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