]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/frontends/qui.js
fix dependency ordering for zope interface (twisted now has its own dependency checke...
[irc/quakenet/qwebirc.git] / js / ui / frontends / qui.js
index 76fe7bdb13312a8cb513a7f6a0813c0c14ceb506..c3b06e246c3a8905ed537e4bf3b3b86ee274c55e 100644 (file)
@@ -39,23 +39,34 @@ qwebirc.ui.QUI = new Class({
     
     this.input = this.qjsui.bottom;
     this.reflow = this.qjsui.reflow.bind(this.qjsui);
-    
-    this.tabs.addEvent("mousewheel", function(x) {
-      if(this.sideTabs)
-        return;
 
+    var scrollHandler = function(x) {
       var event = new Event(x);
+      var up, down;
+      if(this.sideTabs) {
+        var p = this.qjsui.left;
+
+        /* don't scroll if we're scrollable */
+        if(p.getScrollSize().y > p.clientHeight)
+          return;
+
+        up = event.wheel < 0;
+        down = event.wheel > 0;
+      } else {
+        up = event.wheel > 0;
+        down = event.wheel < 0;
+      }
 
-      /* up */
-      if(event.wheel > 0) {
+      if(up) {
         this.nextWindow();
-      } else if(event.wheel < 0) {
-        /* down */
+      } else if(down) {
         this.prevWindow();
       }
       event.stop();
-    }.bind(this));
-    
+    }.bind(this);
+    this.qjsui.left.addEvent("mousewheel", scrollHandler);
+    this.qjsui.top.addEvent("mousewheel", scrollHandler);
+
     this.createInput();
     this.reflow();
     this.reflow.delay(100); /* Konqueror fix */
@@ -178,25 +189,30 @@ qwebirc.ui.QUI = new Class({
       new Event(e).stop();
       sendInput();
     });
-    
-    inputbox.addEvent("focus", this.resetTabComplete.bind(this));
-    inputbox.addEvent("mousedown", this.resetTabComplete.bind(this));
-    
+
+    var reset = this.resetTabComplete.bind(this);
+    inputbox.addEvent("focus", reset);
+    inputbox.addEvent("mousedown", reset);
+    inputbox.addEvent("keypress", reset);
+
     inputbox.addEvent("keydown", function(e) {
       var resultfn;
       var cvalue = inputbox.value;
-      
-      if(e.key == "up") {
+
+      if(e.alt || e.control || e.meta)
+        return;
+
+      if(e.key == "up" && !e.shift) {
         resultfn = this.commandhistory.upLine;
-      } else if(e.key == "down") {
+      } else if(e.key == "down" && !e.shift) {
         resultfn = this.commandhistory.downLine;
-      } else if(e.key == "tab" && !e.altKey && !e.ctrlKey && !e.shiftKey) {
+      } else if(e.key == "tab") {
+        this.tabComplete(inputbox, e.shift);
+
         new Event(e).stop();
-        this.tabComplete(inputbox);
+        e.preventDefault();
         return;
       } else {
-        /* ideally alt and other keys wouldn't break this */
-        this.resetTabComplete();
         return;
       }
       
@@ -207,6 +223,8 @@ qwebirc.ui.QUI = new Class({
       var result = resultfn.bind(this.commandhistory)();
       
       new Event(e).stop();
+      e.preventDefault();
+
       if(!result)
         result = "";
       this.lastcvalue = result;
@@ -336,6 +354,7 @@ qwebirc.ui.QUI.JSUI = new Class({
     left.setStyle("top", topsize.y);
     topic.setStyle("top", topsize.y);
     topic.setStyle("left", leftsize.x);
+    topic.setStyle("width", docsize.x - leftsize.x);
     
     middle.setStyle("top", (topsize.y + topicsize.y));
     middle.setStyle("left", leftsize.x);
@@ -371,7 +390,7 @@ qwebirc.ui.QUI.Window = new Class({
   initialize: function(parentObject, client, type, name, identifier) {
     this.parent(parentObject, client, type, name, identifier);
 
-    this.tab = new Element("a", {"href": "#"});
+    this.tab = new Element("a");
     this.tab.addClass("tab");
     this.tab.addEvent("focus", function() { this.blur() }.bind(this.tab));;
 
@@ -436,7 +455,7 @@ qwebirc.ui.QUI.Window = new Class({
       this.scrollpos = this.getScrollParent().getScroll();
     }.bind(this));
     
-    if(type == qwebirc.ui.WINDOW_CHANNEL) {
+    if(type == qwebirc.ui.WINDOW_CHANNEL || type == qwebirc.ui.WINDOW_QUERY) {
       this.topic = new Element("div");
       this.parentObject.qjsui.applyClasses("topic", this.topic);
       this.topic.addClass("topic");
@@ -444,25 +463,35 @@ qwebirc.ui.QUI.Window = new Class({
       this.topic.set("html", "&nbsp;");
       this.topic.addEvent("dblclick", this.editTopic.bind(this));
       this.parentObject.qjsui.applyClasses("topic", this.topic);
-      
+
       this.prevNick = null;
       this.nicklist = new Element("div");
       this.nicklist.addClass("nicklist");
       this.nicklist.addClass("tab-invisible");
       this.nicklist.addEvent("click", this.removePrevMenu.bind(this));
       this.parentObject.qjsui.applyClasses("right", this.nicklist);
+
+      this.updateTopic("");
     }
     
-    if(type == qwebirc.ui.WINDOW_CHANNEL)
-      this.updateTopic("");
-
     this.nicksColoured = this.parentObject.uiOptions.NICK_COLOURS;
     this.reflow();
   },
   rename: function(name) {
-    this.tab.replaceChild(document.createTextNode(name), this.tab.firstChild);
+    var newNode = document.createTextNode(name);
+    if(this.parentObject.sideTabs) {
+      this.tab.replaceChild(newNode, this.tab.childNodes[1]);
+    } else {
+      this.tab.replaceChild(newNode, this.tab.firstChild);
+    }
+
+    if(this.type == qwebirc.ui.WINDOW_QUERY)
+      this.updateTopic("");
   },
   editTopic: function() {
+    if(this.type != qwebirc.ui.WINDOW_CHANNEL)
+      return;
+
     if(!this.client.nickOnChanHasPrefix(this.client.nickname, this.name, "@")) {
 /*      var cmodes = this.client.getChannelModes(channel);
       if(cmodes.indexOf("t")) {*/
@@ -507,7 +536,6 @@ qwebirc.ui.QUI.Window = new Class({
       var e2 = new Element("a");
       e.appendChild(e2);
 
-      e2.href = "#";
       e2.set("text", "- " + x.text);
 
       e2.addEvent("focus", function() { this.blur() }.bind(e2));
@@ -547,8 +575,6 @@ qwebirc.ui.QUI.Window = new Class({
     
     var e = new Element("a");
     qwebirc.ui.insertAt(position, this.nicklist, e);
-    
-    e.href = "#";
     var span = new Element("span");
     if(this.parentObject.uiOptions.NICK_COLOURS) {
       var colour = realNick.toHSBColour(this.client);
@@ -588,16 +614,23 @@ qwebirc.ui.QUI.Window = new Class({
     while(t.firstChild)
       t.removeChild(t.firstChild);
 
-    if(topic) {
-      t.topicText = topic;
-      this.parent(topic, t);
+    var suffix;
+    if(this.type == qwebirc.ui.WINDOW_CHANNEL) {
+      suffix = ": ";
     } else {
+      suffix = "";
+    }
+    qwebirc.ui.Colourise(this.name + suffix, t, null, null, this);
+
+    if(this.type == qwebirc.ui.WINDOW_CHANNEL) {
       t.topicText = topic;
-      var e = new Element("div");
-      e.set("text", "(no topic set)");
-      e.addClass("emptytopic");
-      t.appendChild(e);
+      if (topic) {
+        this.parent(topic, t);
+      } else {
+        t.appendChild(document.createTextNode("(no topic set)"));
+      }
     }
+
     this.reflow();
   },
   select: function() {