2 * QLIB 1.0 Window Abstraction
\r
3 * Copyright (C) 2002 2003, Quazzle.com Serge Dolgov
\r
4 * This program is free software; you can redistribute it and/or
\r
5 * modify it under the terms of the GNU General Public License
\r
6 * as published by the Free Software Foundation; either version 2
\r
7 * of the License, or (at your option) any later version.
\r
8 * http://qlib.quazzle.com
\r
11 function QWndCtrl_center_ie4() {
\r
12 var b = this.document.body;
\r
13 this.moveTo(b.scrollLeft + Math.max(0, Math.floor((b.clientWidth -
\r
14 this.width) / 2)), b.scrollTop + 100);
\r
17 function QWndCtrl_center_moz() {
\r
18 this.moveTo(self.pageXOffset + Math.max(0, Math.floor((self.innerWidth -
\r
19 this.width) / 2)), self.pageYOffset + 100);
\r
22 function QWndCtrl_setEffects_ie4(fx) {
\r
25 filters[0].enabled = (fx & 256) != 0;
\r
26 filters[1].enabled = (fx & 512) != 0;
\r
27 filters[2].enabled = (fx & 1024) != 0;
\r
28 filters[4].enabled = (fx & 2048) != 0;
\r
32 function QWndCtrl_setEffects_moz(fx) {
\r
36 function QWndCtrl_setOpacity_ie4(op) {
\r
37 this.opacity = Math.max(0, Math.min(100, Math.floor(op - 0)));
\r
38 this.wnd.filters[3].opacity = this.opacity;
\r
39 this.wnd.filters[3].enabled = (this.opacity < 100);
\r
42 function QWndCtrl_setOpacity_moz(op) {
\r
43 this.opacity = Math.max(0, Math.min(100, Math.floor(op - 0)));
\r
44 this.wnd.style.MozOpacity = this.opacity + "%";
\r
47 function QWndCtrl_setSize_css(w, h) {
\r
48 this.wnd.style.width = (this.width = Math.floor(w - 0)) + "px";
\r
49 this.wnd.style.height = typeof(h) == "number" ? (this.height = Math.floor(h)) + "px" : "auto";
\r
52 function QWndCtrl_setSize_ns4(w, h) {
\r
53 this.wnd.clip.width = this.width = Math.floor(w - 0);
\r
54 if (typeof(h) == "number") {
\r
55 this.wnd.clip.height = this.height = Math.floor(h);
\r
59 function QWndCtrl_focus() {
\r
60 this.setZIndex(QWndCtrl.TOPZINDEX++);
\r
63 function QWndCtrl_setZIndex_css(z) {
\r
64 this.wnd.style.zIndex = this.zindex = z || 0;
\r
67 function QWndCtrl_setZIndex_ns4(z) {
\r
68 this.wnd.zIndex = this.zindex = z || 0;
\r
71 function QWndCtrl_moveTo_css(x, y) {
\r
72 this.wnd.style.left = (this.x = Math.floor(x - 0)) + "px";
\r
73 this.wnd.style.top = (this.y = Math.floor(y - 0)) + "px";
\r
76 function QWndCtrl_moveTo_ns4(x, y) {
\r
77 this.wnd.moveTo(this.x = Math.floor(x - 0), this.y = Math.floor(y - 0));
\r
80 function QWndCtrl_fxhandler() {
\r
81 this.fxhandler = QControl.nop;
\r
82 this.onShow(this.visible, this.tag);
\r
85 function QWndCtrl_show_ie4(show) {
\r
86 if (this.visible != show) {
\r
88 switch (show ? this.effects & 15 : (this.effects & 240) >>> 4) {
\r
90 fx = this.wnd.filters[5];
\r
93 (fx = this.wnd.filters[6]).transition = show ? 1 : 0;
\r
96 (fx = this.wnd.filters[6]).transition = show ? 3 : 2;
\r
99 (fx = this.wnd.filters[6]).transition = show ? 5 : 4;
\r
102 (fx = this.wnd.filters[6]).transition = show ? 14 : 13;
\r
105 (fx = this.wnd.filters[6]).transition = show ? 16 : 15;
\r
108 (fx = this.wnd.filters[6]).transition = 12;
\r
111 (fx = this.wnd.filters[6]).transition = 8;
\r
114 (fx = this.wnd.filters[6]).transition = 9;
\r
118 this.wnd.style.visibility = (this.visible = show) ? "visible" : "hidden";
\r
119 this.fxhandler = QWndCtrl_fxhandler;
\r
122 this.wnd.style.visibility = (this.visible = show) ? "visible" : "hidden";
\r
123 this.onShow(show, this.tag);
\r
128 function QWndCtrl_fade_moz(op, step) {
\r
129 this._wndt = false;
\r
132 if ((op > 0) && (op < this.opacity)) {
\r
133 this.wnd.style.MozOpacity = op + "%";
\r
134 this._wndt = setTimeout(this.name + ".fade(" + op + "," + step + ")", 50);
\r
137 this.wnd.style.visibility = "hidden";
\r
138 this.visible = false;
\r
140 this.wnd.style.MozOpacity = this.opacity + "%";
\r
141 this.onShow(this.visible, this.tag);
\r
146 function QWndCtrl_show_moz(show) {
\r
147 if (this.visible != show) {
\r
149 clearTimeout(this._wndt);
\r
150 this._wndt = false;
\r
152 var step = show ? ((this.effects & 15) == 1) && Math.floor(this.opacity / 5) :
\r
153 ((this.effects & 240) == 16) && -Math.floor(this.opacity / 5);
\r
155 if (this.visible) {
\r
156 this.fade(this.opacity - 0, step);
\r
158 this.wnd.style.MozOpacity = "0%";
\r
159 this.wnd.style.visibility = "visible";
\r
160 this.visible = true;
\r
161 this.fade(0, step);
\r
164 this.wnd.style.visibility = (this.visible = show) ? "visible" : "hidden";
\r
165 this.onShow(show, this.tag);
\r
170 function QWndCtrl_show_css(show) {
\r
171 if (this.visible != show) {
\r
172 this.wnd.style.visibility = (this.visible = show) ? "visible" : "hidden";
\r
173 this.onShow(show, this.tag);
\r
177 function QWndCtrl_show_ns4(show) {
\r
178 if (this.visible != show) {
\r
179 this.wnd.visibility = (this.visible = show) ? "show" : "hidden";
\r
180 this.onShow(show, this.tag);
\r
184 function QWndCtrl_create_dom2() {
\r
186 this.fxhandler = QControl.nop;
\r
187 var ie4 = document.body && document.body.filters;
\r
188 var moz = document.body && document.body.style &&
\r
189 typeof(document.body.style.MozOpacity) == "string";
\r
190 document.write('<div unselectable="on" id="' + id +
\r
191 (ie4 ? '" onfilterchange="' + name + '.fxhandler()': '') +
\r
192 '" style="position:absolute;left:' + x + 'px;top:' + y +
\r
193 'px;width:' + width + (height != null ? 'px;height:' + height : '') +
\r
194 'px;visibility:' + (visible ? 'visible' : 'hidden') +
\r
195 ';overflow:hidden' + (zindex ? ';z-index:' + zindex : '') +
\r
196 (ie4 ? ';filter:Gray(enabled=' + (effects & 256 ? '1' : '0') +
\r
197 ') Xray(enabled=' + (effects & 512 ? '1' : '0') +
\r
198 ') Invert(enabled=' + (effects & 1024 ? '1' : '0') +
\r
199 ') alpha(enabled=' + (opacity < 100 ? '1' : '0') + ',opacity=' + opacity +
\r
200 ') shadow(enabled=' + (effects & 2048 ? '1' : '0') +
\r
201 ',direction=135) BlendTrans(enabled=0) RevealTrans(enabled=0)' : '') +
\r
202 (moz && (opacity < 100) ? ';-moz-opacity:' + opacity + '%' : '') +
\r
203 '"><div unselectable="on" class="qwindow">');
\r
204 if (typeof(content) == "function") {
\r
207 document.write(content);
\r
209 document.write('</div></div>');
\r
210 if (this.wnd = document.getElementById ? document.getElementById(id) :
\r
211 (document.all.item ? document.all.item(id) : document.all[id])) {
\r
213 ie4 = ie4 && wnd.filters;
\r
214 moz = moz && typeof(wnd.style.MozOpacity) == "string";
\r
215 this.moveTo = QWndCtrl_moveTo_css;
\r
216 this.setZIndex = QWndCtrl_setZIndex_css;
\r
217 this.focus = QWndCtrl_focus;
\r
218 this.setSize = QWndCtrl_setSize_css;
\r
219 this.show = ie4 ? QWndCtrl_show_ie4 : (moz ? QWndCtrl_show_moz : QWndCtrl_show_css);
\r
220 this.fade = moz ? QWndCtrl_fade_moz : QControl.nop;
\r
221 this.setOpacity = ie4 ? QWndCtrl_setOpacity_ie4 : (moz ? QWndCtrl_setOpacity_moz : QControl.nop);
\r
222 this.setEffects = ie4 ? QWndCtrl_setEffects_ie4 : (moz ? QWndCtrl_setEffects_moz : QControl.nop);
\r
223 this.center = self.innerWidth ? QWndCtrl_center_moz :
\r
224 (document.body && document.body.clientWidth ? QWndCtrl_center_ie4 : QControl.nop);
\r
230 function QWndCtrl_create_ns4(finalize) {
\r
234 parent.window.onload = _wnde;
\r
235 parent.window.onload();
\r
238 document.write('<div class="qwindow">');
\r
240 document.write('</div>');
\r
243 document.write('<layer id="' + id + '" left="' + x + '" top="' + y +
\r
244 '" width="' + width + '" visibility="' + (visible ? 'show' : 'hidden') +
\r
245 (height != null ? '" height="' + height + '" clip="' + width + ',' + height : '') +
\r
246 (zindex ? '" z-index="' + zindex : '') + (typeof(content) != "function" ?
\r
247 '"><div class="qwindow">' + content + '</div></layer>' : '"> </layer>'));
\r
248 if (this.window = this.wnd = document.layers[id]) {
\r
249 if (this.document = wnd.document) {
\r
250 this.show = QWndCtrl_show_ns4;
\r
251 this.moveTo = QWndCtrl_moveTo_ns4;
\r
252 this.setZIndex = QWndCtrl_setZIndex_ns4;
\r
253 this.focus = QWndCtrl_focus;
\r
254 this.center = QWndCtrl_center_moz;
\r
255 this.setSize = QWndCtrl_setSize_ns4;
\r
256 if (typeof(content) == "function") {
\r
257 this._wnde = parent.window.onload;
\r
258 parent.window.onload = new Function(name + ".create(true)");
\r
266 function QWndCtrl_create_na() {
\r
267 this.document.write('Object is not supported.');
\r
271 function QWndCtrl_create() {
\r
273 this.create = (document.getElementById || document.all) ? QWndCtrl_create_dom2 :
\r
274 (document.layers ? QWndCtrl_create_ns4 : QWndCtrl_create_na);
\r
279 function QWndCtrl() {
\r
280 this.x = this.y = 0;
\r
281 this.width = this.height = 0;
\r
283 this.visible = true;
\r
285 this.opacity = 100;
\r
286 this.zindex = null;
\r
287 this._wndt = this._wnde = false;
\r
288 this.create = QWndCtrl_create;
\r
289 this.show = QControl.nop;
\r
290 this.focus = QControl.nop;
\r
291 this.center = QControl.nop;
\r
292 this.moveTo = QControl.nop;
\r
293 this.setSize = QControl.nop;
\r
294 this.setOpacity = QControl.nop;
\r
295 this.setEffects = QControl.nop;
\r
296 this.setZIndex = QControl.nop;
\r
297 this.onShow = QControl.event;
\r
299 QWndCtrl.prototype = new QControl();
\r
300 QWndCtrl.TOPZINDEX = 1000;
\r
301 QWndCtrl.GRAY = 256;
\r
302 QWndCtrl.XRAY = 512;
\r
303 QWndCtrl.INVERT = 1024;
\r
304 QWndCtrl.SHADOW = 2048;
\r
305 QWndCtrl.FADEIN = 1;
\r
306 QWndCtrl.FADEOUT = 16;
\r
307 QWndCtrl.BOXIN = 2;
\r
308 QWndCtrl.BOXOUT = 32;
\r
309 QWndCtrl.CIRCLEIN = 3;
\r
310 QWndCtrl.CIRCLEOUT = 48;
\r
311 QWndCtrl.WIPEIN = 4;
\r
312 QWndCtrl.WIPEOUT = 64;
\r
313 QWndCtrl.HBARNIN = 5;
\r
314 QWndCtrl.HBARNOUT = 80;
\r
315 QWndCtrl.VBARNIN = 6;
\r
316 QWndCtrl.VBARNOUT = 96;
\r
317 QWndCtrl.DISSOLVEIN = 7;
\r
318 QWndCtrl.DISSOLVEOUT = 112;
\r
319 QWndCtrl.HBLINDSIN = 8;
\r
320 QWndCtrl.HBLINDSOUT = 128;
\r
321 QWndCtrl.VBLINDSIN = 9;
\r
322 QWndCtrl.VBLINDSOUT = 144;
\r