]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/qui.js
Fix version in ctcp.
[irc/quakenet/qwebirc.git] / js / ui / qui.js
index 21272b4781b04557b4d3f8a1c2c51b1e12c532c6..495f6b7b05393fd6b74ea91e805343c6d45fbd7b 100644 (file)
@@ -23,6 +23,19 @@ qwebirc.ui.QUI = new Class({
     this.input = this.qjsui.bottom;
     this.reflow = this.qjsui.reflow.bind(this.qjsui);
     
+    this.tabs.addEvent("mousewheel", function(x) {
+      var event = new Event(x);
+      
+      /* up */
+      if(event.wheel > 0) {
+        this.nextWindow();
+      } else if(event.wheel < 0) {
+        /* down */
+        this.prevWindow();        
+      }
+      event.stop();
+    }.bind(this));
+    
     this.createInput();
     this.reflow();
   },
@@ -196,6 +209,8 @@ qwebirc.ui.QUI.Window = new Class({
 
     this.tab = new Element("a", {"href": "#"});
     this.tab.addClass("tab");
+    this.tab.addEvent("focus", function() { this.blur() }.bind(this.tab));;
+    
     parentObject.tabs.appendChild(this.tab);
     
     this.tab.appendText(name);
@@ -216,7 +231,7 @@ qwebirc.ui.QUI.Window = new Class({
 
         this.close();
       }.bind(this));
-
+      
       this.tab.appendChild(tabclose);
     }
 
@@ -235,9 +250,11 @@ qwebirc.ui.QUI.Window = new Class({
       this.topic.set("html", "&nbsp;");
       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("nicklist", this.nicklist);
     }
     
@@ -254,18 +271,84 @@ qwebirc.ui.QUI.Window = new Class({
     if(this.scrolleddown)
       this.scrollToBottom();
   },
-  updateNickList: function(nicks) {
-    this.parent(nicks);
+  createMenu: function(nick, parent) {
+    var e = new Element("div");
+    parent.appendChild(e);
+    e.addClass("menu");
     
-    var n = this.nicklist;
-    while(n.firstChild)
-      n.removeChild(n.firstChild);
-
-    nicks.each(function(nick) {
-      var e = new Element("div");
-      n.appendChild(e);
-      e.appendChild(document.createTextNode(nick));
-    });
+    qwebirc.ui.MENU_ITEMS.forEach(function(x) {
+      var e2 = new Element("a");
+      e.appendChild(e2);
+      
+      e2.href = "#";
+      e2.set("text", "- " + x[0]);
+      
+      e2.addEvent("focus", function() { this.blur() }.bind(e2));
+      e2.addEvent("click", function(ev) { new Event(ev.stop()); this.menuClick(x[1]); }.bind(this));
+    }.bind(this));
+    return e;
+  },
+  menuClick: function(fn) {
+    /*
+    this.prevNick.removeChild(this.prevNick.menu);
+    this.prevNick.menu = null;
+    */
+    fn.bind(this)(this.prevNick.realNick);
+    this.removePrevMenu();
+  },
+  moveMenuClass: function() {
+    if(!this.prevNick)
+      return;
+    if(this.nicklist.firstChild == this.prevNick) {
+      this.prevNick.removeClass("selected-middle");
+    } else {
+      this.prevNick.addClass("selected-middle");
+    }
+  },
+  removePrevMenu: function() {
+    if(!this.prevNick)
+      return;
+      
+    this.prevNick.removeClass("selected");
+    this.prevNick.removeClass("selected-middle");
+    if(this.prevNick.menu)
+      this.prevNick.removeChild(this.prevNick.menu);
+    this.prevNick = null;
+  },
+  nickListAdd: function(nick, position) {
+    var e = new Element("a");
+    qwebirc.ui.insertAt(position, this.nicklist, e);
+    
+    e.href = "#";
+    e.appendChild(document.createTextNode(nick));
+    
+    e.realNick = this.client.stripPrefix(nick);
+    
+    e.addEvent("click", function(x) {
+      if(this.prevNick == e) {
+        this.removePrevMenu();
+        return;
+      }
+      
+      this.removePrevMenu();
+      this.prevNick = e;
+      e.addClass("selected");
+      this.moveMenuClass();
+      e.menu = this.createMenu(x.realNick, e);
+      new Event(x).stop();
+    }.bind(this));
+    e.addEvent("dblclick", function(x) {
+      new Event(x).stop();
+      this.client.exec("/QUERY " + e.realNick);
+    }.bind(this));
+    
+    e.addEvent("focus", function() { this.blur() }.bind(e));
+    this.moveMenuClass();
+    return e;
+  },
+  nickListRemove: function(nick, stored) {
+    this.nicklist.removeChild(stored);
+    this.moveMenuClass();
   },
   updateTopic: function(topic) {
     var t = this.topic;
@@ -327,12 +410,27 @@ qwebirc.ui.QUI.Window = new Class({
     this.parent(type, line, colour, e);
   },
   setHilighted: function(state) {
+    laststate = this.hilighted;
+    
     this.parent(state);
+
+    if(state == laststate)
+      return;
+      
+    this.tab.removeClass("tab-hilight-activity");
+    this.tab.removeClass("tab-hilight-us");
+    this.tab.removeClass("tab-hilight-speech");
     
-    if(state) {
-      this.tab.addClass("tab-hilighted");
-    } else {
-      this.tab.removeClass("tab-hilighted");
+    switch(this.hilighted) {
+      case qwebirc.ui.HILIGHT_US:
+        this.tab.addClass("tab-hilight-us");
+        break;
+      case qwebirc.ui.HILIGHT_SPEECH:
+        this.tab.addClass("tab-hilight-speech");
+        break;
+      case qwebirc.ui.HILIGHT_ACTIVITY:
+        this.tab.addClass("tab-hilight-activity");
+        break;
     }
   }
 });