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