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