Mercurial > hg > digilib-old
annotate client/digitallibrary/navigation.js @ 199:21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
author | robcast |
---|---|
date | Wed, 14 Jan 2004 12:06:53 +0100 |
parents | 28f96364040f |
children | 7349d58cd391 |
rev | line source |
---|---|
133 | 1 /* |
2 | |
3 Copyright (C) 2003 WTWG, Uni Bern | |
4 | |
5 This program is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU General Public License | |
7 as published by the Free Software Foundation; either version 2 | |
8 of the License, or (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software | |
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
18 | |
19 Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.4 | |
20 | |
21 */ | |
22 | |
23 var ZOOMFACTOR = Math.sqrt(2); | |
24 | |
25 dlParams = new Object(); | |
26 | |
27 function newParameter(name, value, defaultValue, detail) { | |
28 | |
29 if ( !dlParams[name] ) { | |
30 | |
31 dlParams[name] = new Object(); | |
32 | |
33 dlParams[name].value = value; | |
34 dlParams[name].defaultValue = defaultValue; | |
35 dlParams[name].detail = detail; | |
36 | |
37 return dlParams[name]; | |
38 | |
39 } else { | |
40 | |
41 alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!"); | |
42 return false; | |
43 | |
44 } | |
45 } | |
46 | |
47 function getParameter(name) { | |
48 | |
49 if ( dlParams[name] ) { | |
50 return dlParams[name].value; | |
51 } else { | |
52 return false; | |
53 } | |
54 } | |
55 | |
56 | |
57 | |
58 function listParametersAsString() { | |
59 | |
60 var params = new Array(); | |
61 | |
62 for ( param in dlParams ) { | |
63 params.push(param); | |
64 } | |
65 | |
66 return params.join(","); | |
67 | |
68 } | |
69 | |
70 | |
71 function listParameters() { | |
72 | |
73 var params = new Array(); | |
74 | |
75 for ( param in dlParams ) { | |
76 params.push(param); | |
77 } | |
78 | |
79 return params; | |
80 | |
81 } | |
82 | |
83 | |
84 function init() { | |
85 | |
86 // give a name to the window containing digilib - this way one can test if there is already a | |
87 // digilib-window open and replace the contents of it (ex. digicat) | |
88 top.window.name = "digilib"; | |
89 | |
90 placeMarks(); | |
91 | |
92 if ( document.all ) { | |
93 this.document.onkeypress = parseKeypress; | |
94 } else if ( typeof(document.addEventListener) == "function" ) { | |
95 this.document.addEventListener('keypress', parseKeypress, true); | |
96 } else { | |
97 window.captureEvents(Event.KEYDOWN); | |
98 window.onkeydown = parseKeypress; | |
99 } | |
100 | |
101 focus(); | |
102 } | |
103 | |
104 | |
105 function display(detail) { | |
106 | |
107 var queryString = ''; | |
108 | |
109 for ( param in dlParams ) { | |
110 | |
111 if ( dlParams[param].defaultValue != dlParams[param].value ) { | |
112 if ( dlParams[param].detail <= detail ) { | |
113 queryString += "&" + param + "=" + dlParams[param].value; | |
114 } else { | |
115 queryString += "&" + param + "=" + dlParams[param].defaultValue; | |
116 } | |
117 } | |
118 | |
119 } | |
120 | |
199
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
121 // window size |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
122 var wwidth, wheight; |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
123 if (self.innerHeight) // all except Explorer |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
124 { |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
125 wwidth = self.innerWidth; |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
126 wheight = self.innerHeight; |
133 | 127 } |
199
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
128 else if (document.documentElement && document.documentElement.clientHeight) |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
129 // Explorer 6 Strict Mode |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
130 { |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
131 wwidth = document.documentElement.clientWidth; |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
132 wheight = document.documentElement.clientHeight; |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
133 } |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
134 else if (document.body) // other Explorers |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
135 { |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
136 wwidth = document.body.clientWidth; |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
137 wheight = document.body.clientHeight; |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
138 } |
21789f3f7251
Corrected Problems with innerWidth and about:blank for Safari.
robcast
parents:
133
diff
changeset
|
139 queryString += "&dw=" + (wwidth-30) + "&dh=" + (wheight-30); |
133 | 140 |
141 queryString += "&lv=1"; | |
142 | |
143 queryString = queryString.slice(1); | |
144 | |
145 location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString; | |
146 | |
147 } | |
148 | |
149 | |
150 // constructor holding different values of a point | |
151 function Point(evt) { | |
152 | |
153 if ( document.all ) { | |
154 | |
155 this.pageX = parseInt(document.body.scrollLeft+event.clientX); | |
156 this.pageY = parseInt(document.body.scrollLeft+event.clientY); | |
157 | |
158 this.x = this.pageX-parseInt(document.all.lay1.style.left); | |
159 this.y = this.pageY-parseInt(document.all.lay1.style.top); | |
160 | |
161 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.lay1.offsetWidth)); | |
162 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.all.lay1.offsetHeight)); | |
163 | |
164 } else { | |
165 | |
166 this.pageX = parseInt(evt.pageX); | |
167 this.pageY = parseInt(evt.pageY); | |
168 | |
169 if ( typeof(document.getElementById) == "function" ) { | |
170 | |
171 this.x = this.pageX-parseInt(document.getElementById("lay1").style.left); | |
172 this.y = this.pageY-parseInt(document.getElementById("lay1").style.top); | |
173 | |
174 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth)); | |
175 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.pic.offsetHeight)); | |
176 | |
177 } else { | |
178 | |
179 this.x = this.pageX-document.lay1.left; | |
180 this.y = this.pageY-document.lay1.top; | |
181 | |
182 this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.lay1.clip.width)); | |
183 this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.lay1.clip.height)); | |
184 | |
185 } | |
186 | |
187 } | |
188 | |
189 return this; | |
190 | |
191 } | |
192 | |
193 | |
194 function page(page, details) { | |
195 | |
196 if ( details == null ) { | |
197 details = 1; | |
198 } | |
199 | |
200 if ( page.indexOf('-') == 0 ) { | |
201 if ( dlParams.pn.value > 1 ) { | |
202 page = Math.max(parseInt(dlParams.pn.value) - parseInt(page.slice(1)), 1); | |
203 dlParams.pn.value = page; | |
204 display(details); | |
205 } else { | |
206 alert("You are already on the first page!"); | |
207 } | |
208 | |
209 } else if ( page.indexOf('+') == 0 ) { | |
210 page = parseInt(dlParams.pn.value) + parseInt(page.slice(1)); | |
211 dlParams.pn.value = page; | |
212 display(details); | |
213 } else if ( page == parseInt(page) ) { | |
214 dlParams.pn.value = parseInt(page); | |
215 display(details); | |
216 } | |
217 | |
218 } | |
219 | |
220 | |
221 function digicat() { | |
222 | |
223 var url = baseUrl + "/digicat.jsp?" + dlParams.fn.value + "+" + dlParams.pn.value; | |
224 win = window.open(url, "digicat"); | |
225 win.focus(); | |
226 | |
227 } | |
228 | |
229 | |
230 function ref(select) { | |
231 | |
232 var hyperlinkRef = baseUrl + "/digilib.jsp?"; | |
233 hyperlinkRef += dlParams.fn.value + "+" + dlParams.pn.value + "+" + dlParams.ws.value + "+"; | |
234 hyperlinkRef += dlParams.mo.value + "+" + dlParams.mk.value; | |
235 | |
236 if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) { | |
237 hyperlinkRef += "+" + dlParams.wx.value + "+" + dlParams.wy.value + "+" + dlParams.ww.value; | |
238 hyperlinkRef += "+" + dlParams.wh.value; | |
239 } | |
240 | |
241 if ( select == 0 ) { | |
242 prompt("Link for LaTeX-documents", "\\href{" + hyperlinkRef + "}{TEXT}"); | |
243 } else if ( select == 1 ) { | |
244 prompt("Link for HTML-documents", hyperlinkRef); | |
245 } | |
246 } | |
247 | |
248 | |
249 function mark() { | |
250 | |
251 if ( dlParams.mk.value.split(";").length > 7 ) { | |
252 alert("Only 8 marks are possible at the moment!"); | |
253 return; | |
254 } | |
255 | |
256 function markEvent(evt) { | |
257 | |
258 var point = new Point(evt); | |
259 | |
260 if ( dlParams.mk.value != '' ) { | |
261 dlParams.mk.value += ';'; | |
262 } | |
263 | |
264 dlParams.mk.value += point.relX + '/' + point.relY; | |
265 | |
266 // stopping event capture | |
267 if ( document.all ) { | |
268 document.all.lay1.onmousedown = null; | |
269 } else if ( typeof(document.removeEventListener) == "function" ) { | |
270 document.getElementById("lay1").removeEventListener("mousedown", markEvent, true); | |
271 } else { | |
272 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
273 } | |
274 | |
275 placeMarks(); | |
276 | |
277 } | |
278 | |
279 // starting event capture | |
280 if ( document.all ) { | |
281 document.all.lay1.onmousedown = markEvent; | |
282 } else if ( typeof(document.addEventListener) == "function" ) { | |
283 document.getElementById("lay1").addEventListener("mousedown", markEvent, true); | |
284 } else { | |
285 document.lay1.captureEvents(Event.MOUSEDOWN); | |
286 document.lay1.onmousedown = markEvent; | |
287 } | |
288 } | |
289 | |
290 | |
291 function placeMarks() { | |
292 | |
293 if ( dlParams.mk.value != '' ) { | |
294 | |
295 var mark = dlParams.mk.value.split(";"); | |
296 var mark_count = mark.length; | |
297 | |
298 // maximum of marks is 8 | |
299 // we do not report this error because this is already done in function 'mark' | |
300 if ( mark_count > 8 ) mark_count = 8; | |
301 | |
302 var picWidth = (document.all) ? parseInt(document.all.lay1.offsetWidth) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetWidth) : parseInt(document.pic.clip.width); | |
303 var picHeight = (document.all) ? parseInt(document.all.lay1.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.pic.clip.height); | |
304 | |
305 // catch the cases where the picture had not been loaded already and | |
306 // make a timeout so that the coordinates are calculated with the real dimensions | |
307 if ( (document.pic.complete) || (picWidth > 30) ) { | |
308 | |
309 var xOffset = (document.all) ? parseInt(document.all.lay1.style.left) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.left) : document.lay1.left; | |
310 var yOffset = (document.all) ? parseInt(document.all.lay1.style.top) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('lay1').style.top) : document.lay1.top; | |
311 | |
312 for (var i = 0; i < mark_count; i++) { | |
313 mark[i] = mark[i].split("/"); | |
314 | |
315 if ( (mark[i][0] >= dlParams.wx.value) && (mark[i][1] >= dlParams.wy.value) && (mark[i][0] <= (parseFloat(dlParams.wx.value) + parseFloat(dlParams.ww.value))) && (mark[i][1] <= (parseFloat(dlParams.wy.value) + parseFloat(dlParams.wh.value))) ) { | |
316 | |
317 mark[i][0] = parseInt(xOffset + picWidth * (mark[i][0] - dlParams.wx.value)/dlParams.ww.value); | |
318 mark[i][1] = parseInt(yOffset + picHeight * (mark[i][1] - dlParams.wy.value)/dlParams.wh.value); | |
319 | |
320 if ( (document.all) || (typeof(document.getElementById) == "function") ) { | |
321 // suboptimal to place -5 pixels and not half size of mark-image | |
322 // should be changed in the future | |
323 document.getElementById("dot" + i).style.left = mark[i][0]-5; | |
324 document.getElementById("dot" + i).style.top = mark[i][1]-5; | |
325 document.getElementById("dot" + i).style.visibility = "visible"; | |
326 } else { | |
327 document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5); | |
328 document.layers[i+1].visibility = "show"; | |
329 } | |
330 } | |
331 } | |
332 | |
333 } else { | |
334 setTimeout("placeMarks()", 100); | |
335 } | |
336 } | |
337 } | |
338 | |
339 | |
340 function zoomPoint() { | |
341 | |
342 function zoomPointEvent(evt) { | |
343 | |
344 var point = new Point(evt); | |
345 | |
346 dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value*(1/ZOOMFACTOR)); | |
347 dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value*(1/ZOOMFACTOR)); | |
348 | |
349 dlParams.ww.value = cropFloat(dlParams.ww.value*(1/ZOOMFACTOR)); | |
350 dlParams.wh.value = cropFloat(dlParams.wh.value*(1/ZOOMFACTOR)); | |
351 | |
352 if ( dlParams.wx.value < 0 ) { | |
353 dlParams.wx.value = 0; | |
354 } | |
355 if ( dlParams.wy.value < 0 ) { | |
356 dlParams.wy.value = 0; | |
357 } | |
358 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
359 dlParams.wx.value = 1 - dlParams.ww.value; | |
360 } | |
361 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
362 dlParams.wy.value = 1 - dlParams.wh.value; | |
363 } | |
364 | |
365 // stopping event capture | |
366 if ( document.all ) { | |
367 document.all.lay1.onmousedown = null; | |
368 } else if ( typeof(document.removeEventListener) == "function" ) { | |
369 document.getElementById("lay1").removeEventListener("mousedown", zoomPointEvent, true); | |
370 } else { | |
371 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
372 } | |
373 | |
374 display(3); | |
375 } | |
376 | |
377 // starting event capture | |
378 if ( document.all ) { | |
379 document.all.lay1.onmousedown = zoomPointEvent; | |
380 } else if ( typeof(document.addEventListener) == "function" ) { | |
381 document.getElementById("lay1").addEventListener("mousedown", zoomPointEvent, true); | |
382 } else { | |
383 document.lay1.captureEvents(Event.MOUSEDOWN); | |
384 document.lay1.onmousedown = zoomPointEvent; | |
385 } | |
386 } | |
387 | |
388 | |
389 function zoomArea() { | |
390 var state = 0; | |
391 var pt1, pt2; | |
392 | |
393 function click(evt) { | |
394 | |
395 if (state == 0) { | |
396 state = 1; | |
397 | |
398 pt1 = new Point(evt); | |
399 pt2 = pt1; | |
400 | |
401 if ( document.all ) { | |
402 | |
403 document.all.eck1.style.left = pt1.pageX; | |
404 document.all.eck1.style.top = pt1.pageY; | |
405 document.all.eck2.style.left = pt2.pageX-12; | |
406 document.all.eck2.style.top = pt1.pageY; | |
407 document.all.eck3.style.left = pt1.pageX; | |
408 document.all.eck3.style.top = pt2.pageY-12; | |
409 document.all.eck4.style.left = pt2.pageX-12; | |
410 document.all.eck4.style.top = pt2.pageY-12; | |
411 | |
412 document.all.eck1.style.visibility="visible"; | |
413 document.all.eck2.style.visibility="visible"; | |
414 document.all.eck3.style.visibility="visible"; | |
415 document.all.eck4.style.visibility="visible"; | |
416 | |
417 document.all.lay1.onmousemove = move; | |
418 document.all.eck4.onmousemove = move; | |
419 | |
420 } else if ( typeof(document.addEventListener) == "function" ) { | |
421 | |
422 document.getElementById("eck1").style.left = pt1.pageX; | |
423 document.getElementById("eck1").style.top = pt1.pageY; | |
424 document.getElementById("eck2").style.left = pt2.pageX-12; | |
425 document.getElementById("eck2").style.top = pt1.pageY; | |
426 document.getElementById("eck3").style.left = pt1.pageX; | |
427 document.getElementById("eck3").style.top = pt2.pageY-12; | |
428 document.getElementById("eck4").style.left = pt2.pageX-12; | |
429 document.getElementById("eck4").style.top = pt2.pageY-12; | |
430 | |
431 document.getElementById("eck1").style.visibility="visible"; | |
432 document.getElementById("eck2").style.visibility="visible"; | |
433 document.getElementById("eck3").style.visibility="visible"; | |
434 document.getElementById("eck4").style.visibility="visible"; | |
435 | |
436 document.getElementById("lay1").addEventListener("mousemove", move, true); | |
437 document.getElementById("eck4").addEventListener("mousemove", move, true); | |
438 | |
439 } else { | |
440 | |
441 document.eck1.moveTo(pt1.pageX, pt1.pageY); | |
442 document.eck2.moveTo(pt2.pageX-12, pt1.pageY); | |
443 document.eck3.moveTo(pt1.pageX, pt2.pageY-12); | |
444 document.eck4.moveTo(pt2.pageX-12, pt2.pageY-12); | |
445 | |
446 document.eck1.visibility="show"; | |
447 document.eck2.visibility="show"; | |
448 document.eck3.visibility="show"; | |
449 document.eck4.visibility="show"; | |
450 | |
451 document.lay1.captureEvents(Event.MOUSEMOVE); | |
452 document.eck4.captureEvents(Event.MOUSEMOVE); | |
453 document.lay1.onmousemove = move; | |
454 document.eck4.onmousemove = move; | |
455 | |
456 } | |
457 | |
458 } else { | |
459 | |
460 pt2 = new Point(evt); | |
461 | |
462 if ( document.all ) { | |
463 | |
464 document.all.eck1.visibility="hidden"; | |
465 document.all.eck2.visibility="hidden"; | |
466 document.all.eck3.visibility="hidden"; | |
467 document.all.eck4.visibility="hidden"; | |
468 | |
469 document.all.lay1.onmousedown = null; | |
470 document.all.eck4.onmousedown = null; | |
471 document.all.lay1.onmousemove = null; | |
472 document.all.eck4.onmousemove = null; | |
473 | |
474 } else if ( typeof(document.removeEventListener) == "function" ) { | |
475 | |
476 document.getElementById("eck1").style.visibility="hidden"; | |
477 document.getElementById("eck2").style.visibility="hidden"; | |
478 document.getElementById("eck3").style.visibility="hidden"; | |
479 document.getElementById("eck4").style.visibility="hidden"; | |
480 | |
481 document.getElementById("lay1").removeEventListener("mousedown", click, true); | |
482 document.getElementById("eck4").removeEventListener("mousedown", click, true); | |
483 document.getElementById("lay1").removeEventListener("mousemove", move, true); | |
484 document.getElementById("eck4").removeEventListener("mousemove", move, true); | |
485 | |
486 } else { | |
487 | |
488 document.eck1.visibility="hide"; | |
489 document.eck2.visibility="hide"; | |
490 document.eck3.visibility="hide"; | |
491 document.eck4.visibility="hide"; | |
492 | |
493 document.lay1.releaseEvents(Event.MOUSEDOWN); | |
494 document.eck4.releaseEvents(Event.MOUSEDOWN); | |
495 document.lay1.releaseEvents(Event.MOUSEMOVE); | |
496 document.eck4.releaseEvents(Event.MOUSEMOVE); | |
497 | |
498 } | |
499 | |
500 dlParams.wx.value = cropFloat(parseFloat(Math.min(pt1.relX, pt2.relX))); | |
501 dlParams.wy.value = cropFloat(parseFloat(Math.min(pt1.relY, pt2.relY))); | |
502 | |
503 dlParams.ww.value = cropFloat(parseFloat(Math.abs(pt1.relX-pt2.relX))); | |
504 dlParams.wh.value = cropFloat(parseFloat(Math.abs(pt1.relY-pt2.relY))); | |
505 | |
506 if ( (dlParams.ww.value != 0) && (dlParams.wh.value != 0) ) { | |
507 display(3); | |
508 } | |
509 } | |
510 } | |
511 | |
512 function move(evt) { | |
513 | |
514 pt2 = new Point(evt); | |
515 | |
516 var eck1_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); | |
517 var eck1_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); | |
518 var eck2_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;; | |
519 var eck2_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY); | |
520 var eck3_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX); | |
521 var eck3_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; | |
522 var eck4_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12; | |
523 var eck4_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12; | |
524 | |
525 if ( document.all ) { | |
526 | |
527 document.all.eck1.style.left = eck1_left; | |
528 document.all.eck1.style.top = eck1_top; | |
529 document.all.eck2.style.left = eck2_left; | |
530 document.all.eck2.style.top = eck2_top; | |
531 document.all.eck3.style.left = eck3_left; | |
532 document.all.eck3.style.top = eck3_top; | |
533 document.all.eck4.style.left = eck4_left; | |
534 document.all.eck4.style.top = eck4_top; | |
535 | |
536 } else if ( typeof(document.getElementById) == "function" ) { | |
537 | |
538 document.getElementById("eck1").style.left = eck1_left; | |
539 document.getElementById("eck1").style.top = eck1_top; | |
540 document.getElementById("eck2").style.left = eck2_left; | |
541 document.getElementById("eck2").style.top = eck2_top; | |
542 document.getElementById("eck3").style.left = eck3_left; | |
543 document.getElementById("eck3").style.top = eck3_top; | |
544 document.getElementById("eck4").style.left = eck4_left; | |
545 document.getElementById("eck4").style.top = eck4_top; | |
546 | |
547 } else { | |
548 | |
549 document.eck1.moveTo(eck1_left, eck1_top); | |
550 document.eck2.moveTo(eck2_left, eck2_top); | |
551 document.eck3.moveTo(eck3_left, eck3_top); | |
552 document.eck4.moveTo(eck4_left, eck4_top); | |
553 | |
554 } | |
555 } | |
556 | |
557 // starting event capture | |
558 if ( document.all ) { | |
559 document.all.lay1.onmousedown = click; | |
560 document.all.eck4.onmousedown = click; | |
561 } else if ( typeof(document.addEventListener) == "function" ) { | |
562 document.getElementById("lay1").addEventListener("mousedown", click, true); | |
563 document.getElementById("eck4").addEventListener("mousedown", click, true); | |
564 } else { | |
565 document.lay1.captureEvents(Event.MOUSEDOWN); | |
566 document.eck4.captureEvents(Event.MOUSEDOWN); | |
567 document.lay1.onmousedown = click; | |
568 document.eck4.onmousedown = click; | |
569 } | |
570 } | |
571 | |
572 | |
573 function zoomExtends() { | |
574 | |
575 dlParams.wx.value = 0.0; | |
576 dlParams.wy.value = 0.0; | |
577 | |
578 dlParams.ww.value = 1.0; | |
579 dlParams.wh.value = 1.0; | |
580 | |
581 display(3); | |
582 | |
583 } | |
584 | |
585 | |
586 function zoomOut() { | |
587 | |
588 dlParams.wx.value = cropFloat(dlParams.wx.value-0.5*(dlParams.ww.value*(ZOOMFACTOR)-dlParams.ww.value)); | |
589 dlParams.wy.value = cropFloat(dlParams.wy.value-0.5*(dlParams.wh.value*(ZOOMFACTOR)-dlParams.wh.value)); | |
590 | |
591 dlParams.ww.value = cropFloat(dlParams.ww.value*(ZOOMFACTOR)); | |
592 dlParams.wh.value = cropFloat(dlParams.wh.value*(ZOOMFACTOR)); | |
593 | |
594 if ( dlParams.wx.value < 0 ) { | |
595 dlParams.wx.value = 0; | |
596 } | |
597 if ( dlParams.wy.value < 0 ) { | |
598 dlParams.wy.value = 0; | |
599 } | |
600 if ( dlParams.ww.value > 1 ) { | |
601 dlParams.ww.value = 1; | |
602 } | |
603 if ( dlParams.wh.value > 1 ) { | |
604 dlParams.wh.value = 1; | |
605 } | |
606 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
607 dlParams.wx.value = 1 - dlParams.ww.value; | |
608 } | |
609 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
610 dlParams.wy.value = 1 - dlParams.wh.value; | |
611 } | |
612 | |
613 display(3); | |
614 } | |
615 | |
616 | |
617 function moveTo() { | |
618 | |
619 if ( (parseFloat(dlParams.ww.value) == 1.0) && (parseFloat(dlParams.wh.value) == 1.0) ) { | |
620 alert("This function is only available when zoomed in!"); | |
621 return; | |
622 } | |
623 | |
624 function moveToEvent(event) { | |
625 | |
626 var point = new Point(event); | |
627 | |
628 dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value); | |
629 dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value); | |
630 | |
631 if ( dlParams.wx.value < 0 ) { | |
632 dlParams.wx.value = 0; | |
633 } | |
634 if ( dlParams.wy.value < 0 ) { | |
635 dlParams.wy.value = 0; | |
636 } | |
637 if ( dlParams.wx.value + dlParams.ww.value > 1 ) { | |
638 dlParams.wx.value = 1 - dlParams.ww.value; | |
639 } | |
640 if ( dlParams.wy.value + dlParams.wh.value > 1 ) { | |
641 dlParams.wy.value = 1 - dlParams.wh.value; | |
642 } | |
643 | |
644 // stopping event capture | |
645 if ( document.all ) { | |
646 document.all.lay1.onmousedown = null; | |
647 } else if ( typeof(document.removeEventListener) == "function" ) { | |
648 document.getElementById("lay1").removeEventListener("mousedown", moveToEvent, true); | |
649 } else { | |
650 document.lay1.releaseEvents(Event.MOUSEDOWN) | |
651 } | |
652 | |
653 display(3); | |
654 } | |
655 | |
656 // starting event capture | |
657 if ( document.all ) { | |
658 document.all.lay1.onmousedown = moveToEvent; | |
659 } else if ( typeof(document.addEventListener) == "function" ) { | |
660 document.getElementById("lay1").addEventListener("mousedown", moveToEvent, true); | |
661 } else { | |
662 document.lay1.captureEvents(Event.MOUSEDOWN); | |
663 document.lay1.onmousedown = moveToEvent; | |
664 } | |
665 } | |
666 | |
667 | |
668 function scale(factor) { | |
669 | |
670 dlParams.ws.value = cropFloat(factor); | |
671 display(3); | |
672 | |
673 } | |
674 | |
675 | |
676 // capturing keypresses for next and previous page | |
677 function parseKeypress(evt) { | |
678 | |
679 if ( document.all ) { | |
680 | |
681 if ( event.keyCode == 110 ) { | |
682 page('+1'); | |
683 } | |
684 if ( event.keyCode == 98 ) { | |
685 page('-1'); | |
686 } | |
687 | |
688 document.cancleBubble = true; | |
689 | |
690 } else { | |
691 | |
692 if ( evt.charCode == 110 ) { | |
693 page('+1'); | |
694 } else if ( evt.charCode == 98 ) { | |
695 page('-1'); | |
696 } else if ( evt.which == 110 ) { | |
697 page('+1'); | |
698 } else if ( evt.which == 98 ) { | |
699 // does not work currentlyfor Opera, because it catches the 'b'-key on it's own | |
700 // have to change the key or find another way - luginbuehl | |
701 page('-1'); | |
702 } | |
703 | |
704 } | |
705 } | |
706 | |
707 | |
708 // auxiliary function to crop senseless precicsion | |
709 function cropFloat(tmp) { | |
710 return parseInt(10000*tmp)/10000; | |
711 } |