Annotation of zogiLib/js/navigation.js, revision 1.1
1.1 ! dwinter 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: Changed for digiLib in Zope by DW 24.03.2004
! 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:
! 91: placeMarks();
! 92:
! 93: if ( document.all ) {
! 94: this.document.onkeypress = parseKeypress;
! 95: } else if ( typeof(document.addEventListener) == "function" ) {
! 96: this.document.addEventListener('keypress', parseKeypress, true);
! 97: } else {
! 98: window.captureEvents(Event.KEYDOWN);
! 99: window.onkeydown = parseKeypress;
! 100: }
! 101:
! 102: focus();
! 103: }
! 104:
! 105:
! 106: function display(detail) {
! 107:
! 108: var queryString = '';
! 109:
! 110: for ( param in dlParams ) {
! 111:
! 112: if ( dlParams[param].defaultValue != dlParams[param].value ) {
! 113: if ( dlParams[param].detail <= detail ) {
! 114: queryString += "&" + param + "=" + dlParams[param].value;
! 115: } else {
! 116: queryString += "&" + param + "=" + dlParams[param].defaultValue;
! 117: }
! 118: }
! 119:
! 120: }
! 121:
! 122: // window size
! 123: var wwidth, wheight;
! 124: if (self.innerHeight) // all except Explorer
! 125: {
! 126: wwidth = self.innerWidth;
! 127: wheight = self.innerHeight;
! 128: }
! 129: else if (document.documentElement && document.documentElement.clientHeight)
! 130: // Explorer 6 Strict Mode
! 131: {
! 132: wwidth = document.documentElement.clientWidth;
! 133: wheight = document.documentElement.clientHeight;
! 134: }
! 135: else if (document.body) // other Explorers
! 136: {
! 137: wwidth = document.body.clientWidth;
! 138: wheight = document.body.clientHeight;
! 139: }
! 140: //queryString += "&dw=" + (wwidth-30) + "&dh=" + (wheight-30); # not needed DW
! 141:
! 142: queryString += "&lv=1";
! 143:
! 144: queryString = queryString.slice(1);
! 145:
! 146: location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString;
! 147:
! 148: }
! 149:
! 150:
! 151: // constructor holding different values of a point
! 152: function Point(evt) {
! 153:
! 154: if ( document.all ) {
! 155:
! 156: this.pageX = parseInt(document.body.scrollLeft+event.clientX);
! 157: this.pageY = parseInt(document.body.scrollLeft+event.clientY);
! 158:
! 159: this.x = this.pageX-parseInt(document.all.scaler.offsetLeft);
! 160: this.y = this.pageY-parseInt(document.all.scaler.offsetTop);
! 161:
! 162: this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.all.scaler.offsetWidth));
! 163: this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.all.scaler.offsetHeight));
! 164:
! 165: } else {
! 166:
! 167: this.pageX = parseInt(evt.pageX);
! 168: this.pageY = parseInt(evt.pageY);
! 169:
! 170: if ( typeof(document.getElementById) == "function" ) {
! 171:
! 172: this.x = this.pageX-parseInt(document.getElementById("scaler").offsetLeft);
! 173: this.y = this.pageY-parseInt(document.getElementById("scaler").offsetTop);
! 174: // top("2"+"::"+this.pageX+"::"+parseInt(document.getElementById("scaler").offsetLeft)+'::'+document.getElementById("scaler").offsetLeft);
! 175: this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.pic.offsetWidth));
! 176: this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.pic.offsetHeight));
! 177:
! 178: } else {
! 179:
! 180: this.x = this.pageX-document.scaler.left;
! 181: this.y = this.pageY-document.scaler.top;
! 182:
! 183: this.relX = cropFloat(parseFloat(dlParams.wx.value)+(dlParams.ww.value*this.x/document.scaler.clip.width));
! 184: this.relY = cropFloat(parseFloat(dlParams.wy.value)+(dlParams.wh.value*this.y/document.scaler.clip.height));
! 185:
! 186: }
! 187:
! 188: }
! 189:
! 190: return this;
! 191:
! 192: }
! 193:
! 194:
! 195: function page(page, details) {
! 196:
! 197: if ( details == null ) {
! 198: details = 1;
! 199: }
! 200:
! 201: if ( page.indexOf('-') == 0 ) {
! 202: if ( dlParams.pn.value > 1 ) {
! 203: page = Math.max(parseInt(dlParams.pn.value) - parseInt(page.slice(1)), 1);
! 204: dlParams.pn.value = page;
! 205: display(details);
! 206: } else {
! 207: alert("You are already on the first page!");
! 208: }
! 209:
! 210: } else if ( page.indexOf('+') == 0 ) {
! 211: page = parseInt(dlParams.pn.value) + parseInt(page.slice(1));
! 212: dlParams.pn.value = page;
! 213: display(details);
! 214: } else if ( page == parseInt(page) ) {
! 215: dlParams.pn.value = parseInt(page);
! 216: display(details);
! 217: }
! 218:
! 219: }
! 220:
! 221:
! 222: function digicat() {
! 223:
! 224: var url = baseUrl + "/digicat.jsp?" + dlParams.fn.value + "+" + dlParams.pn.value;
! 225: win = window.open(url, "digicat");
! 226: win.focus();
! 227:
! 228: }
! 229:
! 230:
! 231: function ref(select) {
! 232:
! 233: var hyperlinkRef = baseUrl + "?";
! 234: hyperlinkRef += "fn="+dlParams.fn.value + "&pn=" + dlParams.pn.value + "&ws=" + dlParams.ws.value + "&mo=";
! 235: hyperlinkRef += dlParams.mo.value + "&mk=" + dlParams.mk.value;
! 236:
! 237: if ( (dlParams.wx.value != 0) || (dlParams.wy.value != 0) || (dlParams.ww.value != 1) || (dlParams.wh.value != 1) ) {
! 238: hyperlinkRef += "&wx=" + dlParams.wx.value + "&wy=" + dlParams.wy.value + "&ww=" + dlParams.ww.value;
! 239: hyperlinkRef += "&wh=" + dlParams.wh.value;
! 240: }
! 241:
! 242: if ( select == 0 ) {
! 243: prompt("Link for LaTeX-documents", "\\href{" + hyperlinkRef + "}{TEXT}");
! 244: } else if ( select == 1 ) {
! 245: prompt("Link for HTML-documents", hyperlinkRef);
! 246: }
! 247: }
! 248:
! 249:
! 250: function mark() {
! 251:
! 252: if ( dlParams.mk.value.split(";").length > 7 ) {
! 253: alert("Only 8 marks are possible at the moment!");
! 254: return;
! 255: }
! 256:
! 257: function markEvent(evt) {
! 258:
! 259: var point = new Point(evt);
! 260:
! 261: if ( dlParams.mk.value != '' ) {
! 262: dlParams.mk.value += ';';
! 263: }
! 264:
! 265: dlParams.mk.value += point.relX + '/' + point.relY;
! 266:
! 267: // stopping event capture
! 268: if ( document.all ) {
! 269: document.all.scaler.onmousedown = null;
! 270: } else if ( typeof(document.removeEventListener) == "function" ) {
! 271: document.getElementById("scaler").removeEventListener("mousedown", markEvent, true);
! 272: } else {
! 273: document.scaler.releaseEvents(Event.MOUSEDOWN);
! 274: }
! 275:
! 276: placeMarks();
! 277:
! 278: }
! 279:
! 280: // starting event capture
! 281: if ( document.all ) {
! 282: document.all.scaler.onmousedown = markEvent;
! 283: } else if ( typeof(document.addEventListener) == "function" ) {
! 284: document.getElementById("scaler").addEventListener("mousedown", markEvent, true);
! 285: } else {
! 286: document.scaler.captureEvents(Event.MOUSEDOWN);
! 287: document.scaler.onmousedown = markEvent;
! 288: }
! 289: }
! 290:
! 291:
! 292: function placeMarks() {
! 293:
! 294: if ( dlParams.mk.value != '' ) {
! 295:
! 296: var mark = dlParams.mk.value.split(";");
! 297: var mark_count = mark.length;
! 298:
! 299: // maximum of marks is 8
! 300: // we do not report this error because this is already done in function 'mark'
! 301: if ( mark_count > 8 ) mark_count = 8;
! 302:
! 303: var picWidth = (document.all) ? parseInt(document.all.scaler.offsetWidth) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetWidth) : parseInt(document.pic.clip.width);
! 304: var picHeight = (document.all) ? parseInt(document.all.scaler.offsetHeight) : (typeof(document.getElementById) == "function") ? parseInt(document.pic.offsetHeight) : parseInt(document.pic.clip.height);
! 305:
! 306: // catch the s where the picture had not been loaded already and
! 307: // make a timeout so that the coordinates are calculated with the real dimensions
! 308: //if ( (document.pic.complete) || (picWidth > 30) ) {
! 309: if ( (picWidth > 30) ) {
! 310:
! 311: var xOffset = (document.all) ? parseInt(document.all.scaler.offsetLeft) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('scaler').offsetLeft) : document.scaler.left;
! 312: var yOffset = (document.all) ? parseInt(document.all.scaler.offsetTop) : (typeof(document.getElementById) == "function") ? parseInt(document.getElementById('scaler').offsetTop) : document.scaler.top;
! 313:
! 314: for (var i = 0; i < mark_count; i++) {
! 315: mark[i] = mark[i].split("/");
! 316:
! 317: 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))) ) {
! 318:
! 319: mark[i][0] = parseInt(xOffset + picWidth * (mark[i][0] - dlParams.wx.value)/dlParams.ww.value);
! 320: mark[i][1] = parseInt(yOffset + picHeight * (mark[i][1] - dlParams.wy.value)/dlParams.wh.value);
! 321:
! 322: if ( (document.all) || (typeof(document.getElementById) == "function") ) {
! 323: // suboptimal to place -5 pixels and not half size of mark-image
! 324: // should be changed in the future
! 325: document.getElementById("dot" + i).style.left = mark[i][0]-5;
! 326: document.getElementById("dot" + i).style.top = mark[i][1]-5;
! 327: document.getElementById("dot" + i).style.visibility = "visible";
! 328: } else {
! 329: document.layers[i+1].moveTo(mark[i][0]-5, mark[i][1]-5);
! 330: document.layers[i+1].visibility = "show";
! 331: }
! 332: }
! 333: }
! 334:
! 335: } else {
! 336: setTimeout("placeMarks()", 100);
! 337: }
! 338: }
! 339: }
! 340:
! 341:
! 342: function zoomPoint() {
! 343:
! 344: function zoomPointEvent(evt) {
! 345:
! 346: var point = new Point(evt);
! 347:
! 348: dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value*(1/ZOOMFACTOR));
! 349: dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value*(1/ZOOMFACTOR));
! 350:
! 351: dlParams.ww.value = cropFloat(dlParams.ww.value*(1/ZOOMFACTOR));
! 352: dlParams.wh.value = cropFloat(dlParams.wh.value*(1/ZOOMFACTOR));
! 353:
! 354: if ( dlParams.wx.value < 0 ) {
! 355: dlParams.wx.value = 0;
! 356: }
! 357: if ( dlParams.wy.value < 0 ) {
! 358: dlParams.wy.value = 0;
! 359: }
! 360: if ( dlParams.wx.value + dlParams.ww.value > 1 ) {
! 361: dlParams.wx.value = 1 - dlParams.ww.value;
! 362: }
! 363: if ( dlParams.wy.value + dlParams.wh.value > 1 ) {
! 364: dlParams.wy.value = 1 - dlParams.wh.value;
! 365: }
! 366:
! 367: // stopping event capture
! 368: if ( document.all ) {
! 369: document.all.scaler.onmousedown = null;
! 370: } else if ( typeof(document.removeEventListener) == "function" ) {
! 371: document.getElementById("scaler").removeEventListener("mousedown", zoomPointEvent, true);
! 372: } else {
! 373: document.scaler.releaseEvents(Event.MOUSEDOWN);
! 374: }
! 375:
! 376: display(3);
! 377: }
! 378:
! 379: // starting event capture
! 380: if ( document.all ) {
! 381: document.all.scaler.onmousedown = zoomPointEvent;
! 382: } else if ( typeof(document.addEventListener) == "function" ) {
! 383: document.getElementById("scaler").addEventListener("mousedown", zoomPointEvent, true);
! 384: } else {
! 385: document.scaler.captureEvents(Event.MOUSEDOWN);
! 386: document.scaler.onmousedown = zoomPointEvent;
! 387: }
! 388: }
! 389:
! 390:
! 391: function zoomArea() {
! 392: var state = 0;
! 393: var pt1, pt2;
! 394:
! 395: function click(evt) {
! 396:
! 397: if (state == 0) {
! 398: state = 1;
! 399:
! 400: pt1 = new Point(evt);
! 401:
! 402: pt2 = pt1;
! 403:
! 404: if ( document.all ) {
! 405:
! 406: document.all.eck1.style.left = pt1.pageX;
! 407: document.all.eck1.style.top = pt1.pageY;
! 408: document.all.eck2.style.left = pt2.pageX-12;
! 409: document.all.eck2.style.top = pt1.pageY;
! 410: document.all.eck3.style.left = pt1.pageX;
! 411: document.all.eck3.style.top = pt2.pageY-12;
! 412: document.all.eck4.style.left = pt2.pageX-12;
! 413: document.all.eck4.style.top = pt2.pageY-12;
! 414:
! 415: document.all.eck1.style.visibility="visible";
! 416: document.all.eck2.style.visibility="visible";
! 417: document.all.eck3.style.visibility="visible";
! 418: document.all.eck4.style.visibility="visible";
! 419:
! 420: document.all.scaler.onmousemove = move;
! 421: document.all.eck4.onmousemove = move;
! 422:
! 423: } else if ( typeof(document.addEventListener) == "function" ) {
! 424:
! 425: document.getElementById("eck1").style.left = pt1.pageX;
! 426: document.getElementById("eck1").style.top = pt1.pageY;
! 427: document.getElementById("eck2").style.left = pt2.pageX-12;
! 428: document.getElementById("eck2").style.top = pt1.pageY;
! 429: document.getElementById("eck3").style.left = pt1.pageX;
! 430: document.getElementById("eck3").style.top = pt2.pageY-12;
! 431: document.getElementById("eck4").style.left = pt2.pageX-12;
! 432: document.getElementById("eck4").style.top = pt2.pageY-12;
! 433:
! 434: document.getElementById("eck1").style.visibility="visible";
! 435: document.getElementById("eck2").style.visibility="visible";
! 436: document.getElementById("eck3").style.visibility="visible";
! 437: document.getElementById("eck4").style.visibility="visible";
! 438:
! 439: document.getElementById("scaler").addEventListener("mousemove", move, true);
! 440: document.getElementById("eck4").addEventListener("mousemove", move, true);
! 441:
! 442: } else {
! 443:
! 444: document.eck1.moveTo(pt1.pageX, pt1.pageY);
! 445: document.eck2.moveTo(pt2.pageX-12, pt1.pageY);
! 446: document.eck3.moveTo(pt1.pageX, pt2.pageY-12);
! 447: document.eck4.moveTo(pt2.pageX-12, pt2.pageY-12);
! 448:
! 449: document.eck1.visibility="show";
! 450: document.eck2.visibility="show";
! 451: document.eck3.visibility="show";
! 452: document.eck4.visibility="show";
! 453:
! 454: document.scaler.captureEvents(Event.MOUSEMOVE);
! 455: document.eck4.captureEvents(Event.MOUSEMOVE);
! 456: document.scaler.onmousemove = move;
! 457: document.eck4.onmousemove = move;
! 458:
! 459: }
! 460:
! 461: } else {
! 462:
! 463: pt2 = new Point(evt);
! 464:
! 465: if ( document.all ) {
! 466:
! 467: document.all.eck1.visibility="hidden";
! 468: document.all.eck2.visibility="hidden";
! 469: document.all.eck3.visibility="hidden";
! 470: document.all.eck4.visibility="hidden";
! 471:
! 472: document.all.scaler.onmousedown = null;
! 473: document.all.eck4.onmousedown = null;
! 474: document.all.scaler.onmousemove = null;
! 475: document.all.eck4.onmousemove = null;
! 476:
! 477: } else if ( typeof(document.removeEventListener) == "function" ) {
! 478:
! 479: document.getElementById("eck1").style.visibility="hidden";
! 480: document.getElementById("eck2").style.visibility="hidden";
! 481: document.getElementById("eck3").style.visibility="hidden";
! 482: document.getElementById("eck4").style.visibility="hidden";
! 483:
! 484: document.getElementById("scaler").removeEventListener("mousedown", click, true);
! 485: document.getElementById("eck4").removeEventListener("mousedown", click, true);
! 486: document.getElementById("scaler").removeEventListener("mousemove", move, true);
! 487: document.getElementById("eck4").removeEventListener("mousemove", move, true);
! 488:
! 489: } else {
! 490:
! 491: document.eck1.visibility="hide";
! 492: document.eck2.visibility="hide";
! 493: document.eck3.visibility="hide";
! 494: document.eck4.visibility="hide";
! 495:
! 496: document.scaler.releaseEvents(Event.MOUSEDOWN);
! 497: document.eck4.releaseEvents(Event.MOUSEDOWN);
! 498: document.scaler.releaseEvents(Event.MOUSEMOVE);
! 499: document.eck4.releaseEvents(Event.MOUSEMOVE);
! 500:
! 501: }
! 502:
! 503: dlParams.wx.value = cropFloat(parseFloat(Math.min(pt1.relX, pt2.relX)));
! 504:
! 505: dlParams.wy.value = cropFloat(parseFloat(Math.min(pt1.relY, pt2.relY)));
! 506:
! 507: dlParams.ww.value = cropFloat(parseFloat(Math.abs(pt1.relX-pt2.relX)));
! 508: dlParams.wh.value = cropFloat(parseFloat(Math.abs(pt1.relY-pt2.relY)));
! 509:
! 510: if ( (dlParams.ww.value != 0) && (dlParams.wh.value != 0) ) {
! 511: display(3);
! 512: }
! 513: }
! 514: }
! 515:
! 516: function move(evt) {
! 517:
! 518: pt2 = new Point(evt);
! 519:
! 520: var eck1_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX);
! 521: var eck1_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY);
! 522: var eck2_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;;
! 523: var eck2_top = ((pt1.pageY < pt2.pageY) ? pt1.pageY : pt2.pageY);
! 524: var eck3_left = ((pt1.pageX < pt2.pageX) ? pt1.pageX : pt2.pageX);
! 525: var eck3_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12;
! 526: var eck4_left = ((pt1.pageX < pt2.pageX) ? pt2.pageX : pt1.pageX)-12;
! 527: var eck4_top = ((pt1.pageY < pt2.pageY) ? pt2.pageY : pt1.pageY)-12;
! 528:
! 529: if ( document.all ) {
! 530:
! 531: document.all.eck1.style.left = eck1_left;
! 532: document.all.eck1.style.top = eck1_top;
! 533: document.all.eck2.style.left = eck2_left;
! 534: document.all.eck2.style.top = eck2_top;
! 535: document.all.eck3.style.left = eck3_left;
! 536: document.all.eck3.style.top = eck3_top;
! 537: document.all.eck4.style.left = eck4_left;
! 538: document.all.eck4.style.top = eck4_top;
! 539:
! 540: } else if ( typeof(document.getElementById) == "function" ) {
! 541:
! 542: document.getElementById("eck1").style.left = eck1_left;
! 543: document.getElementById("eck1").style.top = eck1_top;
! 544: document.getElementById("eck2").style.left = eck2_left;
! 545: document.getElementById("eck2").style.top = eck2_top;
! 546: document.getElementById("eck3").style.left = eck3_left;
! 547: document.getElementById("eck3").style.top = eck3_top;
! 548: document.getElementById("eck4").style.left = eck4_left;
! 549: document.getElementById("eck4").style.top = eck4_top;
! 550:
! 551: } else {
! 552:
! 553: document.eck1.moveTo(eck1_left, eck1_top);
! 554: document.eck2.moveTo(eck2_left, eck2_top);
! 555: document.eck3.moveTo(eck3_left, eck3_top);
! 556: document.eck4.moveTo(eck4_left, eck4_top);
! 557:
! 558: }
! 559: }
! 560:
! 561: // starting event capture
! 562: if ( document.all ) {
! 563: document.all.scaler.onmousedown = click;
! 564: document.all.eck4.onmousedown = click;
! 565: } else if ( typeof(document.addEventListener) == "function" ) {
! 566: document.getElementById("scaler").addEventListener("mousedown", click, true);
! 567: document.getElementById("eck4").addEventListener("mousedown", click, true);
! 568: } else {
! 569: document.scaler.captureEvents(Event.MOUSEDOWN);
! 570: document.eck4.captureEvents(Event.MOUSEDOWN);
! 571: document.scaler.onmousedown = click;
! 572: document.eck4.onmousedown = click;
! 573: }
! 574: }
! 575:
! 576:
! 577: function zoomExtends() {
! 578:
! 579: dlParams.wx.value = 0.0;
! 580: dlParams.wy.value = 0.0;
! 581:
! 582: dlParams.ww.value = 1.0;
! 583: dlParams.wh.value = 1.0;
! 584:
! 585: display(3);
! 586:
! 587: }
! 588:
! 589:
! 590: function zoomOut() {
! 591:
! 592: dlParams.wx.value = cropFloat(dlParams.wx.value-0.5*(dlParams.ww.value*(ZOOMFACTOR)-dlParams.ww.value));
! 593: dlParams.wy.value = cropFloat(dlParams.wy.value-0.5*(dlParams.wh.value*(ZOOMFACTOR)-dlParams.wh.value));
! 594:
! 595: dlParams.ww.value = cropFloat(dlParams.ww.value*(ZOOMFACTOR));
! 596: dlParams.wh.value = cropFloat(dlParams.wh.value*(ZOOMFACTOR));
! 597:
! 598: if ( dlParams.wx.value < 0 ) {
! 599: dlParams.wx.value = 0;
! 600: }
! 601: if ( dlParams.wy.value < 0 ) {
! 602: dlParams.wy.value = 0;
! 603: }
! 604: if ( dlParams.ww.value > 1 ) {
! 605: dlParams.ww.value = 1;
! 606: }
! 607: if ( dlParams.wh.value > 1 ) {
! 608: dlParams.wh.value = 1;
! 609: }
! 610: if ( dlParams.wx.value + dlParams.ww.value > 1 ) {
! 611: dlParams.wx.value = 1 - dlParams.ww.value;
! 612: }
! 613: if ( dlParams.wy.value + dlParams.wh.value > 1 ) {
! 614: dlParams.wy.value = 1 - dlParams.wh.value;
! 615: }
! 616:
! 617: display(3);
! 618: }
! 619:
! 620:
! 621: function moveTo() {
! 622:
! 623: if ( (parseFloat(dlParams.ww.value) == 1.0) && (parseFloat(dlParams.wh.value) == 1.0) ) {
! 624: alert("This function is only available when zoomed in!");
! 625: return;
! 626: }
! 627:
! 628: function moveToEvent(event) {
! 629:
! 630: var point = new Point(event);
! 631:
! 632: dlParams.wx.value = cropFloat(point.relX-0.5*dlParams.ww.value);
! 633: dlParams.wy.value = cropFloat(point.relY-0.5*dlParams.wh.value);
! 634:
! 635: if ( dlParams.wx.value < 0 ) {
! 636: dlParams.wx.value = 0;
! 637: }
! 638: if ( dlParams.wy.value < 0 ) {
! 639: dlParams.wy.value = 0;
! 640: }
! 641: if ( dlParams.wx.value + dlParams.ww.value > 1 ) {
! 642: dlParams.wx.value = 1 - dlParams.ww.value;
! 643: }
! 644: if ( dlParams.wy.value + dlParams.wh.value > 1 ) {
! 645: dlParams.wy.value = 1 - dlParams.wh.value;
! 646: }
! 647:
! 648: // stopping event capture
! 649: if ( document.all ) {
! 650: document.all.scaler.onmousedown = null;
! 651: } else if ( typeof(document.removeEventListener) == "function" ) {
! 652: document.getElementById("scaler").removeEventListener("mousedown", moveToEvent, true);
! 653: } else {
! 654: document.scaler.releaseEvents(Event.MOUSEDOWN)
! 655: }
! 656:
! 657: display(3);
! 658: }
! 659:
! 660: // starting event capture
! 661: if ( document.all ) {
! 662: document.all.scaler.onmousedown = moveToEvent;
! 663: } else if ( typeof(document.addEventListener) == "function" ) {
! 664: document.getElementById("scaler").addEventListener("mousedown", moveToEvent, true);
! 665: } else {
! 666: document.scaler.captureEvents(Event.MOUSEDOWN);
! 667: document.scaler.onmousedown = moveToEvent;
! 668: }
! 669: }
! 670:
! 671:
! 672: function scale(factor) {
! 673:
! 674: dlParams.ws.value = cropFloat(factor);
! 675: display(3);
! 676:
! 677: }
! 678:
! 679:
! 680: // capturing keypresses for next and previous page
! 681: function parseKeypress(evt) {
! 682:
! 683: if ( document.all ) {
! 684:
! 685: if ( event.keyCode == 110 ) {
! 686: page('+1');
! 687: }
! 688: if ( event.keyCode == 98 ) {
! 689: page('-1');
! 690: }
! 691:
! 692: document.cancleBubble = true;
! 693:
! 694: } else {
! 695:
! 696: if ( evt.charCode == 110 ) {
! 697: page('+1');
! 698: } else if ( evt.charCode == 98 ) {
! 699: page('-1');
! 700: } else if ( evt.which == 110 ) {
! 701: page('+1');
! 702: } else if ( evt.which == 98 ) {
! 703: // does not work currentlyfor Opera, because it catches the 'b'-key on it's own
! 704: // have to change the key or find another way - luginbuehl
! 705: page('-1');
! 706: }
! 707:
! 708: }
! 709: }
! 710:
! 711:
! 712: // auxiliary function to crop senseless precicsion
! 713: function cropFloat(tmp) {
! 714: return parseInt(10000*tmp)/10000;
! 715: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>