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