]>
Commit | Line | Data |
---|---|---|
1 | qwebirc.ui.MochaUI = new Class({ | |
2 | Extends: qwebirc.ui.RootUI, | |
3 | initialize: function(parentElement, theme, options) { | |
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, | |
59 | ||
60 | initialize: function(parentObject, client, type, name, identifier) { | |
61 | this.parent(parentObject, client, type, name, identifier); | |
62 | ||
63 | this.lines = new Element("div", {styles: {overflow: "auto", "width": "90"}}); | |
64 | ||
65 | var toolbar = (type != qwebirc.ui.WINDOW_CUSTOM) && (type != qwebirc.ui.WINDOW_CONNECT); | |
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 | } | |
90 | ||
91 | var prefs = { | |
92 | width: 800, | |
93 | height: 400, | |
94 | title: name, | |
95 | footerHeight: 0, | |
96 | container: $("pageWrapper"), | |
97 | toolbarHeight: parentObject.inputHeight, | |
98 | toolbarPosition: "bottom", | |
99 | toolbarContent: "", | |
100 | //toolbarURL: "", | |
101 | toolbarLoadMethod: "html", | |
102 | content: this.lines, | |
103 | minimized: true, | |
104 | addClass: "hidenewwin", | |
105 | onFocus: function() { | |
106 | parentObject.selectWindow(this); | |
107 | }.bind(this), | |
108 | onClose: function() { | |
109 | if(type == qwebirc.ui.WINDOW_CHANNEL) | |
110 | this.client.exec("/PART " + name); | |
111 | this.close(); | |
112 | }.bind(this) | |
113 | }; | |
114 | ||
115 | prefs.toolbar = toolbar; | |
116 | prefs.closable = type != qwebirc.ui.WINDOW_STATUS && type != qwebirc.ui.WINDOW_CONNECT; | |
117 | ||
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 | */ | |
128 | var nw = new MochaUI.Window(prefs); | |
129 | this.window = nw; | |
130 | ||
131 | /*if(!focus) { | |
132 | MochaUI.Windows.indexLevel = oldIndexLevel; | |
133 | MochaUI.focusWindow = oldfocus; | |
134 | }*/ | |
135 | ||
136 | /* HACK */ | |
137 | if(toolbar) { | |
138 | var toolbar = $(nw.options.id + "_toolbar"); | |
139 | toolbar.appendChild(this.form); | |
140 | } | |
141 | this.titleText = $(nw.options.id + "_title"); | |
142 | this.tabText = $(nw.options.id + "_dockTabText"); | |
143 | ||
144 | /*alert(toolbar.parentNode.getStyle("background"));*/ | |
145 | /*this.inputbox.setStyle("background", toolbar.parentNode.getStyle("background"));*/ | |
146 | this.windowObject = nw; | |
147 | ||
148 | this.scroller = this.lines.parentNode.parentNode; | |
149 | ||
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 | ||
192 | qwebirc.ui.Colourise(topic, t); | |
193 | }, | |
194 | addLine: function(type, line, colour) { | |
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 | } | |
204 | this.lastcolour = !this.lastcolour; | |
205 | ||
206 | this.parent(type, line, colour, e, this.lines); | |
207 | }, | |
208 | select: function() { | |
209 | this.parent(); | |
210 | ||
211 | if(this.inputbox) | |
212 | this.inputbox.focus(); | |
213 | }, | |
214 | setHilighted: function(state) { | |
215 | this.parent(state); | |
216 | ||
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); | |
225 | } | |
226 | }, | |
227 | close: function() { | |
228 | this.parent(); | |
229 | ||
230 | MochaUI.closeWindow(this.window.windowEl); | |
231 | }, | |
232 | }); |