398
|
1 /* Copyright (C) 2003,2004 IT-Group MPIWG, WTWG Uni Bern and others
|
|
2
|
|
3 This program is free software; you can redistribute it and/or
|
|
4 modify it under the terms of the GNU General Public License
|
|
5 as published by the Free Software Foundation; either version 2
|
|
6 of the License, or (at your option) any later version.
|
|
7
|
|
8 This program is distributed in the hope that it will be useful,
|
|
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 GNU General Public License for more details.
|
|
12
|
|
13 You should have received a copy of the GNU General Public License
|
|
14 along with this program; if not, write to the Free Software
|
|
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
16
|
|
17 Authors:
|
|
18 Christian Luginbuehl, 01.05.2003 (first version)
|
|
19 DW 24.03.2004 (Changed for digiLib in Zope)
|
|
20 Robert Casties, 2.11.2004
|
407
|
21 Martin Raspe, 12.12.2005 (changes for Digilib NG)
|
398
|
22
|
|
23 */
|
|
24
|
407
|
25 // was: function base_init() {
|
|
26 baseLibVersion = "2.0";
|
|
27 browserType = getBrowserType();
|
398
|
28
|
|
29
|
|
30 function getInt(n) {
|
|
31 // returns always an integer
|
|
32 n = parseInt(n);
|
|
33 if (isNaN(n)) return 0;
|
|
34 return n;
|
|
35 }
|
|
36
|
|
37 function defined(x) {
|
|
38 // returns if x is defined
|
|
39 return (typeof arguments[0] != "undefined");
|
|
40 }
|
|
41
|
|
42 function cropFloat(x) {
|
|
43 // auxiliary function to crop senseless precision
|
407
|
44 return parseInt(10000 * x) / 10000;
|
398
|
45 }
|
|
46
|
|
47 function getBrowserType() {
|
|
48 // browser sniffer
|
|
49 var bt = Object();
|
|
50 bt.doDHTML = false;
|
|
51 bt.versIE = 0;
|
|
52
|
|
53 if ((! document.cssonly && document.layers) || document.all || document.getElementById) {
|
|
54 var vers = navigator.appVersion.split('MSIE ');
|
|
55 vers = vers[vers.length - 1];
|
|
56 bt.versIE = getInt(vers);
|
|
57 bt.isIE = navigator.userAgent.indexOf('MSIE') >= 0;
|
|
58 bt.isMac = navigator.platform.indexOf('Mac') >= 0;
|
|
59 bt.isWin = navigator.platform.indexOf('Win') >= 0;
|
|
60 bt.isN4 = (navigator.userAgent.indexOf('Mozilla/4.') >= 0) && ! bt.isIE;
|
|
61 bt.isIEWin = bt.versIE > 0 && bt.isWin;
|
|
62 if (navigator.appVersion.indexOf('MSIE') < 0 || ! bt.isMac || bt.versIE >= 5) {
|
|
63 bt.doDHTML = true;
|
|
64 bt.isOpera = navigator.userAgent.indexOf(' Opera ') >= 0;
|
|
65 bt.isKonq = navigator.userAgent.indexOf(' Konqueror') >= 0;
|
|
66 }
|
|
67 }
|
|
68 return bt;
|
|
69 }
|
|
70
|
|
71 // fixes for javascript < 1.2
|
|
72 if (! Array.prototype.push) {
|
|
73 Array.prototype.push = function(val) {
|
|
74 this[this.length] = val;
|
|
75 return this.length;
|
|
76 }
|
|
77 Array.prototype.pop = function() {
|
|
78 var val = this[this.length-1];
|
|
79 this.length -= 1;
|
|
80 return val;
|
|
81 }
|
|
82 }
|
|
83
|
|
84
|
|
85 /* **********************************************
|
|
86 * geometry classes
|
|
87 * ******************************************** */
|
|
88
|
|
89 /*
|
|
90 * Size class
|
|
91 */
|
|
92 function Size(w, h) {
|
|
93 this.width = parseFloat(w);
|
|
94 this.height = parseFloat(h);
|
|
95 return this;
|
|
96 }
|
|
97 Size.prototype.toString = function() {
|
|
98 return this.width + "x" + this.height;
|
|
99 }
|
|
100
|
|
101
|
|
102 /*
|
|
103 * Position class
|
|
104 */
|
|
105 function Position(x, y) {
|
|
106 this.x = parseFloat(x);
|
|
107 this.y = parseFloat(y);
|
|
108 return this;
|
|
109 }
|
|
110 Position.prototype.toString = function() {
|
|
111 return this.x + "," + this.y;
|
|
112 }
|
|
113
|
|
114 /*
|
|
115 * Rectangle class
|
|
116 */
|
|
117 function Rectangle(x, y, w, h) {
|
|
118 this.x = parseFloat(x);
|
|
119 this.y = parseFloat(y);
|
|
120 this.width = parseFloat(w);
|
|
121 this.height = parseFloat(h);
|
|
122 return this;
|
|
123 }
|
|
124 Rectangle.prototype.toString = function() {
|
|
125 return this.width+"x"+this.height+"@"+this.x+","+this.y;
|
|
126 }
|
|
127 Rectangle.prototype.copy = function() {
|
|
128 // returns a copy of this Rectangle
|
|
129 return new Rectangle(this.x, this.y, this.width, this.height);
|
|
130 }
|
|
131 Rectangle.prototype.getPosition = function() {
|
|
132 // returns the position of this Rectangle
|
|
133 return new Position(this.x, this.y);
|
|
134 }
|
|
135 Rectangle.prototype.getSize = function() {
|
|
136 // returns the size of this Rectangle
|
|
137 return new Size(this.width, this.height);
|
|
138 }
|
|
139 Rectangle.prototype.getArea = function() {
|
|
140 // returns the area of this Rectangle
|
|
141 return (this.width * this.height);
|
|
142 }
|
|
143 Rectangle.prototype.containsPosition = function(pos) {
|
|
144 // returns if the given Position lies in this Rectangle
|
|
145 return ((pos.x >= this.x)&&(pos.y >= this.y)&&(pos.x <= this.x+this.width)&&(pos.y <= this.y+this.width));
|
|
146 }
|
|
147 Rectangle.prototype.intersect = function(rect) {
|
|
148 // returns the intersection of the given Rectangle and this one
|
|
149 var sec = rect.copy();
|
|
150 if (sec.x < this.x) {
|
|
151 sec.width = sec.width - (this.x - sec.x);
|
|
152 sec.x = this.x;
|
|
153 }
|
|
154 if (sec.y < this.y) {
|
|
155 sec.height = sec.height - (this.y - sec.y);
|
|
156 sec.y = this.y;
|
|
157 }
|
|
158 if (sec.x + sec.width > this.x + this.width) {
|
|
159 sec.width = (this.x + this.width) - sec.x;
|
|
160 }
|
|
161 if (sec.y + sec.height > this.y + this.height) {
|
|
162 sec.height = (this.y + this.height) - sec.y;
|
|
163 }
|
|
164 return sec;
|
|
165 }
|
|
166 Rectangle.prototype.fit = function(rect) {
|
|
167 // returns a Rectangle that fits into this one (by moving first)
|
|
168 var sec = rect.copy();
|
|
169 sec.x = Math.max(sec.x, this.x);
|
|
170 sec.x = Math.max(sec.x, this.x);
|
|
171 if (sec.x + sec.width > this.x + this.width) {
|
|
172 sec.x = this.x + this.width - sec.width;
|
|
173 }
|
|
174 if (sec.y + sec.height > this.y + this.height) {
|
|
175 sec.y = this.y + this.height - sec.height;
|
|
176 }
|
|
177 return sec.intersect(this);
|
|
178 }
|
|
179
|
|
180 /*
|
|
181 * Transform class
|
|
182 *
|
|
183 * defines a class of affine transformations
|
|
184 */
|
|
185 function Transform() {
|
|
186 this.m00 = 1.0;
|
|
187 this.m01 = 0.0;
|
|
188 this.m02 = 0.0;
|
|
189 this.m10 = 0.0;
|
|
190 this.m11 = 1.0;
|
|
191 this.m12 = 0.0;
|
|
192 this.m20 = 0.0;
|
|
193 this.m21 = 0.0;
|
|
194 this.m22 = 1.0;
|
|
195 return this;
|
|
196 }
|
|
197 Transform.prototype.concat = function(traf) {
|
|
198 // add Transform traf to this Transform
|
|
199 for (var i = 0; i < 3; i++) {
|
|
200 for (var j = 0; j < 3; j++) {
|
|
201 var c = 0.0;
|
|
202 for (var k = 0; k < 3; k++) {
|
|
203 c += traf["m"+i+k] * this["m"+k+j];
|
|
204 }
|
|
205 this["m"+i+j] = c;
|
|
206 }
|
|
207 }
|
|
208 return this;
|
|
209 }
|
|
210 Transform.prototype.transform = function(rect) {
|
|
211 // returns transformed Rectangle or Position with this Transform applied
|
|
212 var x = this.m00 * rect.x + this.m01 * rect.y + this.m02;
|
|
213 var y = this.m10 * rect.x + this.m11 * rect.y + this.m12;
|
|
214 if (rect.width) {
|
|
215 var width = this.m00 * rect.width + this.m01 * rect.height;
|
|
216 var height = this.m10 * rect.width + this.m11 * rect.height;
|
|
217 return new Rectangle(x, y, width, height);
|
|
218 }
|
|
219 return new Position(x, y);
|
|
220 }
|
|
221 Transform.prototype.invtransform = function(pos) {
|
|
222 // returns transformed Position pos with the inverse of this Transform applied
|
|
223 var det = this.m00 * this.m11 - this.m01 * this.m10;
|
|
224 var x = (this.m11 * pos.x - this.m01 * pos.y - this.m11 * this.m02 + this.m01 * this.m12) / det;
|
|
225 var y = (- this.m10 * pos.x + this.m00 * pos.y + this.m10 * this.m02 - this.m00 * this.m12) / det;
|
|
226 return new Position(x, y);
|
|
227 }
|
|
228 function getRotation(angle, pos) {
|
|
229 // returns a Transform that is a rotation by angle degrees around [pos.x, pos.y]
|
|
230 var traf = new Transform();
|
|
231 if (angle != 0) {
|
|
232 var t = 2.0 * Math.PI * parseFloat(angle) / 360.0;
|
|
233 traf.m00 = Math.cos(t);
|
|
234 traf.m01 = - Math.sin(t);
|
|
235 traf.m10 = Math.sin(t);
|
|
236 traf.m11 = Math.cos(t);
|
|
237 traf.m02 = pos.x - pos.x * Math.cos(t) + pos.y * Math.sin(t);
|
|
238 traf.m12 = pos.y - pos.x * Math.sin(t) - pos.y * Math.cos(t);
|
|
239 }
|
|
240 return traf;
|
|
241 }
|
|
242 function getTranslation(pos) {
|
|
243 // returns a Transform that is a translation by [pos.x, pos,y]
|
|
244 var traf = new Transform();
|
|
245 traf.m02 = pos.x;
|
|
246 traf.m12 = pos.y;
|
|
247 return traf;
|
|
248 }
|
|
249 function getScale(size) {
|
|
250 // returns a Transform that is a scale by [size.width, size.height]
|
|
251 var traf = new Transform();
|
|
252 traf.m00 = size.width;
|
|
253 traf.m11 = size.height;
|
|
254 return traf;
|
|
255 }
|
|
256
|
|
257
|
|
258 /* **********************************************
|
|
259 * parameter routines
|
|
260 * ******************************************** */
|
407
|
261 dlParams = new Object();
|
398
|
262
|
|
263 function newParameter(name, defaultValue, detail) {
|
|
264 // create a new parameter with a name and a default value
|
|
265 if (!defined(dlParams[name])) dlParams[name] = new Object(); // no error condition
|
|
266 //alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!");
|
|
267 //return false;
|
|
268 dlParams[name].defaultValue = defaultValue;
|
|
269 dlParams[name].hasValue = false;
|
|
270 dlParams[name].value = defaultValue;
|
|
271 dlParams[name].detail = detail;
|
|
272 return dlParams[name];
|
|
273 }
|
|
274
|
|
275 function getParameter(name) {
|
|
276 // returns the named parameter value or its default value
|
407
|
277 if (!defined(dlParams[name])) return null;
|
|
278 if (dlParams[name].hasValue)
|
|
279 return dlParams[name].value;
|
|
280 else
|
398
|
281 return dlParams[name].defaultValue;
|
|
282 }
|
|
283
|
|
284 function setParameter(name, value, relative) {
|
|
285 // sets parameter value (relative values with +/- unless literal)
|
407
|
286 if (!defined(dlParams[name])) return null;
|
|
287 var p = dlParams[name];
|
|
288 if (relative && value.slice) {
|
|
289 var sign = value.slice(0, 1);
|
|
290 if (sign == '+') {
|
|
291 p.value = parseFloat(p.value) + parseFloat(value.slice(1));
|
|
292 } else if (sign == '-') {
|
|
293 p.value = parseFloat(p.value) - parseFloat(value.slice(1));
|
|
294 } else {
|
|
295 p.value = value;
|
|
296 }
|
|
297 } else p.value = value;
|
|
298 p.hasValue = true;
|
|
299 return p.value;
|
|
300 }
|
398
|
301
|
|
302 function hasParameter(name) {
|
407
|
303 // returns if the parameter's value has been set
|
|
304 if (!defined(dlParams[name])) return null;
|
|
305 return dlParams[name].hasValue;
|
|
306 }
|
398
|
307
|
|
308 function getAllParameters(detail) {
|
|
309 // returns a string of all parameters in query format
|
|
310 if (! detail) {
|
|
311 detail = 255;
|
|
312 }
|
|
313 var params = new Array();
|
|
314 for (param in dlParams) {
|
|
315 if (((dlParams[param].detail & detail) > 0)&&(dlParams[param].hasValue)) {
|
|
316 var val = getParameter(param);
|
|
317 if (val != "") {
|
|
318 params.push(param + "=" + val);
|
|
319 }
|
|
320 }
|
|
321 }
|
|
322 return params.join("&");
|
|
323 }
|
|
324
|
|
325 function parseParameters(query) {
|
|
326 // gets parameter values from query format string
|
|
327 var params = query.split("&");
|
|
328 for (var i = 0; i < params.length; i++) {
|
|
329 var keyval = params[i].split("=");
|
|
330 if (keyval.length == 2) {
|
|
331 setParameter(keyval[0], keyval[1]);
|
|
332 }
|
|
333 }
|
|
334 }
|
|
335
|
407
|
336 function resetParameters() {
|
|
337 // reset parameters to initial values
|
|
338 newParameter('fn', '', 1);
|
|
339 newParameter('pn', '1', 1);
|
|
340 newParameter('ws', '1.0', 1);
|
|
341 newParameter('mo', '', 1);
|
|
342 newParameter('mk', '', 3);
|
|
343 newParameter('wx', '0.0', 2);
|
|
344 newParameter('wy', '0.0', 2);
|
|
345 newParameter('ww', '1.0', 2);
|
|
346 newParameter('wh', '1.0', 2);
|
|
347 newParameter('pt', '<%= dlRequest.getAsString("pt") %>', 1);
|
|
348 newParameter('brgt', '0.0', 1);
|
|
349 newParameter('cont', '0.0', 1);
|
|
350 newParameter('rot', '0.0', 1);
|
|
351 newParameter('rgba', '', 1);
|
|
352 newParameter('rgbm', '', 1);
|
|
353 newParameter('ddpix', '', 1);
|
|
354 newParameter('ddpiy', '', 1);
|
|
355 }
|
|
356
|
|
357 getQueryString = getAllParameters;
|
398
|
358
|
|
359 /* **********************************************
|
|
360 * HTML/DOM routines
|
|
361 * ******************************************** */
|
|
362
|
|
363 function getElement(tagid, quiet) {
|
|
364 // returns the element object with the id tagid
|
|
365 var e;
|
|
366 if (document.getElementById) {
|
|
367 e = document.getElementById(tagid);
|
|
368 } else if (document.all) {
|
|
369 alert("document.all!");
|
|
370 e = document.all[tagid];
|
|
371 } else if (document.layers) {
|
|
372 e = document.layers[tagid];
|
|
373 }
|
|
374 if (e) {
|
|
375 return e;
|
|
376 } else {
|
|
377 if (! quiet) {
|
|
378 alert("unable to find element: "+tagid);
|
|
379 }
|
|
380 return null;
|
|
381 }
|
|
382 }
|
|
383
|
|
384 function getElementPosition(elem) {
|
|
385 // returns a Position with the position of the element
|
|
386 var x = 0;
|
|
387 var y = 0;
|
|
388 if (defined(elem.offsetLeft)) {
|
|
389 var e = elem;
|
|
390 while (e) {
|
|
391 if (defined(e.clientLeft)) {
|
|
392 // special for IE
|
|
393 if (browserType.isMac) {
|
|
394 if (e.offsetParent.tagName == "BODY") {
|
|
395 // IE for Mac extraspecial
|
|
396 x += e.clientLeft;
|
|
397 y += e.clientTop;
|
|
398 break;
|
|
399 }
|
|
400 } else {
|
|
401 if ((e.tagName != "TABLE") && (e.tagName != "BODY")) {
|
|
402 x += e.clientLeft;
|
|
403 y += e.clientTop;
|
|
404 }
|
|
405 }
|
|
406 }
|
|
407 x += e.offsetLeft;
|
|
408 y += e.offsetTop;
|
|
409 e = e.offsetParent;
|
|
410 }
|
|
411 } else if (defined(elem.x)) {
|
|
412 x = elem.x;
|
|
413 y = elem.y;
|
|
414 } else if (defined(elem.pageX)) {
|
|
415 x = elem.pageX;
|
|
416 y = elem.pageY;
|
|
417 } else {
|
|
418 alert("unable to get position of "+elem+" (id:"+elem.id+")");
|
|
419 }
|
|
420 return new Position(getInt(x), getInt(y));
|
|
421 }
|
|
422
|
|
423 function getElementSize(elem) {
|
|
424 // returns a Rectangle with the size of the element
|
|
425 var width = 0;
|
|
426 var height = 0;
|
|
427 if (defined(elem.offsetWidth)) {
|
|
428 width = elem.offsetWidth;
|
|
429 height = elem.offsetHeight;
|
|
430 } else if (defined(elem.width)) {
|
|
431 width = elem.width;
|
|
432 height = elem.height;
|
|
433 } else if (defined(elem.clip.width)) {
|
|
434 width = elem.clip.width;
|
|
435 height = elem.clip.height;
|
|
436 } else {
|
|
437 alert("unable to get size of "+elem+" (id:"+elem.id+")");
|
|
438 }
|
|
439 return new Size(getInt(width), getInt(height));
|
|
440 }
|
|
441
|
|
442 function getElementRect(elem) {
|
|
443 // returns a Rectangle with the size and position of the element
|
|
444 var pos = getElementPosition(elem);
|
|
445 var size = getElementSize(elem);
|
|
446 return new Rectangle(pos.x, pos.y, size.width, size.height);
|
|
447 }
|
|
448
|
|
449
|
|
450
|
|
451 function moveElement(elem, rect) {
|
|
452 // moves and sizes the element
|
|
453 if (elem.style) {
|
|
454 if (defined(rect.x)) {
|
|
455 elem.style.left = Math.round(rect.x) + "px";
|
|
456 elem.style.top = Math.round(rect.y) + "px";
|
|
457 }
|
|
458 if (defined(rect.width)) {
|
|
459 elem.style.width = Math.round(rect.width) + "px";
|
|
460 elem.style.height = Math.round(rect.height) + "px";
|
|
461 }
|
|
462 } else if (document.layers) {
|
|
463 if (defined(rect.x)) {
|
|
464 elem.pageX = getInt(rect.x);
|
|
465 elem.pageY = getInt(rect.y);
|
|
466 }
|
|
467 if (defined(rect.width)) {
|
|
468 elem.clip.width = getInt(rect.width);
|
|
469 elem.clip.height = getInt(rect.height);
|
|
470 }
|
|
471 } else {
|
|
472 alert("moveelement: no style nor layer property!");
|
|
473 return false;
|
|
474 }
|
|
475 return true;
|
|
476 }
|
|
477
|
|
478 function showElement(elem, show) {
|
|
479 // shows or hides the element
|
|
480 if (elem.style) {
|
|
481 if (show) {
|
|
482 elem.style.visibility = "visible";
|
|
483 } else {
|
|
484 elem.style.visibility = "hidden";
|
|
485 }
|
|
486 } else if (defined(elem.visibility)) {
|
|
487 if (show) {
|
|
488 elem.visibility = "show";
|
|
489 } else {
|
|
490 elem.visibility = "hide";
|
|
491 }
|
|
492 } else {
|
|
493 alert("showelement: no style nor layer property!");
|
|
494 }
|
|
495 return true;
|
|
496 }
|
|
497
|
|
498 function evtPosition(evt) {
|
|
499 // returns the on-screen Position of the Event
|
|
500 var x;
|
|
501 var y;
|
|
502 evt = (evt) ? evt : window.event;
|
|
503 if (!evt) {
|
|
504 alert("no event found! "+evt);
|
|
505 return;
|
|
506 }
|
|
507 if (defined(evt.pageX)) {
|
|
508 x = parseInt(evt.pageX);
|
|
509 y = parseInt(evt.pageY);
|
|
510 } else if (defined(evt.clientX)) {
|
|
511 x = parseInt(document.body.scrollLeft+evt.clientX);
|
|
512 y = parseInt(document.body.scrollTop+evt.clientY);
|
|
513 } else {
|
|
514 alert("evtPosition: don't know how to deal with "+evt);
|
|
515 }
|
|
516 return new Position(x, y);
|
|
517 }
|
|
518
|
|
519 function registerEvent(type, elem, handler) {
|
407
|
520 // register the given event handler on the indicated element
|
|
521 if (elem.addEventListener) {
|
|
522 elem.addEventListener(type, handler, false); // bubble
|
|
523 }
|
|
524 else if (elem.attachEvent) {
|
|
525 elem.attachEvent("on" + type, handler);
|
|
526 }
|
|
527 else if (elem.captureEvents) {
|
|
528 if (Event) {
|
|
529 t = type.toUpperCase();
|
|
530 elem.captureEvents(Event[t]);
|
|
531 elem[ "on" + t ] = handler;
|
|
532 }
|
|
533 }
|
|
534 else {
|
|
535 alert("Could not register event of type " + type);
|
|
536 return false;
|
|
537 }
|
|
538 return true;
|
|
539 }
|
|
540
|
|
541 function unregisterEvent(type, elem, handler) {
|
|
542 // unregister the given event handler from the indicated element
|
|
543 if (elem.removeEventListener) {
|
|
544 elem.removeEventListener(type, handler, false);
|
|
545 }
|
|
546 else if (elem.detachEvent) {
|
|
547 elem.detachEvent('on' + type, handler);
|
|
548 }
|
|
549 else if (elem.releaseEvents) {
|
|
550 if (Event) {
|
|
551 t = type.toUpperCase();
|
|
552 elem.releaseEvents(Event[t]);
|
|
553 elem[ "on" + t ] = null;
|
|
554 }
|
|
555 }
|
|
556 else {
|
|
557 alert("Could not register event of type " + type);
|
|
558 return false;
|
|
559 }
|
|
560 return true;
|
398
|
561 }
|
|
562
|
407
|
563 function registerEventById(type, id, handler) {
|
|
564 registerEvent(type, document.getElementById(id), handler);
|
|
565 }
|
|
566
|
|
567 function unregisterEventById(type, id, handler) {
|
|
568 unregisterEvent(type, document.getElementById(id), handler);
|
|
569 }
|
|
570
|
|
571 function stopEvent(e) {
|
|
572 if (!e) var e = window.event;
|
|
573 e.cancelBubble = true;
|
|
574 if (e.stopPropagation) e.stopPropagation();
|
|
575 return false;
|
398
|
576 }
|
|
577
|
407
|
578 function getEventSrc(e) {
|
|
579 if (e.target) return e.target;
|
|
580 if (e.srcElement) return e.srcElement;
|
|
581 }
|
398
|
582
|
|
583 // old registerXXYY API for compatibility
|
|
584 function registerMouseDown(elem, handler) {
|
|
585 return registerEvent("mousedown", elem, handler);
|
|
586 }
|
|
587 function unregisterMouseDown(elem, handler) {
|
|
588 return unregisterEvent("mousedown", elem, handler);
|
|
589 }
|
|
590 function registerMouseMove(elem, handler) {
|
|
591 return registerEvent("mousemove", elem, handler);
|
|
592 }
|
|
593 function unregisterMouseMove(elem, handler) {
|
|
594 return unregisterEvent("mousemove", elem, handler);
|
|
595 }
|
|
596 function registerKeyDown(handler) {
|
|
597 return registerEvent("keypress", elem, handler);
|
|
598 }
|
|
599
|
|
600
|
|
601 function getWinSize() {
|
|
602 // returns a Size with the current window size (mostly from www.quirksmode.org)
|
|
603 var wsize = new Size(100, 100);
|
|
604 if (defined(self.innerHeight)) {
|
|
605 // all except Explorer
|
|
606 if ((self.innerWidth == 0)||(self.innerHeight == 0)) {
|
|
607 // Safari 1.2 bug
|
|
608 if (parent) {
|
|
609 parent.innerHeight;
|
|
610 parent.innerWidth;
|
|
611 }
|
|
612 }
|
|
613 wsize.width = self.innerWidth;
|
|
614 wsize.height = self.innerHeight;
|
|
615 } else if (document.documentElement && document.documentElement.clientHeight) {
|
|
616 // Explorer 6 Strict Mode
|
|
617 wsize.width = document.documentElement.clientWidth;
|
|
618 wsize.height = document.documentElement.clientHeight;
|
|
619 } else if (document.body) {
|
|
620 // other Explorers
|
|
621 wsize.width = document.body.clientWidth;
|
|
622 wsize.height = document.body.clientHeight;
|
|
623 }
|
|
624 return wsize;
|
|
625 }
|
|
626
|
|
627 function openWin(url, name, params) {
|
|
628 // open browser window
|
|
629 var ow = window.open(url, name, params);
|
|
630 ow.focus();
|
|
631 }
|