]> jfr.im git - irc/quakenet/qwebirc.git/blame - js/ui/frontends/qui.js
replace menu icon with hamburger
[irc/quakenet/qwebirc.git] / js / ui / frontends / qui.js
CommitLineData
e20e5a6b 1qwebirc.ui.QUI = new Class({
144ee52f 2 Extends: qwebirc.ui.RootUI,
2cad083e
CP
3 initialize: function(parentElement, theme, options) {
4 this.parent(parentElement, qwebirc.ui.QUI.Window, "qui", options);
e20e5a6b
CP
5 this.theme = theme;
6 this.parentElement = parentElement;
4dd199c3 7 this.setModifiableStylesheet("qui");
e20e5a6b
CP
8 },
9 postInitialize: function() {
10 this.qjsui = new qwebirc.ui.QUI.JSUI("qwebirc-qui", this.parentElement);
bfbe72f9
CP
11 this.qjsui.addEvent("reflow", function() {
12 var w = this.getActiveWindow();
13 if($defined(w))
14 w.onResize();
15 }.bind(this));
941e1642 16 this.qjsui.top.addClass("outertabbar");
e20e5a6b
CP
17
18 this.qjsui.bottom.addClass("input");
19 this.qjsui.right.addClass("nicklist");
20 this.qjsui.topic.addClass("topic");
21 this.qjsui.middle.addClass("lines");
22
941e1642 23 this.outerTabs = this.qjsui.top;
0989d983 24
941e1642
CP
25 this.tabs = new Element("div");
26 this.tabs.addClass("tabbar");
9da8639a
CP
27
28 this.__createDropdownMenu();
29
941e1642 30 this.outerTabs.appendChild(this.tabs);
e20e5a6b
CP
31 this.origtopic = this.topic = this.qjsui.topic;
32 this.origlines = this.lines = this.qjsui.middle;
33 this.orignicklist = this.nicklist = this.qjsui.right;
34
35 this.input = this.qjsui.bottom;
36 this.reflow = this.qjsui.reflow.bind(this.qjsui);
37
ff4befd8
CP
38 this.tabs.addEvent("mousewheel", function(x) {
39 var event = new Event(x);
40
41 /* up */
42 if(event.wheel > 0) {
43 this.nextWindow();
44 } else if(event.wheel < 0) {
45 /* down */
b35116e2 46 this.prevWindow();
ff4befd8
CP
47 }
48 event.stop();
49 }.bind(this));
50
e20e5a6b
CP
51 this.createInput();
52 this.reflow();
0a55be30 53 this.reflow.delay(100); /* Konqueror fix */
e20e5a6b 54 },
0989d983 55 __createDropdownMenu: function() {
e9837dce 56 var dropdownMenu = new Element("span");
43cb8910 57 dropdownMenu.addClass("dropdownmenu");
0989d983
CP
58
59 dropdownMenu.hide = function() {
43cb8910
CP
60 dropdownMenu.setStyle("display", "none");
61 dropdownMenu.visible = false;
e9837dce 62 document.removeEvent("mousedown", hideEvent);
43cb8910 63 }.bind(this);
e9837dce 64 var hideEvent = function() { dropdownMenu.hide(); };
0989d983
CP
65
66 dropdownMenu.hide();
43cb8910
CP
67 this.parentElement.appendChild(dropdownMenu);
68
69 this.UICommands.forEach(function(x) {
70 var text = x[0];
71 var fn = this[x[1] + "Window"].bind(this);
72 var e = new Element("a");
0989d983 73 e.addEvent("mousedown", function(e) { new Event(e).stop(); });
43cb8910
CP
74 e.addEvent("click", function() {
75 dropdownMenu.hide();
76 fn();
77 });
78 e.set("text", text);
79 dropdownMenu.appendChild(e);
80 }.bind(this));
81
941e1642 82 var dropdown = new Element("div");
43cb8910 83 dropdown.addClass("dropdown-tab");
fbe5af77 84 dropdown.appendChild(new Element("img", {src: qwebirc.global.staticBaseURL + "images/icon.png", title: "menu", alt: "menu"}));
391f51ff
CP
85 dropdown.setStyle("opacity", 1);
86
941e1642 87 this.outerTabs.appendChild(dropdown);
9da8639a 88 dropdownMenu.show = function(x) {
43cb8910 89 new Event(x).stop();
321abaf8 90
43cb8910
CP
91 if(dropdownMenu.visible) {
92 dropdownMenu.hide();
93 return;
94 }
e9837dce
CP
95 var top = this.outerTabs.getSize().y;
96
941e1642 97 dropdownMenu.setStyle("left", 0);
385143a6 98 dropdownMenu.setStyle("top", top-1); /* -1 == top border */
43cb8910
CP
99 dropdownMenu.setStyle("display", "inline-block");
100 dropdownMenu.visible = true;
e9837dce
CP
101
102 document.addEvent("mousedown", hideEvent);
43cb8910 103 }.bind(this);
e9837dce 104 dropdown.addEvent("mousedown", function(e) { new Event(e).stop(); });
43cb8910 105 dropdown.addEvent("click", dropdownMenu.show);
0989d983 106 },
e20e5a6b
CP
107 createInput: function() {
108 var form = new Element("form");
109 this.input.appendChild(form);
c1416a8d 110
e20e5a6b
CP
111 form.addClass("input");
112
113 var inputbox = new Element("input");
fc38a626 114 this.addEvent("signedOn", function() {
1761242b 115 inputbox.placeholder = "chat here! you can also use commands, like /JOIN or /HELP";
63494576
CP
116 var d = function() { inputbox.addClass("input-flash"); }.delay(250);
117 var d = function() { inputbox.removeClass("input-flash"); }.delay(500);
118 var d = function() { inputbox.addClass("input-flash"); }.delay(750);
119 var d = function() { inputbox.removeClass("input-flash"); }.delay(1000);
120 var d = function() { inputbox.addClass("input-flash"); }.delay(1250);
121 var d = function() { inputbox.removeClass("input-flash"); }.delay(1750);
fc38a626 122 });
e20e5a6b
CP
123 form.appendChild(inputbox);
124 this.inputbox = inputbox;
7c82e345 125 this.inputbox.maxLength = 470;
c1416a8d
CP
126
127 var sendInput = function() {
e20e5a6b
CP
128 if(inputbox.value == "")
129 return;
130
3184781b 131 this.resetTabComplete();
e20e5a6b
CP
132 this.getActiveWindow().historyExec(inputbox.value);
133 inputbox.value = "";
fc38a626 134 inputbox.placeholder = "";
c1416a8d
CP
135 }.bind(this);
136
137 if(!qwebirc.util.deviceHasKeyboard()) {
138 inputbox.addClass("mobile-input");
139 var inputButton = new Element("input", {type: "button"});
140 inputButton.addClass("mobile-button");
141 inputButton.addEvent("click", function() {
142 sendInput();
143 inputbox.focus();
144 });
145 inputButton.value = ">";
146 this.input.appendChild(inputButton);
147 var reflowButton = function() {
148 var containerSize = this.input.getSize();
149 var buttonSize = inputButton.getSize();
150
151 var buttonLeft = containerSize.x - buttonSize.x - 5; /* lovely 5 */
152
153 inputButton.setStyle("left", buttonLeft);
154 inputbox.setStyle("width", buttonLeft - 5);
155 inputButton.setStyle("height", containerSize.y);
156 }.bind(this);
157 this.qjsui.addEvent("reflow", reflowButton);
158 } else {
159 inputbox.addClass("keyboard-input");
160 }
161
162 form.addEvent("submit", function(e) {
163 new Event(e).stop();
164 sendInput();
165 });
e20e5a6b 166
3184781b
CP
167 inputbox.addEvent("focus", this.resetTabComplete.bind(this));
168 inputbox.addEvent("mousedown", this.resetTabComplete.bind(this));
169
e20e5a6b
CP
170 inputbox.addEvent("keydown", function(e) {
171 var resultfn;
172 var cvalue = inputbox.value;
3184781b 173
e20e5a6b
CP
174 if(e.key == "up") {
175 resultfn = this.commandhistory.upLine;
176 } else if(e.key == "down") {
177 resultfn = this.commandhistory.downLine;
325d6a9f 178 } else if(e.key == "tab" && !e.altKey && !e.ctrlKey && !e.shiftKey) {
3184781b
CP
179 new Event(e).stop();
180 this.tabComplete(inputbox);
181 return;
e20e5a6b 182 } else {
3184781b
CP
183 /* ideally alt and other keys wouldn't break this */
184 this.resetTabComplete();
e20e5a6b
CP
185 return;
186 }
187
3184781b 188 this.resetTabComplete();
e20e5a6b
CP
189 if((cvalue != "") && (this.lastcvalue != cvalue))
190 this.commandhistory.addLine(cvalue, true);
191
192 var result = resultfn.bind(this.commandhistory)();
193
194 new Event(e).stop();
195 if(!result)
196 result = "";
197 this.lastcvalue = result;
198
199 inputbox.value = result;
1d6756bc 200 qwebirc.util.setAtEnd(inputbox);
e20e5a6b
CP
201 }.bind(this));
202 },
203 setLines: function(lines) {
204 this.lines.parentNode.replaceChild(lines, this.lines);
205 this.qjsui.middle = this.lines = lines;
206 },
207 setChannelItems: function(nicklist, topic) {
208 if(!$defined(nicklist)) {
209 nicklist = this.orignicklist;
210 topic = this.origtopic;
211 }
212 this.nicklist.parentNode.replaceChild(nicklist, this.nicklist);
213 this.qjsui.right = this.nicklist = nicklist;
214
215 this.topic.parentNode.replaceChild(topic, this.topic);
216 this.qjsui.topic = this.topic = topic;
217 }
218});
219
220qwebirc.ui.QUI.JSUI = new Class({
bfbe72f9 221 Implements: [Events],
b1ee83f3
CP
222 initialize: function(class_, parent, sizer) {
223 this.parent = parent;
224 this.sizer = $defined(sizer)?sizer:parent;
225
24ede2cb
CP
226 this.class_ = class_;
227 this.create();
228
6c19eb8f
CP
229 this.reflowevent = null;
230
b1ee83f3 231 window.addEvent("resize", function() {
6c19eb8f 232 this.reflow(100);
b1ee83f3
CP
233 }.bind(this));
234 },
24ede2cb 235 applyClasses: function(pos, l) {
6c19eb8f 236 l.addClass("dynamicpanel");
24ede2cb 237 l.addClass(this.class_);
6c19eb8f 238
24ede2cb
CP
239 if(pos == "middle") {
240 l.addClass("leftboundpanel");
241 } else if(pos == "top") {
242 l.addClass("topboundpanel");
243 l.addClass("widepanel");
244 } else if(pos == "topic") {
245 l.addClass("widepanel");
246 } else if(pos == "right") {
247 l.addClass("rightboundpanel");
248 } else if(pos == "bottom") {
249 l.addClass("bottomboundpanel");
250 l.addClass("widepanel");
251 }
252 },
253 create: function() {
254 var XE = function(pos) {
255 var element = new Element("div");
256 this.applyClasses(pos, element);
b1ee83f3 257
24ede2cb
CP
258 this.parent.appendChild(element);
259 return element;
b1ee83f3
CP
260 }.bind(this);
261
24ede2cb
CP
262 this.top = XE("top");
263 this.topic = XE("topic");
264 this.middle = XE("middle");
265 this.right = XE("right");
266 this.bottom = XE("bottom");
b1ee83f3 267 },
6c19eb8f
CP
268 reflow: function(delay) {
269 if(!delay)
270 delay = 1;
271
272 if(this.reflowevent)
273 $clear(this.reflowevent);
274 this.__reflow();
275 this.reflowevent = this.__reflow.delay(delay, this);
276 },
277 __reflow: function() {
b1ee83f3
CP
278 var bottom = this.bottom;
279 var middle = this.middle;
280 var right = this.right;
281 var topic = this.topic;
282 var top = this.top;
283
284 var topicsize = topic.getSize();
285 var topsize = top.getSize();
286 var rightsize = right.getSize();
287 var bottomsize = bottom.getSize();
288 var docsize = this.sizer.getSize();
289
290 var mheight = (docsize.y - topsize.y - bottomsize.y - topicsize.y);
291 var mwidth = (docsize.x - rightsize.x);
292
4b9f894d 293 topic.setStyle("top", topsize.y);
b1ee83f3 294
4b9f894d 295 middle.setStyle("top", (topsize.y + topicsize.y));
b1ee83f3 296 if(mheight > 0) {
4b9f894d
CP
297 middle.setStyle("height", mheight);
298 right.setStyle("height", mheight);
b1ee83f3
CP
299 }
300
6c19eb8f 301 if(mwidth > 0)
4b9f894d
CP
302 middle.setStyle("width", mwidth);
303 right.setStyle("top", (topsize.y + topicsize.y));
304 right.setStyle("left", mwidth);
b1ee83f3 305
4b9f894d 306 bottom.setStyle("top", (docsize.y - bottomsize.y));
bfbe72f9 307 this.fireEvent("reflow");
b1ee83f3 308 },
5f464ed5 309 showChannel: function(state, nicklistVisible) {
b1ee83f3
CP
310 var display = "none";
311 if(state)
312 display = "block";
313
5f464ed5 314 this.right.setStyle("display", nicklistVisible ? display : "none");
b1ee83f3 315 this.topic.setStyle("display", display);
6c19eb8f
CP
316 },
317 showInput: function(state) {
941e1642 318 this.bottom.isVisible = state;
6c19eb8f 319 this.bottom.setStyle("display", state?"block":"none");
b1ee83f3
CP
320 }
321});
35155ba7 322
e20e5a6b
CP
323qwebirc.ui.QUI.Window = new Class({
324 Extends: qwebirc.ui.Window,
f4ae92cc 325
f74802c5
CP
326 initialize: function(parentObject, client, type, name, identifier) {
327 this.parent(parentObject, client, type, name, identifier);
be0bd774 328
66de775f 329 this.tab = new Element("a", {"href": "#"});
f4ae92cc 330 this.tab.addClass("tab");
fd60516d 331 this.tab.addEvent("focus", function() { this.blur() }.bind(this.tab));;
ff1c78b3
CP
332
333 this.spaceNode = document.createTextNode(" ");
35155ba7 334 parentObject.tabs.appendChild(this.tab);
ff1c78b3 335 parentObject.tabs.appendChild(this.spaceNode);
f4ae92cc
CP
336
337 this.tab.appendText(name);
66de775f
CP
338 this.tab.addEvent("click", function(e) {
339 new Event(e).stop();
f84bf379
CP
340
341 if(this.closed)
342 return;
343
f4ae92cc
CP
344 parentObject.selectWindow(this);
345 }.bind(this));
f4ae92cc 346
e20e5a6b
CP
347 if(type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT) {
348 var tabclose = new Element("span");
349 tabclose.set("text", "X");
f4ae92cc 350 tabclose.addClass("tabclose");
f84bf379 351 var close = function(e) {
f4ae92cc
CP
352 new Event(e).stop();
353
f84bf379
CP
354 if(this.closed)
355 return;
356
e20e5a6b 357 if(type == qwebirc.ui.WINDOW_CHANNEL)
f4ae92cc
CP
358 this.client.exec("/PART " + name);
359
360 this.close();
3184781b 361
941e1642 362 //parentObject.inputbox.focus();
f84bf379
CP
363 }.bind(this);
364
365 tabclose.addEvent("click", close);
366 this.tab.addEvent("mouseup", function(e) {
b46f79e6
CP
367 var button = 1;
368
369 if(Browser.Engine.trident)
370 button = 4;
371
372 if(e.event.button == button)
f84bf379 373 close(e);
f4ae92cc 374 }.bind(this));
52090a1f 375
f4ae92cc
CP
376 this.tab.appendChild(tabclose);
377 }
be0bd774 378
be0bd774 379 this.lines = new Element("div");
6c19eb8f 380 this.parentObject.qjsui.applyClasses("middle", this.lines);
be0bd774 381 this.lines.addClass("lines");
e82478eb
CP
382 if(type != qwebirc.ui.WINDOW_CUSTOM && type != qwebirc.ui.WINDOW_CONNECT)
383 this.lines.addClass("ircwindow");
6c19eb8f 384
b1ee83f3
CP
385 this.lines.addEvent("scroll", function() {
386 this.scrolleddown = this.scrolledDown();
ff6a32cc 387 this.scrollpos = this.getScrollParent().getScroll();
be0bd774 388 }.bind(this));
be0bd774 389
e20e5a6b 390 if(type == qwebirc.ui.WINDOW_CHANNEL) {
be0bd774
CP
391 this.topic = new Element("div");
392 this.topic.addClass("topic");
b1ee83f3 393 this.topic.addClass("tab-invisible");
be0bd774 394 this.topic.set("html", "&nbsp;");
8eb4377c 395 this.topic.addEvent("dblclick", this.editTopic.bind(this));
6c19eb8f 396 this.parentObject.qjsui.applyClasses("topic", this.topic);
be0bd774 397
52090a1f 398 this.prevNick = null;
66de775f
CP
399 this.nicklist = new Element("div");
400 this.nicklist.addClass("nicklist");
b1ee83f3 401 this.nicklist.addClass("tab-invisible");
cffd43cf 402 this.nicklist.addEvent("click", this.removePrevMenu.bind(this));
6c19eb8f 403 this.parentObject.qjsui.applyClasses("nicklist", this.nicklist);
be0bd774 404 }
b1ee83f3 405
ff1c78b3 406 if(type == qwebirc.ui.WINDOW_CHANNEL)
359b7edd 407 this.updateTopic("");
ff1c78b3 408
f121b688 409 this.nicksColoured = this.parentObject.uiOptions.NICK_COLOURS;
ff1c78b3 410 this.reflow();
b1ee83f3 411 },
5aa173fb
CP
412 rename: function(name) {
413 this.tab.replaceChild(document.createTextNode(name), this.tab.firstChild);
414 },
eaf3ed38
CP
415 editTopic: function() {
416 if(!this.client.nickOnChanHasPrefix(this.client.nickname, this.name, "@")) {
417/* var cmodes = this.client.getChannelModes(channel);
418 if(cmodes.indexOf("t")) {*/
95d00e97 419 alert("Sorry, you need to be a channel operator to change the topic!");
eaf3ed38
CP
420 return;
421 /*}*/
422 }
423 var newTopic = prompt("Change topic of " + this.name + " to:", this.topic.topicText);
424 if(newTopic === null)
425 return;
426
427 this.client.exec("/TOPIC " + newTopic);
428 },
b1ee83f3
CP
429 reflow: function() {
430 this.parentObject.reflow();
35155ba7
CP
431 },
432 onResize: function() {
ff6a32cc
CP
433 if(this.scrolleddown) {
434 if(Browser.Engine.trident) {
435 this.scrollToBottom.delay(5, this);
436 } else {
437 this.scrollToBottom();
438 }
439 } else if($defined(this.scrollpos)) {
440 if(Browser.Engine.trident) {
441 this.getScrollParent().scrollTo(this.scrollpos.x, this.scrollpos.y);
442 } else {
443 this.getScrollParent().scrollTo.delay(5, this, [this.scrollpos.x, this.scrollpos.y]);
444 }
445 }
359b7edd 446 },
cffd43cf 447 createMenu: function(nick, parent) {
d2512acf 448 var e = new Element("div");
cffd43cf
CP
449 parent.appendChild(e);
450 e.addClass("menu");
451
27add99a 452 var nickArray = [nick];
cffd43cf 453 qwebirc.ui.MENU_ITEMS.forEach(function(x) {
27add99a
CP
454 if(!x.predicate || x.predicate !== true && !x.predicate.apply(this, nickArray))
455 return;
456
457 var e2 = new Element("a");
458 e.appendChild(e2);
7555d601 459
27add99a
CP
460 e2.href = "#";
461 e2.set("text", "- " + x.text);
7555d601 462
27add99a
CP
463 e2.addEvent("focus", function() { this.blur() }.bind(e2));
464 e2.addEvent("click", function(ev) { new Event(ev.stop()); this.menuClick(x.fn); }.bind(this));
cffd43cf
CP
465 }.bind(this));
466 return e;
467 },
468 menuClick: function(fn) {
469 /*
470 this.prevNick.removeChild(this.prevNick.menu);
471 this.prevNick.menu = null;
472 */
473 fn.bind(this)(this.prevNick.realNick);
474 this.removePrevMenu();
475 },
d8272bcb
CP
476 moveMenuClass: function() {
477 if(!this.prevNick)
478 return;
479 if(this.nicklist.firstChild == this.prevNick) {
480 this.prevNick.removeClass("selected-middle");
481 } else {
482 this.prevNick.addClass("selected-middle");
483 }
484 },
cffd43cf
CP
485 removePrevMenu: function() {
486 if(!this.prevNick)
487 return;
488
489 this.prevNick.removeClass("selected");
d8272bcb 490 this.prevNick.removeClass("selected-middle");
cffd43cf
CP
491 if(this.prevNick.menu)
492 this.prevNick.removeChild(this.prevNick.menu);
493 this.prevNick = null;
494 },
52090a1f 495 nickListAdd: function(nick, position) {
f121b688
CP
496 var realNick = this.client.stripPrefix(nick);
497
52090a1f
CP
498 var e = new Element("a");
499 qwebirc.ui.insertAt(position, this.nicklist, e);
f4ae92cc 500
52090a1f 501 e.href = "#";
f121b688
CP
502 var span = new Element("span");
503 if(this.parentObject.uiOptions.NICK_COLOURS) {
504 var colour = realNick.toHSBColour(this.client);
505 if($defined(colour))
506 span.setStyle("color", colour.rgbToHex());
507 }
508 span.set("text", nick);
509 e.appendChild(span);
52090a1f 510
f121b688 511 e.realNick = realNick;
52090a1f
CP
512
513 e.addEvent("click", function(x) {
aab6d06a
CP
514 if(this.prevNick == e) {
515 this.removePrevMenu();
516 return;
517 }
518
cffd43cf 519 this.removePrevMenu();
52090a1f
CP
520 this.prevNick = e;
521 e.addClass("selected");
d8272bcb 522 this.moveMenuClass();
27add99a 523 e.menu = this.createMenu(e.realNick, e);
52090a1f
CP
524 new Event(x).stop();
525 }.bind(this));
52090a1f 526
fd60516d 527 e.addEvent("focus", function() { this.blur() }.bind(e));
d8272bcb 528 this.moveMenuClass();
52090a1f
CP
529 return e;
530 },
531 nickListRemove: function(nick, stored) {
532 this.nicklist.removeChild(stored);
d8272bcb 533 this.moveMenuClass();
f4ae92cc
CP
534 },
535 updateTopic: function(topic) {
f4ae92cc
CP
536 var t = this.topic;
537
538 while(t.firstChild)
539 t.removeChild(t.firstChild);
540
66de775f 541 if(topic) {
eaf3ed38 542 t.topicText = topic;
1f06a70a 543 this.parent(topic, t);
66de775f 544 } else {
eaf3ed38 545 t.topicText = topic;
359b7edd
CP
546 var e = new Element("div");
547 e.set("text", "(no topic set)");
66de775f 548 e.addClass("emptytopic");
359b7edd 549 t.appendChild(e);
66de775f 550 }
359b7edd 551 this.reflow();
f4ae92cc
CP
552 },
553 select: function() {
e20e5a6b 554 var inputVisible = this.type != qwebirc.ui.WINDOW_CONNECT && this.type != qwebirc.ui.WINDOW_CUSTOM;
6c19eb8f 555
f4ae92cc 556 this.tab.removeClass("tab-unselected");
f4ae92cc 557 this.tab.addClass("tab-selected");
359b7edd 558
6c19eb8f
CP
559 this.parentObject.setLines(this.lines);
560 this.parentObject.setChannelItems(this.nicklist, this.topic);
561 this.parentObject.qjsui.showInput(inputVisible);
5f464ed5 562 this.parentObject.qjsui.showChannel($defined(this.nicklist), this.parentObject.uiOptions.SHOW_NICKLIST);
6c19eb8f
CP
563
564 this.reflow();
24ede2cb 565
7c633700 566 this.parent();
25be5960 567
6c19eb8f
CP
568 if(inputVisible)
569 this.parentObject.inputbox.focus();
f121b688
CP
570
571 if(this.type == qwebirc.ui.WINDOW_CHANNEL && this.nicksColoured != this.parentObject.uiOptions.NICK_COLOURS) {
572 this.nicksColoured = this.parentObject.uiOptions.NICK_COLOURS;
573
574 var nodes = this.nicklist.childNodes;
575 if(this.parentObject.uiOptions.NICK_COLOURS) {
576 for(var i=0;i<nodes.length;i++) {
577 var e = nodes[i], span = e.firstChild;
578 var colour = e.realNick.toHSBColour(this.client);
579 if($defined(colour))
580 span.setStyle("color", colour.rgbToHex());
581 };
582 } else {
583 for(var i=0;i<nodes.length;i++) {
584 var span = nodes[i].firstChild;
585 span.setStyle("color", null);
586 };
587 }
588 }
f4ae92cc
CP
589 },
590 deselect: function() {
591 this.parent();
592
f4ae92cc
CP
593 this.tab.removeClass("tab-selected");
594 this.tab.addClass("tab-unselected");
595 },
596 close: function() {
597 this.parent();
598
f4ae92cc 599 this.parentObject.tabs.removeChild(this.tab);
ff1c78b3
CP
600 this.parentObject.tabs.removeChild(this.spaceNode);
601 this.reflow();
f4ae92cc 602 },
b35116e2 603 addLine: function(type, line, colourClass) {
f4ae92cc
CP
604 var e = new Element("div");
605
b35116e2
CP
606 if(colourClass) {
607 e.addClass(colourClass);
f4ae92cc
CP
608 } else if(this.lastcolour) {
609 e.addClass("linestyle1");
610 } else {
611 e.addClass("linestyle2");
612 }
f4ae92cc 613 this.lastcolour = !this.lastcolour;
35155ba7 614
b35116e2 615 this.parent(type, line, colourClass, e);
be0bd774
CP
616 },
617 setHilighted: function(state) {
2a802692 618 var laststate = this.hilighted;
96f28062 619
be0bd774 620 this.parent(state);
96f28062
CP
621
622 if(state == laststate)
623 return;
624
625 this.tab.removeClass("tab-hilight-activity");
626 this.tab.removeClass("tab-hilight-us");
627 this.tab.removeClass("tab-hilight-speech");
f4ae92cc 628
96f28062
CP
629 switch(this.hilighted) {
630 case qwebirc.ui.HILIGHT_US:
631 this.tab.addClass("tab-hilight-us");
632 break;
633 case qwebirc.ui.HILIGHT_SPEECH:
634 this.tab.addClass("tab-hilight-speech");
635 break;
636 case qwebirc.ui.HILIGHT_ACTIVITY:
637 this.tab.addClass("tab-hilight-activity");
638 break;
be0bd774 639 }
f4ae92cc
CP
640 }
641});