]>
Commit | Line | Data |
---|---|---|
e20e5a6b | 1 | qwebirc.ui.MochaUI = new Class({ |
144ee52f | 2 | Extends: qwebirc.ui.RootUI, |
2cad083e | 3 | initialize: function(parentElement, theme, options) { |
e20e5a6b CP |
4 | this.parent(parentElement, qwebirc.ui.MochaUI.Window, "mochaui"); |
5 | this.theme = theme; | |
6 | this.parentElement = parentElement; | |
7 | ||
8 | window.addEvent("domready", function() { | |
9 | /* determine input size */ | |
10 | var l = new Element("input", {styles: {border: 0}}); | |
11 | this.parentElement.appendChild(l); | |
12 | this.inputHeight = l.getSize().y; | |
13 | this.parentElement.removeChild(l); | |
14 | ||
15 | MochaUI.Desktop = new MochaUI.Desktop(); | |
16 | MochaUI.Dock = new MochaUI.Dock({ | |
17 | dockPosition: "top" | |
18 | }); | |
19 | ||
20 | MochaUI.Modal = new MochaUI.Modal(); | |
21 | MochaUI.options.useEffects = false; | |
22 | }.bind(this)); | |
23 | ||
24 | window.addEvent("unload", function() { | |
25 | if(MochaUI) | |
26 | MochaUI.garbageCleanUp(); | |
27 | }); | |
28 | }, | |
29 | postInitialize: function() { | |
30 | return; | |
31 | this.tabs = new Element("div"); | |
32 | this.tabs.addClass("tabbar"); | |
33 | ||
34 | this.parentElement.appendChild(this.tabs); | |
35 | ||
36 | this.container = new Element("div"); | |
37 | this.container.addClass("container"); | |
38 | ||
39 | this.parentElement.appendChild(this.container); | |
40 | ||
41 | var form = new Element("form"); | |
42 | var inputbox = new Element("input"); | |
43 | inputbox.addClass("input"); | |
44 | ||
45 | form.addEvent("submit", function(e) { | |
46 | new Event(e).stop(); | |
47 | ||
48 | this.getActiveWindow().client.exec(inputbox.value); | |
49 | inputbox.value = ""; | |
50 | }.bind(this)); | |
51 | this.parentElement.appendChild(form); | |
52 | form.appendChild(inputbox); | |
53 | inputbox.focus(); | |
54 | } | |
55 | }); | |
56 | ||
57 | qwebirc.ui.MochaUI.Window = new Class({ | |
58 | Extends: qwebirc.ui.Window, | |
cfd8616d | 59 | |
f74802c5 CP |
60 | initialize: function(parentObject, client, type, name, identifier) { |
61 | this.parent(parentObject, client, type, name, identifier); | |
cfd8616d CP |
62 | |
63 | this.lines = new Element("div", {styles: {overflow: "auto", "width": "90"}}); | |
64 | ||
e20e5a6b | 65 | var toolbar = (type != qwebirc.ui.WINDOW_CUSTOM) && (type != qwebirc.ui.WINDOW_CONNECT); |
6f2e4a37 CP |
66 | |
67 | if(toolbar) { | |
68 | this.form = new Element("form"); | |
69 | this.inputbox = new Element("input", {styles: {border: 0, width: "100%"}}); | |
70 | this.inputbox.addClass("input"); | |
71 | ||
72 | this.inputbox.addEvent("focus", function() { | |
73 | /* TODO: bring to top */ | |
74 | //alert(":O"); | |
75 | //alert(this.windowObject.windowEl); | |
76 | //MochaUI.focusWindow.pass(this.windowObject.windowEl, this.windowObject); | |
77 | //this.windowObject.focusWindow(); | |
78 | this.parentObject.selectWindow(this); | |
79 | }.bind(this)); | |
80 | ||
81 | this.form.addEvent("submit", function(e) { | |
82 | new Event(e).stop(); | |
83 | ||
84 | this.client.exec(this.inputbox.value); | |
85 | this.inputbox.value = ""; | |
86 | }.bind(this)); | |
87 | //this.container.appendChild(form); | |
88 | this.form.appendChild(this.inputbox); | |
89 | } | |
cfd8616d CP |
90 | |
91 | var prefs = { | |
a59dc700 | 92 | width: 800, |
cfd8616d CP |
93 | height: 400, |
94 | title: name, | |
95 | footerHeight: 0, | |
cfd8616d CP |
96 | container: $("pageWrapper"), |
97 | toolbarHeight: parentObject.inputHeight, | |
98 | toolbarPosition: "bottom", | |
99 | toolbarContent: "", | |
a59dc700 CP |
100 | //toolbarURL: "", |
101 | toolbarLoadMethod: "html", | |
cfd8616d | 102 | content: this.lines, |
6db9427a CP |
103 | minimized: true, |
104 | addClass: "hidenewwin", | |
cfd8616d CP |
105 | onFocus: function() { |
106 | parentObject.selectWindow(this); | |
107 | }.bind(this), | |
108 | onClose: function() { | |
e20e5a6b | 109 | if(type == qwebirc.ui.WINDOW_CHANNEL) |
cfd8616d | 110 | this.client.exec("/PART " + name); |
cfd8616d CP |
111 | this.close(); |
112 | }.bind(this) | |
113 | }; | |
114 | ||
6f2e4a37 | 115 | prefs.toolbar = toolbar; |
e20e5a6b | 116 | prefs.closable = type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT; |
cfd8616d | 117 | |
6db9427a CP |
118 | /* HACK */ |
119 | /* var oldIndexLevel = MochaUI.Windows.indexLevel; | |
120 | ||
121 | var focus = false; | |
122 | var oldfocus = MochaUI.focusWindow; | |
123 | if(!focus) { | |
124 | MochaUI.Windows.indexLevel = 0; | |
125 | MochaUI.focusWindow = null; | |
126 | } | |
127 | */ | |
cfd8616d | 128 | var nw = new MochaUI.Window(prefs); |
6f2e4a37 | 129 | this.window = nw; |
6db9427a CP |
130 | |
131 | /*if(!focus) { | |
132 | MochaUI.Windows.indexLevel = oldIndexLevel; | |
133 | MochaUI.focusWindow = oldfocus; | |
134 | }*/ | |
135 | ||
cfd8616d | 136 | /* HACK */ |
6f2e4a37 CP |
137 | if(toolbar) { |
138 | var toolbar = $(nw.options.id + "_toolbar"); | |
139 | toolbar.appendChild(this.form); | |
140 | } | |
6db9427a CP |
141 | this.titleText = $(nw.options.id + "_title"); |
142 | this.tabText = $(nw.options.id + "_dockTabText"); | |
143 | ||
a59dc700 CP |
144 | /*alert(toolbar.parentNode.getStyle("background"));*/ |
145 | /*this.inputbox.setStyle("background", toolbar.parentNode.getStyle("background"));*/ | |
a59dc700 | 146 | this.windowObject = nw; |
cfd8616d | 147 | |
381fddfd CP |
148 | this.scroller = this.lines.parentNode.parentNode; |
149 | ||
cfd8616d CP |
150 | return; |
151 | /* | |
152 | if(type == WINDOW_CHANNEL) { | |
153 | this.nicklist = new Element("div"); | |
154 | this.nicklist.addClass("nicklist"); | |
155 | ||
156 | this.outerContainer.appendChild(this.nicklist); | |
157 | } | |
158 | ||
159 | var innerContainer = new Element("div"); | |
160 | innerContainer.addClass("innercontainer"); | |
161 | this.outerContainer.appendChild(innerContainer); | |
162 | ||
163 | if(type == WINDOW_CHANNEL) { | |
164 | this.topic = new Element("div"); | |
165 | this.topic.addClass("topic"); | |
166 | innerContainer.appendChild(this.topic); | |
167 | } | |
168 | */ | |
169 | }, | |
170 | updateNickList: function(nicks) { | |
171 | this.parent(nicks); | |
172 | ||
173 | return; | |
174 | var n = this.nicklist; | |
175 | while(n.firstChild) | |
176 | n.removeChild(n.firstChild); | |
177 | ||
178 | nicks.each(function(nick) { | |
179 | var e = new Element("div"); | |
180 | n.appendChild(e); | |
181 | e.appendChild(document.createTextNode(nick)); | |
182 | }); | |
183 | }, | |
184 | updateTopic: function(topic) { | |
185 | this.parent(topic); | |
186 | return; | |
187 | var t = this.topic; | |
188 | ||
189 | while(t.firstChild) | |
190 | t.removeChild(t.firstChild); | |
191 | ||
cad18909 | 192 | qwebirc.ui.Colourise(topic, t); |
cfd8616d CP |
193 | }, |
194 | addLine: function(type, line, colour) { | |
cfd8616d CP |
195 | var e = new Element("div"); |
196 | ||
197 | if(colour) { | |
198 | e.setStyles({"background": colour}); | |
199 | } else if(this.lastcolour) { | |
200 | e.addClass("linestyle1"); | |
201 | } else { | |
202 | e.addClass("linestyle2"); | |
203 | } | |
cfd8616d | 204 | this.lastcolour = !this.lastcolour; |
a59dc700 | 205 | |
381fddfd CP |
206 | this.parent(type, line, colour, e, this.lines); |
207 | }, | |
208 | select: function() { | |
209 | this.parent(); | |
6db9427a | 210 | |
6f2e4a37 CP |
211 | if(this.inputbox) |
212 | this.inputbox.focus(); | |
6db9427a | 213 | }, |
381fddfd CP |
214 | setHilighted: function(state) { |
215 | this.parent(state); | |
216 | ||
6db9427a CP |
217 | if(state) { |
218 | this.titleText.setStyle("color", "#ff0000"); | |
219 | this.tabText.setStyle("background-color", "#ff0000"); | |
220 | this.tabText.setStyle("color", "#000000"); | |
221 | } else { | |
222 | this.titleText.setStyle("color", null); | |
223 | this.tabText.setStyle("background-color", null); | |
224 | this.tabText.setStyle("color", null); | |
381fddfd | 225 | } |
6f2e4a37 CP |
226 | }, |
227 | close: function() { | |
228 | this.parent(); | |
229 | ||
230 | MochaUI.closeWindow(this.window.windowEl); | |
231 | }, | |
cfd8616d | 232 | }); |