]>
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 | this.addEvent("signedOn", function() { | |
150 | inputbox.placeholder = "type commands here, for example: /JOIN #channel"; | |
151 | inputbox.addClass("input-flash"); | |
152 | var d = function() { | |
153 | inputbox.removeClass("input-flash"); | |
154 | }.delay(250); | |
155 | var d = function() { | |
156 | inputbox.addClass("input-flash"); | |
157 | }.delay(500); | |
158 | var d = function() { | |
159 | inputbox.removeClass("input-flash"); | |
160 | }.delay(1250); | |
161 | }); | |
162 | form.appendChild(inputbox); | |
163 | this.inputbox = inputbox; | |
164 | this.inputbox.maxLength = 470; | |
165 | ||
166 | var sendInput = function() { | |
167 | if(inputbox.value == "") | |
168 | return; | |
169 | ||
170 | this.resetTabComplete(); | |
171 | this.getActiveWindow().historyExec(inputbox.value); | |
172 | inputbox.value = ""; | |
173 | inputbox.placeholder = ""; | |
174 | }.bind(this); | |
175 | ||
176 | if(!qwebirc.util.deviceHasKeyboard()) { | |
177 | inputbox.addClass("mobile-input"); | |
178 | var inputButton = new Element("input", {type: "button"}); | |
179 | inputButton.addClass("mobile-button"); | |
180 | inputButton.addEvent("click", function() { | |
181 | sendInput(); | |
182 | inputbox.focus(); | |
183 | }); | |
184 | inputButton.value = ">"; | |
185 | this.input.appendChild(inputButton); | |
186 | var reflowButton = function() { | |
187 | var containerSize = this.input.getSize(); | |
188 | var buttonSize = inputButton.getSize(); | |
189 | ||
190 | var buttonLeft = containerSize.x - buttonSize.x - 5; /* lovely 5 */ | |
191 | ||
192 | inputButton.setStyle("left", buttonLeft); | |
193 | inputbox.setStyle("width", buttonLeft - 5); | |
194 | inputButton.setStyle("height", containerSize.y); | |
195 | }.bind(this); | |
196 | this.qjsui.addEvent("reflow", reflowButton); | |
197 | } else { | |
198 | inputbox.addClass("keyboard-input"); | |
199 | } | |
200 | ||
201 | form.addEvent("submit", function(e) { | |
202 | new Event(e).stop(); | |
203 | sendInput(); | |
204 | }); | |
205 | ||
206 | inputbox.addEvent("focus", this.resetTabComplete.bind(this)); | |
207 | inputbox.addEvent("mousedown", this.resetTabComplete.bind(this)); | |
208 | ||
209 | inputbox.addEvent("keydown", function(e) { | |
210 | var resultfn; | |
211 | var cvalue = inputbox.value; | |
212 | ||
213 | if(e.key == "up") { | |
214 | resultfn = this.commandhistory.upLine; | |
215 | } else if(e.key == "down") { | |
216 | resultfn = this.commandhistory.downLine; | |
217 | } else if(e.key == "tab" && !e.altKey && !e.ctrlKey && !e.shiftKey) { | |
218 | new Event(e).stop(); | |
219 | this.tabComplete(inputbox); | |
220 | return; | |
221 | } else { | |
222 | /* ideally alt and other keys wouldn't break this */ | |
223 | this.resetTabComplete(); | |
224 | return; | |
225 | } | |
226 | ||
227 | this.resetTabComplete(); | |
228 | if((cvalue != "") && (this.lastcvalue != cvalue)) | |
229 | this.commandhistory.addLine(cvalue, true); | |
230 | ||
231 | var result = resultfn.bind(this.commandhistory)(); | |
232 | ||
233 | new Event(e).stop(); | |
234 | if(!result) | |
235 | result = ""; | |
236 | this.lastcvalue = result; | |
237 | ||
238 | inputbox.value = result; | |
239 | qwebirc.util.setAtEnd(inputbox); | |
240 | }.bind(this)); | |
241 | }, | |
242 | setLines: function(lines) { | |
243 | this.lines.parentNode.replaceChild(lines, this.lines); | |
244 | this.qjsui.middle = this.lines = lines; | |
245 | }, | |
246 | setChannelItems: function(nicklist, topic) { | |
247 | if(!$defined(nicklist)) { | |
248 | nicklist = this.orignicklist; | |
249 | topic = this.origtopic; | |
250 | } | |
251 | this.nicklist.parentNode.replaceChild(nicklist, this.nicklist); | |
252 | this.qjsui.right = this.nicklist = nicklist; | |
253 | ||
254 | this.topic.parentNode.replaceChild(topic, this.topic); | |
255 | this.qjsui.topic = this.topic = topic; | |
256 | } | |
257 | }); | |
258 | ||
259 | qwebirc.ui.QUI.JSUI = new Class({ | |
260 | Implements: [Events], | |
261 | initialize: function(class_, parent, sizer) { | |
262 | this.parent = parent; | |
263 | this.sizer = $defined(sizer)?sizer:parent; | |
264 | ||
265 | this.class_ = class_; | |
266 | this.create(); | |
267 | ||
268 | this.reflowevent = null; | |
269 | ||
270 | window.addEvent("resize", function() { | |
271 | this.reflow(100); | |
272 | }.bind(this)); | |
273 | }, | |
274 | applyClasses: function(pos, l) { | |
275 | l.addClass("dynamicpanel"); | |
276 | l.addClass(this.class_); | |
277 | ||
278 | if(pos == "middle") { | |
279 | l.addClass("leftboundpanel"); | |
280 | } else if(pos == "top") { | |
281 | l.addClass("topboundpanel"); | |
282 | l.addClass("widepanel"); | |
283 | } else if(pos == "topic") { | |
284 | l.addClass("widepanel"); | |
285 | } else if(pos == "right") { | |
286 | l.addClass("rightboundpanel"); | |
287 | } else if(pos == "bottom") { | |
288 | l.addClass("bottomboundpanel"); | |
289 | l.addClass("widepanel"); | |
290 | } | |
291 | }, | |
292 | create: function() { | |
293 | var XE = function(pos) { | |
294 | var element = new Element("div"); | |
295 | this.applyClasses(pos, element); | |
296 | ||
297 | this.parent.appendChild(element); | |
298 | return element; | |
299 | }.bind(this); | |
300 | ||
301 | this.top = XE("top"); | |
302 | this.topic = XE("topic"); | |
303 | this.middle = XE("middle"); | |
304 | this.right = XE("right"); | |
305 | this.bottom = XE("bottom"); | |
306 | }, | |
307 | reflow: function(delay) { | |
308 | if(!delay) | |
309 | delay = 1; | |
310 | ||
311 | if(this.reflowevent) | |
312 | $clear(this.reflowevent); | |
313 | this.__reflow(); | |
314 | this.reflowevent = this.__reflow.delay(delay, this); | |
315 | }, | |
316 | __reflow: function() { | |
317 | var bottom = this.bottom; | |
318 | var middle = this.middle; | |
319 | var right = this.right; | |
320 | var topic = this.topic; | |
321 | var top = this.top; | |
322 | ||
323 | var topicsize = topic.getSize(); | |
324 | var topsize = top.getSize(); | |
325 | var rightsize = right.getSize(); | |
326 | var bottomsize = bottom.getSize(); | |
327 | var docsize = this.sizer.getSize(); | |
328 | ||
329 | var mheight = (docsize.y - topsize.y - bottomsize.y - topicsize.y); | |
330 | var mwidth = (docsize.x - rightsize.x); | |
331 | ||
332 | topic.setStyle("top", topsize.y); | |
333 | ||
334 | middle.setStyle("top", (topsize.y + topicsize.y)); | |
335 | if(mheight > 0) { | |
336 | middle.setStyle("height", mheight); | |
337 | right.setStyle("height", mheight); | |
338 | } | |
339 | ||
340 | if(mwidth > 0) | |
341 | middle.setStyle("width", mwidth); | |
342 | right.setStyle("top", (topsize.y + topicsize.y)); | |
343 | right.setStyle("left", mwidth); | |
344 | ||
345 | bottom.setStyle("top", (docsize.y - bottomsize.y)); | |
346 | this.fireEvent("reflow"); | |
347 | }, | |
348 | showChannel: function(state, nicklistVisible) { | |
349 | var display = "none"; | |
350 | if(state) | |
351 | display = "block"; | |
352 | ||
353 | this.right.setStyle("display", nicklistVisible ? display : "none"); | |
354 | this.topic.setStyle("display", display); | |
355 | }, | |
356 | showInput: function(state) { | |
357 | this.bottom.isVisible = state; | |
358 | this.bottom.setStyle("display", state?"block":"none"); | |
359 | } | |
360 | }); | |
361 | ||
362 | qwebirc.ui.QUI.Window = new Class({ | |
363 | Extends: qwebirc.ui.Window, | |
364 | ||
365 | initialize: function(parentObject, client, type, name, identifier) { | |
366 | this.parent(parentObject, client, type, name, identifier); | |
367 | ||
368 | this.tab = new Element("a", {"href": "#"}); | |
369 | this.tab.addClass("tab"); | |
370 | this.tab.addEvent("focus", function() { this.blur() }.bind(this.tab));; | |
371 | ||
372 | this.spaceNode = document.createTextNode(" "); | |
373 | parentObject.tabs.appendChild(this.tab); | |
374 | parentObject.tabs.appendChild(this.spaceNode); | |
375 | ||
376 | this.tab.appendText(name); | |
377 | this.tab.addEvent("click", function(e) { | |
378 | new Event(e).stop(); | |
379 | ||
380 | if(this.closed) | |
381 | return; | |
382 | ||
383 | parentObject.selectWindow(this); | |
384 | }.bind(this)); | |
385 | ||
386 | if(type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT) { | |
387 | var tabclose = new Element("span"); | |
388 | tabclose.set("text", "X"); | |
389 | tabclose.addClass("tabclose"); | |
390 | var close = function(e) { | |
391 | new Event(e).stop(); | |
392 | ||
393 | if(this.closed) | |
394 | return; | |
395 | ||
396 | if(type == qwebirc.ui.WINDOW_CHANNEL) | |
397 | this.client.exec("/PART " + name); | |
398 | ||
399 | this.close(); | |
400 | ||
401 | //parentObject.inputbox.focus(); | |
402 | }.bind(this); | |
403 | ||
404 | tabclose.addEvent("click", close); | |
405 | this.tab.addEvent("mouseup", function(e) { | |
406 | var button = 1; | |
407 | ||
408 | if(Browser.Engine.trident) | |
409 | button = 4; | |
410 | ||
411 | if(e.event.button == button) | |
412 | close(e); | |
413 | }.bind(this)); | |
414 | ||
415 | this.tab.appendChild(tabclose); | |
416 | } | |
417 | ||
418 | this.lines = new Element("div"); | |
419 | this.parentObject.qjsui.applyClasses("middle", this.lines); | |
420 | this.lines.addClass("lines"); | |
421 | if(type != qwebirc.ui.WINDOW_CUSTOM && type != qwebirc.ui.WINDOW_CONNECT) | |
422 | this.lines.addClass("ircwindow"); | |
423 | ||
424 | this.lines.addEvent("scroll", function() { | |
425 | this.scrolleddown = this.scrolledDown(); | |
426 | this.scrollpos = this.getScrollParent().getScroll(); | |
427 | }.bind(this)); | |
428 | ||
429 | if(type == qwebirc.ui.WINDOW_CHANNEL) { | |
430 | this.topic = new Element("div"); | |
431 | this.topic.addClass("topic"); | |
432 | this.topic.addClass("tab-invisible"); | |
433 | this.topic.set("html", " "); | |
434 | this.topic.addEvent("dblclick", this.editTopic.bind(this)); | |
435 | this.parentObject.qjsui.applyClasses("topic", this.topic); | |
436 | ||
437 | this.prevNick = null; | |
438 | this.nicklist = new Element("div"); | |
439 | this.nicklist.addClass("nicklist"); | |
440 | this.nicklist.addClass("tab-invisible"); | |
441 | this.nicklist.addEvent("click", this.removePrevMenu.bind(this)); | |
442 | this.parentObject.qjsui.applyClasses("nicklist", this.nicklist); | |
443 | } | |
444 | ||
445 | if(type == qwebirc.ui.WINDOW_CHANNEL) | |
446 | this.updateTopic(""); | |
447 | ||
448 | this.nicksColoured = this.parentObject.uiOptions.NICK_COLOURS; | |
449 | this.reflow(); | |
450 | }, | |
451 | rename: function(name) { | |
452 | this.tab.replaceChild(document.createTextNode(name), this.tab.firstChild); | |
453 | }, | |
454 | editTopic: function() { | |
455 | if(!this.client.nickOnChanHasPrefix(this.client.nickname, this.name, "@")) { | |
456 | /* var cmodes = this.client.getChannelModes(channel); | |
457 | if(cmodes.indexOf("t")) {*/ | |
458 | alert("Sorry, you need to be a channel operator to change the topic!"); | |
459 | return; | |
460 | /*}*/ | |
461 | } | |
462 | var newTopic = prompt("Change topic of " + this.name + " to:", this.topic.topicText); | |
463 | if(newTopic === null) | |
464 | return; | |
465 | ||
466 | this.client.exec("/TOPIC " + newTopic); | |
467 | }, | |
468 | reflow: function() { | |
469 | this.parentObject.reflow(); | |
470 | }, | |
471 | onResize: function() { | |
472 | if(this.scrolleddown) { | |
473 | if(Browser.Engine.trident) { | |
474 | this.scrollToBottom.delay(5, this); | |
475 | } else { | |
476 | this.scrollToBottom(); | |
477 | } | |
478 | } else if($defined(this.scrollpos)) { | |
479 | if(Browser.Engine.trident) { | |
480 | this.getScrollParent().scrollTo(this.scrollpos.x, this.scrollpos.y); | |
481 | } else { | |
482 | this.getScrollParent().scrollTo.delay(5, this, [this.scrollpos.x, this.scrollpos.y]); | |
483 | } | |
484 | } | |
485 | }, | |
486 | createMenu: function(nick, parent) { | |
487 | var e = new Element("div"); | |
488 | parent.appendChild(e); | |
489 | e.addClass("menu"); | |
490 | ||
491 | var nickArray = [nick]; | |
492 | qwebirc.ui.MENU_ITEMS.forEach(function(x) { | |
493 | if(!x.predicate || x.predicate !== true && !x.predicate.apply(this, nickArray)) | |
494 | return; | |
495 | ||
496 | var e2 = new Element("a"); | |
497 | e.appendChild(e2); | |
498 | ||
499 | e2.href = "#"; | |
500 | e2.set("text", "- " + x.text); | |
501 | ||
502 | e2.addEvent("focus", function() { this.blur() }.bind(e2)); | |
503 | e2.addEvent("click", function(ev) { new Event(ev.stop()); this.menuClick(x.fn); }.bind(this)); | |
504 | }.bind(this)); | |
505 | return e; | |
506 | }, | |
507 | menuClick: function(fn) { | |
508 | /* | |
509 | this.prevNick.removeChild(this.prevNick.menu); | |
510 | this.prevNick.menu = null; | |
511 | */ | |
512 | fn.bind(this)(this.prevNick.realNick); | |
513 | this.removePrevMenu(); | |
514 | }, | |
515 | moveMenuClass: function() { | |
516 | if(!this.prevNick) | |
517 | return; | |
518 | if(this.nicklist.firstChild == this.prevNick) { | |
519 | this.prevNick.removeClass("selected-middle"); | |
520 | } else { | |
521 | this.prevNick.addClass("selected-middle"); | |
522 | } | |
523 | }, | |
524 | removePrevMenu: function() { | |
525 | if(!this.prevNick) | |
526 | return; | |
527 | ||
528 | this.prevNick.removeClass("selected"); | |
529 | this.prevNick.removeClass("selected-middle"); | |
530 | if(this.prevNick.menu) | |
531 | this.prevNick.removeChild(this.prevNick.menu); | |
532 | this.prevNick = null; | |
533 | }, | |
534 | nickListAdd: function(nick, position) { | |
535 | var realNick = this.client.stripPrefix(nick); | |
536 | ||
537 | var e = new Element("a"); | |
538 | qwebirc.ui.insertAt(position, this.nicklist, e); | |
539 | ||
540 | e.href = "#"; | |
541 | var span = new Element("span"); | |
542 | if(this.parentObject.uiOptions.NICK_COLOURS) { | |
543 | var colour = realNick.toHSBColour(this.client); | |
544 | if($defined(colour)) | |
545 | span.setStyle("color", colour.rgbToHex()); | |
546 | } | |
547 | span.set("text", nick); | |
548 | e.appendChild(span); | |
549 | ||
550 | e.realNick = realNick; | |
551 | ||
552 | e.addEvent("click", function(x) { | |
553 | if(this.prevNick == e) { | |
554 | this.removePrevMenu(); | |
555 | return; | |
556 | } | |
557 | ||
558 | this.removePrevMenu(); | |
559 | this.prevNick = e; | |
560 | e.addClass("selected"); | |
561 | this.moveMenuClass(); | |
562 | e.menu = this.createMenu(e.realNick, e); | |
563 | new Event(x).stop(); | |
564 | }.bind(this)); | |
565 | ||
566 | e.addEvent("focus", function() { this.blur() }.bind(e)); | |
567 | this.moveMenuClass(); | |
568 | return e; | |
569 | }, | |
570 | nickListRemove: function(nick, stored) { | |
571 | this.nicklist.removeChild(stored); | |
572 | this.moveMenuClass(); | |
573 | }, | |
574 | updateTopic: function(topic) { | |
575 | var t = this.topic; | |
576 | ||
577 | while(t.firstChild) | |
578 | t.removeChild(t.firstChild); | |
579 | ||
580 | if(topic) { | |
581 | t.topicText = topic; | |
582 | this.parent(topic, t); | |
583 | } else { | |
584 | t.topicText = topic; | |
585 | var e = new Element("div"); | |
586 | e.set("text", "(no topic set)"); | |
587 | e.addClass("emptytopic"); | |
588 | t.appendChild(e); | |
589 | } | |
590 | this.reflow(); | |
591 | }, | |
592 | select: function() { | |
593 | var inputVisible = this.type != qwebirc.ui.WINDOW_CONNECT && this.type != qwebirc.ui.WINDOW_CUSTOM; | |
594 | ||
595 | this.tab.removeClass("tab-unselected"); | |
596 | this.tab.addClass("tab-selected"); | |
597 | ||
598 | this.parentObject.setLines(this.lines); | |
599 | this.parentObject.setChannelItems(this.nicklist, this.topic); | |
600 | this.parentObject.qjsui.showInput(inputVisible); | |
601 | this.parentObject.qjsui.showChannel($defined(this.nicklist), this.parentObject.uiOptions.SHOW_NICKLIST); | |
602 | ||
603 | this.reflow(); | |
604 | ||
605 | this.parent(); | |
606 | ||
607 | if(inputVisible) | |
608 | this.parentObject.inputbox.focus(); | |
609 | ||
610 | if(this.type == qwebirc.ui.WINDOW_CHANNEL && this.nicksColoured != this.parentObject.uiOptions.NICK_COLOURS) { | |
611 | this.nicksColoured = this.parentObject.uiOptions.NICK_COLOURS; | |
612 | ||
613 | var nodes = this.nicklist.childNodes; | |
614 | if(this.parentObject.uiOptions.NICK_COLOURS) { | |
615 | for(var i=0;i<nodes.length;i++) { | |
616 | var e = nodes[i], span = e.firstChild; | |
617 | var colour = e.realNick.toHSBColour(this.client); | |
618 | if($defined(colour)) | |
619 | span.setStyle("color", colour.rgbToHex()); | |
620 | }; | |
621 | } else { | |
622 | for(var i=0;i<nodes.length;i++) { | |
623 | var span = nodes[i].firstChild; | |
624 | span.setStyle("color", null); | |
625 | }; | |
626 | } | |
627 | } | |
628 | }, | |
629 | deselect: function() { | |
630 | this.parent(); | |
631 | ||
632 | this.tab.removeClass("tab-selected"); | |
633 | this.tab.addClass("tab-unselected"); | |
634 | }, | |
635 | close: function() { | |
636 | this.parent(); | |
637 | ||
638 | this.parentObject.tabs.removeChild(this.tab); | |
639 | this.parentObject.tabs.removeChild(this.spaceNode); | |
640 | this.reflow(); | |
641 | }, | |
642 | addLine: function(type, line, colourClass) { | |
643 | var e = new Element("div"); | |
644 | ||
645 | if(colourClass) { | |
646 | e.addClass(colourClass); | |
647 | } else if(this.lastcolour) { | |
648 | e.addClass("linestyle1"); | |
649 | } else { | |
650 | e.addClass("linestyle2"); | |
651 | } | |
652 | this.lastcolour = !this.lastcolour; | |
653 | ||
654 | this.parent(type, line, colourClass, e); | |
655 | }, | |
656 | setHilighted: function(state) { | |
657 | var laststate = this.hilighted; | |
658 | ||
659 | this.parent(state); | |
660 | ||
661 | if(state == laststate) | |
662 | return; | |
663 | ||
664 | this.tab.removeClass("tab-hilight-activity"); | |
665 | this.tab.removeClass("tab-hilight-us"); | |
666 | this.tab.removeClass("tab-hilight-speech"); | |
667 | ||
668 | switch(this.hilighted) { | |
669 | case qwebirc.ui.HILIGHT_US: | |
670 | this.tab.addClass("tab-hilight-us"); | |
671 | break; | |
672 | case qwebirc.ui.HILIGHT_SPEECH: | |
673 | this.tab.addClass("tab-hilight-speech"); | |
674 | break; | |
675 | case qwebirc.ui.HILIGHT_ACTIVITY: | |
676 | this.tab.addClass("tab-hilight-activity"); | |
677 | break; | |
678 | } | |
679 | } | |
680 | }); |