]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/baseui.js
TODO update, also include more instead of sortables.
[irc/quakenet/qwebirc.git] / js / ui / baseui.js
index 53f5bc048d3273d45506fbd586f48105a83ba3d2..a563b6367298679ea25c6586e49437a733595052 100644 (file)
@@ -25,6 +25,8 @@ qwebirc.ui.BaseUI = new Class({
     this.commandhistory = new qwebirc.irc.CommandHistory();
   },
   newClient: function(client) {
+    client.hilightController = new qwebirc.ui.HilightController(client);
+    
     this.windows[client] = {}
     var w = this.newWindow(client, qwebirc.ui.WINDOW_STATUS, "Status");
     this.selectWindow(w);
@@ -59,6 +61,29 @@ qwebirc.ui.BaseUI = new Class({
     window.select();  /* calls setActiveWindow */
     document.title = window.name + " - " + this.options.appTitle;
   },
+  nextWindow: function(direction) {
+    if(this.windowArray.length == 0 || !this.active)
+      return;
+      
+    if(!direction)
+      direction = 1;
+      
+    var index = this.windowArray.indexOf(this.active);
+    if(index == -1)
+      return;
+      
+    index = index + direction;
+    if(index < 0) {
+      index = this.windowArray.length - 1;
+    } else if(index >= this.windowArray.length) {
+      index = 0;
+    }
+    
+    this.selectWindow(this.windowArray[index]);
+  },
+  prevWindow: function() {
+    this.nextWindow(-1);
+  },
   __closed: function(window) {
     if(window.active) {
       this.active = undefined;
@@ -73,11 +98,10 @@ qwebirc.ui.BaseUI = new Class({
         } else {
           this.selectWindow(this.windowArray[index - 1]);
         }
-        
-        this.windowArray = this.windowArray.erase(window);
       }
     }
     
+    this.windowArray = this.windowArray.erase(window);
     delete this.windows[window.client][window.identifier];
   },
     /*
@@ -96,20 +120,31 @@ qwebirc.ui.StandardUI = new Class({
   Extends: qwebirc.ui.BaseUI,
   initialize: function(parentElement, windowClass, uiName, options) {
     this.parent(parentElement, windowClass, uiName, options);
+
+    this.tabCompleter = new qwebirc.ui.TabCompleterFactory(this);
+
     window.addEvent("keydown", function(x) {
-      if(!x.alt)
+      if(!x.alt || x.control)
         return;
         
+      var success = false;
       if(x.key == "a" || x.key == "A") {
+        var highestNum = 0;
+        var highestIndex = -1;
+        success = true;
+        
         new Event(x).stop();
         for(var i=0;i<this.windowArray.length;i++) {
-          if(this.windowArray[i].hilighted) {
-            this.selectWindow(this.windowArray[i]);
-            break;
+          var h = this.windowArray[i].hilighted;
+          if(h > highestNum) {
+            highestIndex = i;
+            highestNum = h;
           }
         }
+        if(highestIndex > -1)
+          this.selectWindow(this.windowArray[highestIndex]);
       } else if(x.key >= '0' && x.key <= '9') {
-        new Event(x).stop();
+        success = true;
         
         number = x.key - '0';
         if(number == 0)
@@ -121,7 +156,15 @@ qwebirc.ui.StandardUI = new Class({
           return;
           
         this.selectWindow(this.windowArray[number]);
+      } else if(x.key == "left") {
+        this.prevWindow();
+        success = true;
+      } else if(x.key == "right") {
+        this.nextWindow();
+        success = true;
       }
+      if(success)
+        new Event(x).stop();      
     }.bind(this));
   },
   newCustomWindow: function(name, select, type) {
@@ -149,6 +192,7 @@ qwebirc.ui.StandardUI = new Class({
       this.embedded = null;
     }.bind(this));
         
+    this.embedded.lines.addClass("embeddedwizard");
     var ew = new qwebirc.ui.EmbedWizard({parent: this.embedded.lines});
     ew.addEvent("close", function() {
       this.embedded.close();
@@ -156,9 +200,15 @@ qwebirc.ui.StandardUI = new Class({
   },
   urlDispatcher: function(name) {
     if(name == "embedded")
-      return this.embeddedWindow.bind(this);
+      return ["a", this.embeddedWindow.bind(this)];
 
     return null;
+  },
+  tabComplete: function(element) {
+    this.tabCompleter.tabComplete(element);
+  },
+  resetTabComplete: function() {
+    this.tabCompleter.reset();
   }
 });
 
@@ -166,9 +216,14 @@ qwebirc.ui.QuakeNetUI = new Class({
   Extends: qwebirc.ui.StandardUI,
   urlDispatcher: function(name, window) {
     if(name == "qwhois") {
-      return function(auth) {
+      return ["span", function(auth) {
         this.client.exec("/MSG Q whois #" + auth);
-      }.bind(window);
+      }.bind(window)];
+    }
+    if(name == "whois") {
+      return ["span", function(nick) {
+        this.client.exec("/WHOIS " + nick);
+      }.bind(window)];
     }
     
     return this.parent(name);