+ 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();