bzr branch
http://darksoft.org/webbzr/adei/trunk
1
by Suren A. Chilingaryan
Initial import |
1 |
function POPUP(cb, cbattr) { |
2 |
this.popup_states = new Array(); |
|
3 |
this.popup_callback = new Array(); |
|
4 |
this.popup_rewidth_callback = new Array(); |
|
200
by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196 |
5 |
this.popup_reheight_callback = new Array(); |
1
by Suren A. Chilingaryan
Initial import |
6 |
this.popup_on_callbacks = new Array(); |
7 |
this.popup_off_callbacks = new Array(); |
|
8 |
this.current_height = new Array(); |
|
9 |
this.popups = new Array(); |
|
80
by Suren A. Chilingaryan
Few steps on source tree integration in javascript frontend |
10 |
this.modules = new Array(); |
11 |
this.controls = new Array(); |
|
1
by Suren A. Chilingaryan
Initial import |
12 |
this.popups_width = 300; |
13 |
this.num_opened = 0; |
|
12
by Suren A. Chilingaryan
Layout redesign: search tab, controls, menu |
14 |
|
15 |
this.super_popup = false; |
|
16 |
||
17 |
this.resizable = null; |
|
1
by Suren A. Chilingaryan
Initial import |
18 |
|
19 |
if (typeof cb != "undefined") this.RegisterCallback(cb,cbattr); |
|
20 |
}
|
|
21 |
||
80
by Suren A. Chilingaryan
Few steps on source tree integration in javascript frontend |
22 |
POPUP.prototype.RegisterPopup = function(module) { |
23 |
this.popups.push(module); |
|
24 |
this.controls[module] = new Array(); |
|
25 |
this.popup_states[module] = 0; |
|
26 |
}
|
|
27 |
||
28 |
POPUP.prototype.RegisterControlsModule = function(module, cmod) { |
|
29 |
if (typeof this.controls[module] == "undefined") { |
|
30 |
this.RegisterPopup(module); |
|
31 |
}
|
|
32 |
||
33 |
this.modules[module] = cmod; |
|
34 |
}
|
|
35 |
||
36 |
POPUP.prototype.RegisterControl = function(module, control) { |
|
37 |
if (typeof this.controls[module] == "undefined") { |
|
38 |
this.RegisterPopup(module); |
|
39 |
}
|
|
40 |
||
41 |
this.controls[module].push(control); |
|
42 |
}
|
|
43 |
||
44 |
POPUP.prototype.FindControl = function(control) { |
|
45 |
for (var i = 0; i < this.popups.length; i++) { |
|
46 |
var popup = this.popups[i]; |
|
47 |
if (typeof this.controls[popup] != "undefind") { |
|
48 |
for (var j = 0; j < this.controls[popup].length; j++) { |
|
49 |
if (this.controls[popup][j] == control) { |
|
50 |
return popup; |
|
51 |
}
|
|
52 |
}
|
|
53 |
}
|
|
54 |
}
|
|
55 |
return false; |
|
56 |
}
|
|
57 |
||
58 |
POPUP.prototype.OpenControl = function(control) { |
|
59 |
var popup = this.FindControl(control); |
|
60 |
var module = this.modules[popup]; |
|
61 |
||
62 |
if ((popup)&&(module)) { |
|
63 |
this.Open(popup); |
|
64 |
module.Open(control); |
|
65 |
}
|
|
66 |
}
|
|
67 |
||
12
by Suren A. Chilingaryan
Layout redesign: search tab, controls, menu |
68 |
|
69 |
POPUP.prototype.TryFixedSizeMode = function(sidebar, popup, geometry_node) { |
|
70 |
this.super_popup = false; |
|
71 |
||
72 |
var node = domGetLastChildByName(sidebar, "div"); |
|
73 |
if (!node) return; |
|
74 |
||
75 |
if (!domGetFirstChildByName(node, "table")) { |
|
76 |
node = domGetLastChildByName(node, "div"); |
|
77 |
if (!node) return; |
|
78 |
||
79 |
var subnodes = node.getElementsByTagName("table"); |
|
80 |
if ((!subnodes)||(!subnodes.length)) |
|
81 |
alert("problem detecting popups structure"); |
|
82 |
}
|
|
83 |
this.super_node = node; |
|
84 |
||
85 |
var switch_node = document.getElementById("popup_switch_" + popup); |
|
86 |
nodes = switch_node.getElementsByTagName("button"); |
|
87 |
if ((!nodes)||(!nodes.length)) { |
|
88 |
alert("problem detecting popups structure"); |
|
89 |
return; |
|
90 |
}
|
|
91 |
||
92 |
this.geometry_nodes = new Array(); |
|
93 |
||
94 |
if (geometry_node) { |
|
95 |
node = document.getElementById(geometry_node); |
|
96 |
if (!node) { |
|
97 |
alert("Invalid geometry_node is supplied"); |
|
98 |
return; |
|
99 |
}
|
|
100 |
this.geometry_nodes.push(node); |
|
101 |
}
|
|
102 |
||
103 |
this.super_button = nodes[0]; |
|
104 |
this.super_popup = popup; |
|
105 |
}
|
|
106 |
||
107 |
||
1
by Suren A. Chilingaryan
Initial import |
108 |
POPUP.prototype.RegisterOnCallback = function (module, cb, cbattr, call_once) { |
109 |
if (typeof this.popup_on_callbacks[module] == "undefined") |
|
110 |
this.popup_on_callbacks[module] = new Array(); |
|
111 |
||
112 |
if (typeof call_once == "undefined") call_once = false; |
|
113 |
||
114 |
this.popup_on_callbacks[module].push({ 'cb': cb, 'cbattr': cbattr, 'once': call_once }); |
|
115 |
}
|
|
116 |
||
117 |
POPUP.prototype.RegisterOffCallback = function(module, cb, cbattr) { |
|
118 |
if (typeof this.popup_off_callbacks[module] == "undefined") |
|
119 |
this.popup_off_callbacks[module] = new Array(); |
|
120 |
||
121 |
this.popup_off_callbacks[module].push({ 'cb': cb, 'cbattr': cbattr }); |
|
122 |
}
|
|
123 |
||
124 |
POPUP.prototype.RegisterCallback = function(cb, cbattr) { |
|
125 |
this.popup_callback.push ({ 'cb': cb, 'cbattr': cbattr }); |
|
126 |
}
|
|
127 |
||
128 |
POPUP.prototype.RegisterReWidthCallback = function(cb, cbattr) { |
|
129 |
this.popup_rewidth_callback.push ({ 'cb': cb, 'cbattr': cbattr }); |
|
130 |
}
|
|
131 |
||
200
by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196 |
132 |
POPUP.prototype.RegisterReHeightCallback = function(cb, cbattr) { |
133 |
this.popup_reheight_callback.push ({ 'cb': cb, 'cbattr': cbattr }); |
|
134 |
}
|
|
135 |
||
1
by Suren A. Chilingaryan
Initial import |
136 |
POPUP.prototype.GetEncompasingNode = function(node) { |
137 |
// return node.parentNode.parentNode.parentNode.parentNode.parentNode;
|
|
138 |
return node.parentNode.parentNode.parentNode.parentNode; |
|
139 |
}
|
|
140 |
||
141 |
POPUP.prototype.RunReWidthCallbacksFunction = function(self) { |
|
142 |
return function() { |
|
143 |
for (var i = 0; i < self.popup_rewidth_callback.length; i++) { |
|
144 |
var cb = self.popup_rewidth_callback[i]; |
|
145 |
cb.cb(cb.cbattr); |
|
146 |
}
|
|
147 |
}
|
|
148 |
}
|
|
149 |
||
200
by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196 |
150 |
POPUP.prototype.RunReHeightCallbacksFunction = function(self) { |
151 |
return function() { |
|
152 |
for (var i = 0; i < self.popup_reheight_callback.length; i++) { |
|
153 |
var cb = self.popup_reheight_callback[i]; |
|
154 |
cb.cb(cb.cbattr); |
|
155 |
}
|
|
156 |
}
|
|
157 |
}
|
|
158 |
||
1
by Suren A. Chilingaryan
Initial import |
159 |
POPUP.prototype.RunReWidthCallbacks = function() { |
160 |
setTimeout(this.RunReWidthCallbacksFunction(this), adei.cfg.parse_delay); |
|
161 |
}
|
|
162 |
||
200
by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196 |
163 |
POPUP.prototype.RunReHeightCallbacks = function() { |
164 |
setTimeout(this.RunReHeightCallbacksFunction(this), adei.cfg.parse_delay); |
|
165 |
}
|
|
166 |
||
1
by Suren A. Chilingaryan
Initial import |
167 |
|
168 |
POPUP.prototype.UpdateGeometry = function(module) { |
|
12
by Suren A. Chilingaryan
Layout redesign: search tab, controls, menu |
169 |
this.UpdateGlobalGeometry(); |
170 |
||
1
by Suren A. Chilingaryan
Initial import |
171 |
with (this) { |
172 |
var node = document.getElementById("popup_" + module); |
|
173 |
var switch_node = document.getElementById("popup_switch_" + module); |
|
174 |
||
175 |
/* Table fills not all available space, we can't fix it by width
|
|
176 |
attribute in HTML since it will prevent hiding. So, fixing here */
|
|
177 |
var tbl_node = this.GetEncompasingNode(node); |
|
178 |
||
179 |
if (node) { |
|
180 |
var cur_width_value = tbl_node.offsetWidth; |
|
181 |
||
182 |
if (cur_width_value > this.popups_width) { |
|
183 |
this.popups_width = cur_width_value; |
|
184 |
||
185 |
// for (var popup in this.popup_states) {
|
|
186 |
for (var i = 0; i < this.popups.length; i++) { |
|
187 |
var popup = this.popups[i]; |
|
188 |
if (this.popup_states[popup]) { |
|
189 |
var popup_node = document.getElementById("popup_" + popup); |
|
190 |
var popup_tbl_node = this.GetEncompasingNode(node); |
|
191 |
if (popup_node) { |
|
192 |
// if (popup_tbl_node.offsetWidth < this.popups_width) {
|
|
193 |
domSetMinWidth(popup_node, this.popups_width, false, popup_tbl_node.parentNode); |
|
194 |
// }
|
|
195 |
}
|
|
196 |
}
|
|
197 |
}
|
|
198 |
||
199 |
if (this.num_opened) { /* otherwise calling in Open */ |
|
200 |
this.RunReWidthCallbacks(); |
|
201 |
}
|
|
202 |
} else if (cur_width_value < this.popups_width) { |
|
203 |
domSetMinWidth(node, this.popups_width, false, tbl_node.parentNode); |
|
204 |
}
|
|
205 |
}
|
|
206 |
||
12
by Suren A. Chilingaryan
Layout redesign: search tab, controls, menu |
207 |
if ((node)&&(switch_node)&&(module!=this.super_popup)) { |
1
by Suren A. Chilingaryan
Initial import |
208 |
var a = switch_node.getElementsByTagName("button")[0]; |
209 |
if (a) { |
|
210 |
var new_height_value = node.parentNode.offsetHeight; // td |
|
211 |
if (!this.current_height[module]) this.current_height[module] = a.offsetHeight; |
|
212 |
||
213 |
if (this.current_height[module] < new_height_value) { |
|
214 |
this.current_height[module] = new_height_value; |
|
215 |
domSetMinHeight(a, new_height_value, false, a.parentNode); //td checking |
|
200
by Suren A. Chilingaryan
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196 |
216 |
this.RunReHeightCallbacks(); |
1
by Suren A. Chilingaryan
Initial import |
217 |
}
|
218 |
}
|
|
219 |
}
|
|
12
by Suren A. Chilingaryan
Layout redesign: search tab, controls, menu |
220 |
|
1
by Suren A. Chilingaryan
Initial import |
221 |
}
|
222 |
}
|
|
223 |
||
80
by Suren A. Chilingaryan
Few steps on source tree integration in javascript frontend |
224 |
POPUP.prototype.Open = function (module) { |
225 |
if (!this.popup_states[module]) { |
|
226 |
this.Switch(module); |
|
227 |
}
|
|
228 |
}
|
|
229 |
||
230 |
POPUP.prototype.Close = function (module) { |
|
231 |
if (this.popup_states[module]) { |
|
232 |
this.Switch(module); |
|
233 |
}
|
|
234 |
}
|
|
1
by Suren A. Chilingaryan
Initial import |
235 |
|
236 |
POPUP.prototype.Switch = function (module) { |
|
237 |
with (this) { |
|
238 |
if (typeof this.popup_states[module] == "undefined") { |
|
80
by Suren A. Chilingaryan
Few steps on source tree integration in javascript frontend |
239 |
this.RegisterPopup(module); |
240 |
}
|
|
241 |
||
242 |
if (this.popup_states[module]) { |
|
105
by Suren A. Chilingaryan
Konqueror support |
243 |
if (client.isKonqueror()) { |
244 |
// domHide is not working properly in Konqueror
|
|
245 |
var node = document.getElementById("popup_" + module); |
|
246 |
if (node) { |
|
247 |
var tdnode = node.parentNode; |
|
248 |
// node.style.witdth = "0px";
|
|
249 |
tdnode.style.width = "0px"; |
|
250 |
// tdnode.style.display = "none";
|
|
251 |
}
|
|
252 |
}
|
|
253 |
||
80
by Suren A. Chilingaryan
Few steps on source tree integration in javascript frontend |
254 |
domHide("popup_" + module); |
105
by Suren A. Chilingaryan
Konqueror support |
255 |
|
1
by Suren A. Chilingaryan
Initial import |
256 |
this.popup_states[module] = 0; |
257 |
||
258 |
if (typeof this.popup_off_callbacks[module] != "undefined") { |
|
259 |
for (var i = 0; i < this.popup_off_callbacks[module].length; i++) { |
|
260 |
var cb = this.popup_off_callbacks[module][i]; |
|
261 |
cb.cb(cb.cbattr, false); |
|
262 |
}
|
|
263 |
}
|
|
264 |
||
265 |
this.num_opened--; |
|
266 |
||
267 |
if (!this.num_opened) this.RunReWidthCallbacks(); |
|
268 |
} else { |
|
269 |
domShow("popup_" + module); |
|
105
by Suren A. Chilingaryan
Konqueror support |
270 |
|
271 |
if (client.isKonqueror()) { |
|
272 |
// domHide is not working properly in Konqueror
|
|
273 |
var node = document.getElementById("popup_" + module); |
|
274 |
if (node) { |
|
275 |
var tdnode = node.parentNode; |
|
276 |
tdnode.style.width = "1px"; |
|
277 |
}
|
|
278 |
}
|
|
279 |
||
280 |
||
1
by Suren A. Chilingaryan
Initial import |
281 |
this.UpdateGeometry(module); |
282 |
popup_states[module] = 1; |
|
283 |
||
284 |
if (typeof this.popup_on_callbacks[module] != "undefined") { |
|
285 |
for (var i = 0; i < this.popup_on_callbacks[module].length; i++) { |
|
286 |
var cb = this.popup_on_callbacks[module][i]; |
|
287 |
cb.cb(cb.cbattr, true); |
|
288 |
if (cb.once) { |
|
289 |
this.popup_on_callbacks[module].splice(i,1); |
|
290 |
i = i - 1; |
|
291 |
}
|
|
292 |
}
|
|
293 |
||
294 |
}
|
|
295 |
||
296 |
||
297 |
if (!this.num_opened) this.RunReWidthCallbacks(); |
|
298 |
this.num_opened++; |
|
299 |
}
|
|
300 |
||
301 |
for (var i = 0; i < popup_callback.length; i++) { |
|
302 |
var cb = popup_callback[i]; |
|
303 |
cb.cb(cb.cbattr); |
|
304 |
}
|
|
305 |
}
|
|
306 |
}
|
|
307 |
||
312
by Suren A. Chilingaryan
Resizing of sidebar popups |
308 |
POPUP.prototype.RunCallbacks = function() { |
309 |
with (this) { |
|
310 |
for (var i = 0; i < popup_callback.length; i++) { |
|
311 |
var cb = popup_callback[i]; |
|
312 |
cb.cb(cb.cbattr); |
|
313 |
}
|
|
314 |
}
|
|
315 |
}
|
|
316 |
||
12
by Suren A. Chilingaryan
Layout redesign: search tab, controls, menu |
317 |
POPUP.prototype.UpdateGlobalGeometry = function(height, vend) { |
318 |
if (!this.super_popup) return; |
|
319 |
||
320 |
if (vend) this.global_end = vend; |
|
321 |
else if (this.global_end) vend = this.global_end; |
|
322 |
else return; |
|
323 |
||
324 |
var mboffset = domGetNodeOffset(this.super_node); |
|
325 |
var real_size = vend - mboffset[1]; |
|
326 |
||
327 |
var mboffset = domGetNodeOffset(this.super_button); |
|
328 |
var new_size = vend - mboffset[1]; |
|
329 |
domSetHeight(this.super_button, new_size, true, this.super_node, real_size); |
|
330 |
||
331 |
if (!this.popup_states['controls']) return; |
|
332 |
||
333 |
for (var i = 0; i < this.geometry_nodes.length; ++i) { |
|
334 |
var node = this.geometry_nodes[i]; |
|
335 |
var mboffset = domGetNodeOffset(node); |
|
336 |
||
337 |
var new_size = vend - mboffset[1]; |
|
338 |
domSetHeight(node, new_size, true, this.super_node, real_size); |
|
339 |
}
|
|
340 |
}
|
|
341 |
||
342 |
||
1
by Suren A. Chilingaryan
Initial import |
343 |
function popupUpdateGeometryCallback(me, submodule) { |
344 |
me.popup.UpdateGeometry(me.module); |
|
345 |
}
|
|
346 |