]>
Commit | Line | Data |
---|---|---|
f4ae92cc CP |
1 | var QUIWindow = new Class({ |
2 | Extends: UIWindow, | |
3 | ||
4 | initialize: function(parentObject, client, type, name) { | |
5 | this.parent(parentObject, client, type, name); | |
be0bd774 | 6 | |
66de775f | 7 | this.tab = new Element("a", {"href": "#"}); |
f4ae92cc CP |
8 | this.tab.addClass("tab"); |
9 | ||
10 | this.tab.appendText(name); | |
66de775f CP |
11 | this.tab.addEvent("click", function(e) { |
12 | new Event(e).stop(); | |
f4ae92cc CP |
13 | parentObject.selectWindow(this); |
14 | }.bind(this)); | |
15 | ||
16 | parentObject.tabs.appendChild(this.tab); | |
17 | ||
18 | if(type != WINDOW_STATUS) { | |
19 | tabclose = new Element("span"); | |
20 | tabclose.addClass("tabclose"); | |
21 | tabclose.addEvent("click", function(e) { | |
22 | new Event(e).stop(); | |
23 | ||
24 | if(type == WINDOW_CHANNEL) | |
25 | this.client.exec("/PART " + name); | |
26 | ||
27 | this.close(); | |
28 | }.bind(this)); | |
29 | tabclose.set("text", "X"); | |
30 | this.tab.appendChild(tabclose); | |
31 | } | |
be0bd774 CP |
32 | |
33 | this.parentObject.reflow(); | |
34 | ||
35 | this.window = new Element("div"); | |
36 | this.window.addClass("window"); | |
37 | parentObject.container.appendChild(this.window); | |
38 | ||
39 | this.lines = new Element("div"); | |
40 | this.lines.addClass("lines"); | |
41 | this.window.appendChild(this.lines); | |
42 | ||
43 | var formdiv = new Element("div"); | |
44 | this.window.appendChild(formdiv); | |
45 | ||
46 | var form = new Element("form"); | |
47 | var inputbox = new Element("input"); | |
9b63b053 | 48 | |
be0bd774 CP |
49 | formdiv.addClass("input"); |
50 | ||
51 | form.addEvent("submit", function(e) { | |
52 | new Event(e).stop(); | |
53 | ||
9b63b053 | 54 | this.historyExec(inputbox.value); |
be0bd774 CP |
55 | inputbox.value = ""; |
56 | }.bind(this)); | |
57 | formdiv.appendChild(form); | |
58 | form.appendChild(inputbox); | |
59 | ||
9b63b053 CP |
60 | inputbox.addEvent("keypress", function(e) { |
61 | var result; | |
62 | if(e.key == "up") { | |
63 | result = this.commandhistory.nextLine(); | |
64 | } else if(e.key == "down") { | |
65 | result = this.commandhistory.prevLine(); | |
66 | } else { | |
67 | return; | |
68 | } | |
69 | ||
70 | new Event(e).stop(); | |
71 | if(!result) | |
72 | result = "" | |
73 | inputbox.value = result; | |
74 | setAtEnd(inputbox); | |
75 | }.bind(this)); | |
25be5960 CP |
76 | this.inputbox = inputbox; |
77 | ||
be0bd774 CP |
78 | var toppos = 0; |
79 | var rightpos = 0; | |
80 | var bottompos = formdiv.getSize().y; | |
81 | ||
82 | if(type == WINDOW_CHANNEL) { | |
be0bd774 CP |
83 | this.topic = new Element("div"); |
84 | this.topic.addClass("topic"); | |
85 | this.topic.set("html", " "); | |
66de775f | 86 | this.topic.setStyle("right", "0px"); |
be0bd774 CP |
87 | this.window.appendChild(this.topic); |
88 | ||
89 | toppos = this.topic.getSize().y; | |
66de775f CP |
90 | |
91 | this.nicklist = new Element("div"); | |
92 | this.nicklist.addClass("nicklist"); | |
93 | this.nicklist.setStyle("top", toppos + "px"); | |
94 | this.nicklist.setStyle("bottom", (bottompos - 1) + "px"); | |
95 | ||
96 | this.window.appendChild(this.nicklist); | |
97 | rightpos = this.nicklist.getSize().x; | |
be0bd774 CP |
98 | } |
99 | ||
100 | this.lines.setStyle("top", toppos + "px"); | |
101 | this.lines.setStyle("bottom", bottompos + "px"); | |
102 | this.lines.setStyle("right", rightpos + "px"); | |
103 | this.lines.addClass("lines"); | |
25be5960 CP |
104 | |
105 | this.lines.addEvent("scroll", function() { | |
106 | this.scrolleddown = this.scrolledDown(); | |
107 | }.bind(this)); | |
108 | ||
109 | window.addEvent("resize", function() { | |
110 | if(this.scrolleddown) | |
111 | this.scrollToBottom(); | |
112 | }.bind(this)); | |
f4ae92cc CP |
113 | }, |
114 | updateNickList: function(nicks) { | |
115 | this.parent(nicks); | |
116 | ||
117 | var n = this.nicklist; | |
118 | while(n.firstChild) | |
119 | n.removeChild(n.firstChild); | |
120 | ||
121 | nicks.each(function(nick) { | |
122 | var e = new Element("div"); | |
123 | n.appendChild(e); | |
124 | e.appendChild(document.createTextNode(nick)); | |
125 | }); | |
126 | }, | |
127 | updateTopic: function(topic) { | |
128 | this.parent(topic); | |
129 | ||
130 | var t = this.topic; | |
131 | ||
132 | while(t.firstChild) | |
133 | t.removeChild(t.firstChild); | |
134 | ||
66de775f CP |
135 | if(topic) { |
136 | Colourise(topic, "[" + topic + "]"); | |
137 | } else { | |
138 | var e = new Element("(no topic set)"); | |
139 | e.addClass("emptytopic"); | |
140 | topic.appendChild(e); | |
141 | } | |
f4ae92cc CP |
142 | }, |
143 | select: function() { | |
be0bd774 | 144 | this.window.removeClass("tab-invisible"); |
f4ae92cc | 145 | this.tab.removeClass("tab-unselected"); |
f4ae92cc | 146 | this.tab.addClass("tab-selected"); |
7c633700 | 147 | this.parent(); |
25be5960 CP |
148 | |
149 | this.inputbox.focus(); | |
f4ae92cc CP |
150 | }, |
151 | deselect: function() { | |
152 | this.parent(); | |
153 | ||
be0bd774 | 154 | this.window.addClass("tab-invisible"); |
f4ae92cc CP |
155 | this.tab.removeClass("tab-selected"); |
156 | this.tab.addClass("tab-unselected"); | |
157 | }, | |
158 | close: function() { | |
159 | this.parent(); | |
160 | ||
be0bd774 | 161 | this.parentObject.container.removeChild(this.window); |
f4ae92cc CP |
162 | this.parentObject.tabs.removeChild(this.tab); |
163 | }, | |
164 | addLine: function(type, line, colour) { | |
f4ae92cc CP |
165 | var e = new Element("div"); |
166 | ||
167 | if(colour) { | |
168 | e.setStyles({"background": colour}); | |
169 | } else if(this.lastcolour) { | |
170 | e.addClass("linestyle1"); | |
171 | } else { | |
172 | e.addClass("linestyle2"); | |
173 | } | |
f4ae92cc | 174 | this.lastcolour = !this.lastcolour; |
be0bd774 CP |
175 | |
176 | this.parent(type, line, colour, e); | |
177 | }, | |
178 | setHilighted: function(state) { | |
179 | this.parent(state); | |
f4ae92cc | 180 | |
be0bd774 | 181 | if(state) { |
7c633700 | 182 | this.tab.addClass("tab-hilighted"); |
be0bd774 | 183 | } else { |
7c633700 | 184 | this.tab.removeClass("tab-hilighted"); |
be0bd774 | 185 | } |
f4ae92cc CP |
186 | } |
187 | }); | |
188 | ||
189 | var QUI = new Class({ | |
190 | Extends: UI, | |
191 | initialize: function(parentElement, theme) { | |
ba47bd8b | 192 | this.parent(parentElement, QUIWindow, "qui"); |
f4ae92cc CP |
193 | this.theme = theme; |
194 | this.parentElement = parentElement; | |
195 | }, | |
be0bd774 CP |
196 | reflow: function() { |
197 | var tabheight = this.tabs.getSize().y; | |
198 | this.container.setStyle("top", tabheight + "px"); | |
199 | }, | |
200 | postInitialize: function() { | |
201 | this.outerContainer = new Element("div"); | |
202 | this.outerContainer.addClass("outercontainer"); | |
203 | this.parentElement.appendChild(this.outerContainer); | |
204 | ||
f4ae92cc CP |
205 | this.tabs = new Element("div"); |
206 | this.tabs.addClass("tabbar"); | |
be0bd774 | 207 | this.outerContainer.appendChild(this.tabs); |
f4ae92cc | 208 | |
be0bd774 CP |
209 | var tester = new Element("span"); |
210 | this.tabs.appendChild(tester); | |
f4ae92cc | 211 | |
be0bd774 CP |
212 | this.tabheight = this.tabs.getSize().y; |
213 | this.tabs.removeChild(tester); | |
214 | ||
f4ae92cc CP |
215 | this.container = new Element("div"); |
216 | this.container.addClass("container"); | |
be0bd774 | 217 | this.outerContainer.appendChild(this.container); |
f4ae92cc | 218 | }, |
66de775f | 219 | loginBox: function(callbackfn, intialNickname, initialChannels, autoConnect, autoNick) { |
f4ae92cc CP |
220 | this.parent(function(options) { |
221 | this.postInitialize(); | |
222 | callbackfn(options); | |
66de775f | 223 | }.bind(this), intialNickname, initialChannels, autoConnect, autoNick); |
f4ae92cc CP |
224 | } |
225 | }); |