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) {
|
412
|
144 // returns if Position "pos" lies inside of this rectangle
|
|
145 return ((pos.x >= this.x)
|
|
146 && (pos.y >= this.y)
|
|
147 && (pos.x <= this.x + this.width)
|
|
148 && (pos.y <= this.y + this.width)
|
|
149 );
|
|
150 }
|
|
151 Rectangle.prototype.containsRect = function(rect) {
|
|
152 // returns if rectangle "rect" is contained in this rectangle
|
|
153 return (this.containsPosition(rect)
|
|
154 && this.containsPosition(new Position(
|
|
155 rect.x + rect.width,
|
|
156 rect.y + rect.height
|
|
157 )));
|
|
158 }
|
|
159 Rectangle.prototype.stayInside = function(rect) {
|
|
160 // changes this rectangle's x/y values so it stays inside of rectangle rect
|
|
161 if (this.x < rect.x) this.x = rect.x;
|
|
162 if (this.y < rect.y) this.y = rect.y;
|
|
163 if (this.x + this.width > rect.x + rect.width)
|
|
164 this.x = rect.x + rect.width - this.width;
|
|
165 if (this.y + this.height > rect.y + rect.height)
|
|
166 this.y = rect.y + rect.height - this.height;
|
|
167 return this;
|
398
|
168 }
|
|
169 Rectangle.prototype.intersect = function(rect) {
|
|
170 // returns the intersection of the given Rectangle and this one
|
412
|
171 // FIX ME: not really, it should return null if there is no overlap
|
398
|
172 var sec = rect.copy();
|
|
173 if (sec.x < this.x) {
|
|
174 sec.width = sec.width - (this.x - sec.x);
|
|
175 sec.x = this.x;
|
|
176 }
|
|
177 if (sec.y < this.y) {
|
|
178 sec.height = sec.height - (this.y - sec.y);
|
|
179 sec.y = this.y;
|
|
180 }
|
|
181 if (sec.x + sec.width > this.x + this.width) {
|
|
182 sec.width = (this.x + this.width) - sec.x;
|
|
183 }
|
|
184 if (sec.y + sec.height > this.y + this.height) {
|
|
185 sec.height = (this.y + this.height) - sec.y;
|
|
186 }
|
|
187 return sec;
|
|
188 }
|
|
189 Rectangle.prototype.fit = function(rect) {
|
|
190 // returns a Rectangle that fits into this one (by moving first)
|
|
191 var sec = rect.copy();
|
|
192 sec.x = Math.max(sec.x, this.x);
|
|
193 sec.x = Math.max(sec.x, this.x);
|
|
194 if (sec.x + sec.width > this.x + this.width) {
|
|
195 sec.x = this.x + this.width - sec.width;
|
|
196 }
|
|
197 if (sec.y + sec.height > this.y + this.height) {
|
|
198 sec.y = this.y + this.height - sec.height;
|
|
199 }
|
|
200 return sec.intersect(this);
|
|
201 }
|
|
202
|
|
203 /*
|
|
204 * Transform class
|
|
205 *
|
|
206 * defines a class of affine transformations
|
|
207 */
|
|
208 function Transform() {
|
|
209 this.m00 = 1.0;
|
|
210 this.m01 = 0.0;
|
|
211 this.m02 = 0.0;
|
|
212 this.m10 = 0.0;
|
|
213 this.m11 = 1.0;
|
|
214 this.m12 = 0.0;
|
|
215 this.m20 = 0.0;
|
|
216 this.m21 = 0.0;
|
|
217 this.m22 = 1.0;
|
|
218 return this;
|
|
219 }
|
|
220 Transform.prototype.concat = function(traf) {
|
|
221 // add Transform traf to this Transform
|
|
222 for (var i = 0; i < 3; i++) {
|
|
223 for (var j = 0; j < 3; j++) {
|
|
224 var c = 0.0;
|
|
225 for (var k = 0; k < 3; k++) {
|
|
226 c += traf["m"+i+k] * this["m"+k+j];
|
|
227 }
|
|
228 this["m"+i+j] = c;
|
|
229 }
|
|
230 }
|
|
231 return this;
|
|
232 }
|
|
233 Transform.prototype.transform = function(rect) {
|
|
234 // returns transformed Rectangle or Position with this Transform applied
|
|
235 var x = this.m00 * rect.x + this.m01 * rect.y + this.m02;
|
|
236 var y = this.m10 * rect.x + this.m11 * rect.y + this.m12;
|
|
237 if (rect.width) {
|
|
238 var width = this.m00 * rect.width + this.m01 * rect.height;
|
|
239 var height = this.m10 * rect.width + this.m11 * rect.height;
|
|
240 return new Rectangle(x, y, width, height);
|
|
241 }
|
|
242 return new Position(x, y);
|
|
243 }
|
|
244 Transform.prototype.invtransform = function(pos) {
|
|
245 // returns transformed Position pos with the inverse of this Transform applied
|
|
246 var det = this.m00 * this.m11 - this.m01 * this.m10;
|
|
247 var x = (this.m11 * pos.x - this.m01 * pos.y - this.m11 * this.m02 + this.m01 * this.m12) / det;
|
|
248 var y = (- this.m10 * pos.x + this.m00 * pos.y + this.m10 * this.m02 - this.m00 * this.m12) / det;
|
|
249 return new Position(x, y);
|
|
250 }
|
|
251 function getRotation(angle, pos) {
|
|
252 // returns a Transform that is a rotation by angle degrees around [pos.x, pos.y]
|
|
253 var traf = new Transform();
|
|
254 if (angle != 0) {
|
|
255 var t = 2.0 * Math.PI * parseFloat(angle) / 360.0;
|
|
256 traf.m00 = Math.cos(t);
|
|
257 traf.m01 = - Math.sin(t);
|
|
258 traf.m10 = Math.sin(t);
|
|
259 traf.m11 = Math.cos(t);
|
|
260 traf.m02 = pos.x - pos.x * Math.cos(t) + pos.y * Math.sin(t);
|
|
261 traf.m12 = pos.y - pos.x * Math.sin(t) - pos.y * Math.cos(t);
|
|
262 }
|
|
263 return traf;
|
|
264 }
|
|
265 function getTranslation(pos) {
|
|
266 // returns a Transform that is a translation by [pos.x, pos,y]
|
|
267 var traf = new Transform();
|
|
268 traf.m02 = pos.x;
|
|
269 traf.m12 = pos.y;
|
|
270 return traf;
|
|
271 }
|
|
272 function getScale(size) {
|
|
273 // returns a Transform that is a scale by [size.width, size.height]
|
|
274 var traf = new Transform();
|
|
275 traf.m00 = size.width;
|
|
276 traf.m11 = size.height;
|
|
277 return traf;
|
|
278 }
|
|
279
|
|
280
|
|
281 /* **********************************************
|
|
282 * parameter routines
|
|
283 * ******************************************** */
|
407
|
284 dlParams = new Object();
|
398
|
285
|
|
286 function newParameter(name, defaultValue, detail) {
|
|
287 // create a new parameter with a name and a default value
|
|
288 if (!defined(dlParams[name])) dlParams[name] = new Object(); // no error condition
|
|
289 //alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!");
|
|
290 //return false;
|
|
291 dlParams[name].defaultValue = defaultValue;
|
|
292 dlParams[name].hasValue = false;
|
|
293 dlParams[name].value = defaultValue;
|
|
294 dlParams[name].detail = detail;
|
|
295 return dlParams[name];
|
|
296 }
|
|
297
|
412
|
298 function resetParameter(name) {
|
|
299 // resets the given parameter to its default value
|
|
300 if (!defined(dlParams[name])) {
|
|
301 alert("Could not reset non-existing parameter '" + name + "'");
|
|
302 return false;
|
|
303 }
|
|
304 dlParams[name].hasValue = false;
|
|
305 dlParams[name].value = defaultValue;
|
|
306 return dlParams[name];
|
|
307 }
|
|
308
|
|
309 function deleteParameter(name) {
|
|
310 // create a new parameter with a name and a default value
|
|
311 if (!defined(dlParams[name])) return false;
|
|
312 delete dlParams[name];
|
|
313 return true;
|
|
314 }
|
|
315
|
398
|
316 function getParameter(name) {
|
|
317 // returns the named parameter value or its default value
|
407
|
318 if (!defined(dlParams[name])) return null;
|
|
319 if (dlParams[name].hasValue)
|
412
|
320 return dlParams[name].value;
|
407
|
321 else
|
398
|
322 return dlParams[name].defaultValue;
|
|
323 }
|
|
324
|
|
325 function setParameter(name, value, relative) {
|
|
326 // sets parameter value (relative values with +/- unless literal)
|
412
|
327 if (!defined(dlParams[name])) return null;
|
|
328 var p = dlParams[name];
|
|
329 if (relative && value.slice) {
|
|
330 var sign = value.slice(0, 1);
|
|
331 if (sign == '+') {
|
|
332 p.value = parseFloat(p.value) + parseFloat(value.slice(1));
|
|
333 } else if (sign == '-') {
|
|
334 p.value = parseFloat(p.value) - parseFloat(value.slice(1));
|
|
335 } else {
|
|
336 p.value = value;
|
|
337 }
|
|
338 } else p.value = value;
|
|
339 p.hasValue = true;
|
|
340 return p.value;
|
|
341 }
|
398
|
342
|
|
343 function hasParameter(name) {
|
412
|
344 // returns if the parameter's value has been set
|
|
345 if (!defined(dlParams[name])) return null;
|
|
346 return dlParams[name].hasValue;
|
|
347 }
|
398
|
348
|
|
349 function getAllParameters(detail) {
|
|
350 // returns a string of all parameters in query format
|
|
351 if (! detail) {
|
|
352 detail = 255;
|
|
353 }
|
|
354 var params = new Array();
|
|
355 for (param in dlParams) {
|
|
356 if (((dlParams[param].detail & detail) > 0)&&(dlParams[param].hasValue)) {
|
|
357 var val = getParameter(param);
|
|
358 if (val != "") {
|
|
359 params.push(param + "=" + val);
|
|
360 }
|
|
361 }
|
|
362 }
|
|
363 return params.join("&");
|
|
364 }
|
|
365
|
|
366 function parseParameters(query) {
|
|
367 // gets parameter values from query format string
|
|
368 var params = query.split("&");
|
|
369 for (var i = 0; i < params.length; i++) {
|
|
370 var keyval = params[i].split("=");
|
|
371 if (keyval.length == 2) {
|
|
372 setParameter(keyval[0], keyval[1]);
|
|
373 }
|
|
374 }
|
|
375 }
|
|
376
|
407
|
377 getQueryString = getAllParameters;
|
398
|
378
|
|
379 /* **********************************************
|
|
380 * HTML/DOM routines
|
|
381 * ******************************************** */
|
|
382
|
|
383 function getElement(tagid, quiet) {
|
|
384 // returns the element object with the id tagid
|
|
385 var e;
|
|
386 if (document.getElementById) {
|
|
387 e = document.getElementById(tagid);
|
|
388 } else if (document.all) {
|
|
389 alert("document.all!");
|
|
390 e = document.all[tagid];
|
|
391 } else if (document.layers) {
|
|
392 e = document.layers[tagid];
|
|
393 }
|
|
394 if (e) {
|
|
395 return e;
|
|
396 } else {
|
|
397 if (! quiet) {
|
|
398 alert("unable to find element: "+tagid);
|
|
399 }
|
|
400 return null;
|
|
401 }
|
|
402 }
|
|
403
|
|
404 function getElementPosition(elem) {
|
|
405 // returns a Position with the position of the element
|
|
406 var x = 0;
|
|
407 var y = 0;
|
|
408 if (defined(elem.offsetLeft)) {
|
|
409 var e = elem;
|
|
410 while (e) {
|
|
411 if (defined(e.clientLeft)) {
|
|
412 // special for IE
|
|
413 if (browserType.isMac) {
|
|
414 if (e.offsetParent.tagName == "BODY") {
|
|
415 // IE for Mac extraspecial
|
|
416 x += e.clientLeft;
|
|
417 y += e.clientTop;
|
|
418 break;
|
|
419 }
|
|
420 } else {
|
|
421 if ((e.tagName != "TABLE") && (e.tagName != "BODY")) {
|
|
422 x += e.clientLeft;
|
|
423 y += e.clientTop;
|
|
424 }
|
|
425 }
|
|
426 }
|
|
427 x += e.offsetLeft;
|
|
428 y += e.offsetTop;
|
|
429 e = e.offsetParent;
|
|
430 }
|
|
431 } else if (defined(elem.x)) {
|
|
432 x = elem.x;
|
|
433 y = elem.y;
|
|
434 } else if (defined(elem.pageX)) {
|
|
435 x = elem.pageX;
|
|
436 y = elem.pageY;
|
|
437 } else {
|
|
438 alert("unable to get position of "+elem+" (id:"+elem.id+")");
|
|
439 }
|
|
440 return new Position(getInt(x), getInt(y));
|
|
441 }
|
|
442
|
|
443 function getElementSize(elem) {
|
|
444 // returns a Rectangle with the size of the element
|
|
445 var width = 0;
|
|
446 var height = 0;
|
|
447 if (defined(elem.offsetWidth)) {
|
|
448 width = elem.offsetWidth;
|
|
449 height = elem.offsetHeight;
|
|
450 } else if (defined(elem.width)) {
|
|
451 width = elem.width;
|
|
452 height = elem.height;
|
|
453 } else if (defined(elem.clip.width)) {
|
|
454 width = elem.clip.width;
|
|
455 height = elem.clip.height;
|
|
456 } else {
|
|
457 alert("unable to get size of "+elem+" (id:"+elem.id+")");
|
|
458 }
|
|
459 return new Size(getInt(width), getInt(height));
|
|
460 }
|
|
461
|
|
462 function getElementRect(elem) {
|
|
463 // returns a Rectangle with the size and position of the element
|
412
|
464 // FIX ME: what about borders?
|
398
|
465 var pos = getElementPosition(elem);
|
|
466 var size = getElementSize(elem);
|
|
467 return new Rectangle(pos.x, pos.y, size.width, size.height);
|
|
468 }
|
|
469
|
|
470
|
|
471
|
|
472 function moveElement(elem, rect) {
|
|
473 // moves and sizes the element
|
|
474 if (elem.style) {
|
|
475 if (defined(rect.x)) {
|
|
476 elem.style.left = Math.round(rect.x) + "px";
|
|
477 elem.style.top = Math.round(rect.y) + "px";
|
|
478 }
|
|
479 if (defined(rect.width)) {
|
|
480 elem.style.width = Math.round(rect.width) + "px";
|
|
481 elem.style.height = Math.round(rect.height) + "px";
|
|
482 }
|
|
483 } else if (document.layers) {
|
|
484 if (defined(rect.x)) {
|
|
485 elem.pageX = getInt(rect.x);
|
|
486 elem.pageY = getInt(rect.y);
|
|
487 }
|
|
488 if (defined(rect.width)) {
|
|
489 elem.clip.width = getInt(rect.width);
|
|
490 elem.clip.height = getInt(rect.height);
|
|
491 }
|
|
492 } else {
|
|
493 alert("moveelement: no style nor layer property!");
|
|
494 return false;
|
|
495 }
|
|
496 return true;
|
|
497 }
|
|
498
|
|
499 function showElement(elem, show) {
|
|
500 // shows or hides the element
|
|
501 if (elem.style) {
|
|
502 if (show) {
|
|
503 elem.style.visibility = "visible";
|
|
504 } else {
|
|
505 elem.style.visibility = "hidden";
|
|
506 }
|
|
507 } else if (defined(elem.visibility)) {
|
|
508 if (show) {
|
|
509 elem.visibility = "show";
|
|
510 } else {
|
|
511 elem.visibility = "hide";
|
|
512 }
|
|
513 } else {
|
|
514 alert("showelement: no style nor layer property!");
|
|
515 }
|
|
516 return true;
|
|
517 }
|
|
518
|
|
519 function evtPosition(evt) {
|
|
520 // returns the on-screen Position of the Event
|
|
521 var x;
|
|
522 var y;
|
|
523 evt = (evt) ? evt : window.event;
|
|
524 if (!evt) {
|
|
525 alert("no event found! "+evt);
|
|
526 return;
|
|
527 }
|
|
528 if (defined(evt.pageX)) {
|
|
529 x = parseInt(evt.pageX);
|
|
530 y = parseInt(evt.pageY);
|
|
531 } else if (defined(evt.clientX)) {
|
|
532 x = parseInt(document.body.scrollLeft+evt.clientX);
|
|
533 y = parseInt(document.body.scrollTop+evt.clientY);
|
|
534 } else {
|
|
535 alert("evtPosition: don't know how to deal with "+evt);
|
|
536 }
|
|
537 return new Position(x, y);
|
|
538 }
|
|
539
|
|
540 function registerEvent(type, elem, handler) {
|
412
|
541 // register the given event handler on the indicated element
|
|
542 if (elem.addEventListener) {
|
|
543 elem.addEventListener(type, handler, false); // bubble
|
|
544 }
|
|
545 else if (elem.attachEvent) {
|
|
546 elem.attachEvent("on" + type, handler);
|
|
547 }
|
|
548 else if (elem.captureEvents) {
|
|
549 if (Event) {
|
|
550 t = type.toUpperCase();
|
|
551 elem.captureEvents(Event[t]);
|
|
552 elem[ "on" + t ] = handler;
|
|
553 }
|
|
554 }
|
|
555 else {
|
|
556 alert("Could not register event of type " + type);
|
|
557 return false;
|
|
558 }
|
|
559 return true;
|
|
560 }
|
|
561
|
407
|
562 function unregisterEvent(type, elem, handler) {
|
412
|
563 // unregister the given event handler from the indicated element
|
|
564 if (elem.removeEventListener) {
|
|
565 elem.removeEventListener(type, handler, false);
|
|
566 }
|
|
567 else if (elem.detachEvent) {
|
|
568 elem.detachEvent('on' + type, handler);
|
|
569 }
|
|
570 else if (elem.releaseEvents) {
|
|
571 if (Event) {
|
|
572 t = type.toUpperCase();
|
|
573 elem.releaseEvents(Event[t]);
|
|
574 elem[ "on" + t ] = null;
|
|
575 }
|
|
576 }
|
|
577 else {
|
|
578 alert("Could not register event of type " + type);
|
|
579 return false;
|
|
580 }
|
|
581 return true;
|
398
|
582 }
|
|
583
|
407
|
584 function registerEventById(type, id, handler) {
|
412
|
585 registerEvent(type, document.getElementById(id), handler);
|
|
586 }
|
407
|
587
|
|
588 function unregisterEventById(type, id, handler) {
|
412
|
589 unregisterEvent(type, document.getElementById(id), handler);
|
|
590 }
|
407
|
591
|
|
592 function stopEvent(e) {
|
412
|
593 if (!e) var e = window.event;
|
|
594 e.cancelBubble = true;
|
|
595 if (e.stopPropagation) e.stopPropagation();
|
|
596 return false;
|
398
|
597 }
|
|
598
|
407
|
599 function getEventSrc(e) {
|
412
|
600 if (e.target) return e.target;
|
|
601 if (e.srcElement) return e.srcElement;
|
407
|
602 }
|
398
|
603
|
|
604 // old registerXXYY API for compatibility
|
|
605 function registerMouseDown(elem, handler) {
|
|
606 return registerEvent("mousedown", elem, handler);
|
|
607 }
|
|
608 function unregisterMouseDown(elem, handler) {
|
|
609 return unregisterEvent("mousedown", elem, handler);
|
|
610 }
|
|
611 function registerMouseMove(elem, handler) {
|
|
612 return registerEvent("mousemove", elem, handler);
|
|
613 }
|
|
614 function unregisterMouseMove(elem, handler) {
|
|
615 return unregisterEvent("mousemove", elem, handler);
|
|
616 }
|
|
617 function registerKeyDown(handler) {
|
|
618 return registerEvent("keypress", elem, handler);
|
|
619 }
|
|
620
|
|
621
|
|
622 function getWinSize() {
|
|
623 // returns a Size with the current window size (mostly from www.quirksmode.org)
|
|
624 var wsize = new Size(100, 100);
|
|
625 if (defined(self.innerHeight)) {
|
|
626 // all except Explorer
|
|
627 if ((self.innerWidth == 0)||(self.innerHeight == 0)) {
|
|
628 // Safari 1.2 bug
|
|
629 if (parent) {
|
|
630 parent.innerHeight;
|
|
631 parent.innerWidth;
|
|
632 }
|
|
633 }
|
|
634 wsize.width = self.innerWidth;
|
|
635 wsize.height = self.innerHeight;
|
|
636 } else if (document.documentElement && document.documentElement.clientHeight) {
|
|
637 // Explorer 6 Strict Mode
|
|
638 wsize.width = document.documentElement.clientWidth;
|
|
639 wsize.height = document.documentElement.clientHeight;
|
|
640 } else if (document.body) {
|
|
641 // other Explorers
|
|
642 wsize.width = document.body.clientWidth;
|
|
643 wsize.height = document.body.clientHeight;
|
|
644 }
|
|
645 return wsize;
|
|
646 }
|
|
647
|
|
648 function openWin(url, name, params) {
|
|
649 // open browser window
|
|
650 var ow = window.open(url, name, params);
|
|
651 ow.focus();
|
|
652 }
|