]>
Commit | Line | Data |
---|---|---|
1 | var QUIWindow = new Class({ | |
2 | Extends: UIWindow, | |
3 | ||
4 | initialize: function(parentObject, client, type, name) { | |
5 | this.parent(parentObject, client, type, name); | |
6 | ||
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 | } | |
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"); | |
47 | ||
48 | formdiv.addClass("input"); | |
49 | ||
50 | form.addEvent("submit", function(e) { | |
51 | new Event(e).stop(); | |
52 | ||
53 | this.historyExec(inputbox.value); | |
54 | inputbox.value = ""; | |
55 | }.bind(this)); | |
56 | formdiv.appendChild(form); | |
57 | form.appendChild(inputbox); | |
58 | ||
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)); | |
75 | ||
76 | var toppos = 0; | |
77 | var rightpos = 0; | |
78 | var bottompos = formdiv.getSize().y; | |
79 | ||
80 | if(type == WINDOW_CHANNEL) { | |
81 | this.nicklist = new Element("div"); | |
82 | this.nicklist.addClass("nicklist"); | |
83 | this.nicklist.setStyle("bottom", (bottompos - 1) + "px"); | |
84 | ||
85 | this.window.appendChild(this.nicklist); | |
86 | rightpos = this.nicklist.getSize().x; | |
87 | ||
88 | this.topic = new Element("div"); | |
89 | this.topic.addClass("topic"); | |
90 | this.topic.set("html", " "); | |
91 | this.topic.setStyle("right", rightpos + "px"); | |
92 | this.window.appendChild(this.topic); | |
93 | ||
94 | toppos = this.topic.getSize().y; | |
95 | } | |
96 | ||
97 | this.lines.setStyle("top", toppos + "px"); | |
98 | this.lines.setStyle("bottom", bottompos + "px"); | |
99 | this.lines.setStyle("right", rightpos + "px"); | |
100 | this.lines.addClass("lines"); | |
101 | }, | |
102 | updateNickList: function(nicks) { | |
103 | this.parent(nicks); | |
104 | ||
105 | var n = this.nicklist; | |
106 | while(n.firstChild) | |
107 | n.removeChild(n.firstChild); | |
108 | ||
109 | nicks.each(function(nick) { | |
110 | var e = new Element("div"); | |
111 | n.appendChild(e); | |
112 | e.appendChild(document.createTextNode(nick)); | |
113 | }); | |
114 | }, | |
115 | updateTopic: function(topic) { | |
116 | this.parent(topic); | |
117 | ||
118 | var t = this.topic; | |
119 | ||
120 | while(t.firstChild) | |
121 | t.removeChild(t.firstChild); | |
122 | ||
123 | Colourise(topic, t); | |
124 | }, | |
125 | select: function() { | |
126 | this.parent(); | |
127 | ||
128 | this.window.removeClass("tab-invisible"); | |
129 | this.tab.removeClass("tab-unselected"); | |
130 | this.tab.addClass("tab-selected"); | |
131 | }, | |
132 | deselect: function() { | |
133 | this.parent(); | |
134 | ||
135 | this.window.addClass("tab-invisible"); | |
136 | this.tab.removeClass("tab-selected"); | |
137 | this.tab.addClass("tab-unselected"); | |
138 | }, | |
139 | close: function() { | |
140 | this.parent(); | |
141 | ||
142 | this.parentObject.container.removeChild(this.window); | |
143 | this.parentObject.tabs.removeChild(this.tab); | |
144 | }, | |
145 | addLine: function(type, line, colour) { | |
146 | var e = new Element("div"); | |
147 | ||
148 | if(colour) { | |
149 | e.setStyles({"background": colour}); | |
150 | } else if(this.lastcolour) { | |
151 | e.addClass("linestyle1"); | |
152 | } else { | |
153 | e.addClass("linestyle2"); | |
154 | } | |
155 | this.lastcolour = !this.lastcolour; | |
156 | ||
157 | this.parent(type, line, colour, e); | |
158 | }, | |
159 | setHilighted: function(state) { | |
160 | this.parent(state); | |
161 | ||
162 | if(state) { | |
163 | this.tab.addClass("tab-highlighted"); | |
164 | } else { | |
165 | this.tab.removeClass("tab-highlighted"); | |
166 | } | |
167 | } | |
168 | }); | |
169 | ||
170 | var QUI = new Class({ | |
171 | Extends: UI, | |
172 | initialize: function(parentElement, theme) { | |
173 | this.parent(parentElement, QUIWindow, "qui"); | |
174 | this.theme = theme; | |
175 | this.parentElement = parentElement; | |
176 | }, | |
177 | reflow: function() { | |
178 | var tabheight = this.tabs.getSize().y; | |
179 | this.container.setStyle("top", tabheight + "px"); | |
180 | }, | |
181 | postInitialize: function() { | |
182 | this.outerContainer = new Element("div"); | |
183 | this.outerContainer.addClass("outercontainer"); | |
184 | this.parentElement.appendChild(this.outerContainer); | |
185 | ||
186 | this.tabs = new Element("div"); | |
187 | this.tabs.addClass("tabbar"); | |
188 | this.outerContainer.appendChild(this.tabs); | |
189 | ||
190 | var tester = new Element("span"); | |
191 | this.tabs.appendChild(tester); | |
192 | ||
193 | this.tabheight = this.tabs.getSize().y; | |
194 | this.tabs.removeChild(tester); | |
195 | ||
196 | this.container = new Element("div"); | |
197 | this.container.addClass("container"); | |
198 | this.outerContainer.appendChild(this.container); | |
199 | }, | |
200 | loginBox: function(callbackfn, intialNickname, initialChannels) { | |
201 | this.parent(function(options) { | |
202 | this.postInitialize(); | |
203 | callbackfn(options); | |
204 | }.bind(this), intialNickname, initialChannels); | |
205 | } | |
206 | }); |