--- zogiLib/js/dllib.js 2004/10/04 19:39:01 1.2 +++ zogiLib/js/dllib.js 2004/11/03 15:24:46 1.5 @@ -17,21 +17,24 @@ Foundation, Inc., 59 Temple Place - Suit Authors: Christian Luginbuehl, 01.05.2003 (first version) DW 24.03.2004 (Changed for digiLib in Zope) - Robert Casties, 03.08.2004 + Robert Casties, 2.11.2004 ! Requires baselib.js ! */ -var dlScriptVersion = "1.0b2"; + +function identify() { + // used for identifying a digilib instance + // Relato uses that function - lugi + return "Digilib 0.6"; +} + /* * more parameter handling */ -var dlArea = new Rectangle(0.0, 0.0, 1.0, 1.0); -var dlMaxArea = new Rectangle(0.0, 0.0, 1.0, 1.0); - function parseArea() { // returns area Rectangle from current parameters return new Rectangle(getParameter("wx"), getParameter("wy"), getParameter("ww"), getParameter("wh")); @@ -46,8 +49,6 @@ function setParamFromArea(rect) { return true; } -var dlTrafo = new Transform(); - function parseTrafo(elem) { // returns Transform from current dlArea and picsize var picsize = getElementRect(elem); @@ -71,8 +72,6 @@ function parseTrafo(elem) { } -var dlMarks = new Array(); - function parseMarks() { // returns marks array from current parameters var marks = new Array(); @@ -116,8 +115,6 @@ function deleteMark() { return true; } -var dlFlags = new Object(); - function hasFlag(mode) { // returns if mode flag is set return (dlFlags[mode]); @@ -194,12 +191,21 @@ function bestPicSize(elem, inset) { * digilib specific routines * ******************************************** */ -var elemScaler = null; -var picElem = null; - function dl_param_init() { // parameter initialisation before onload + if (!baseScriptVersion) { + base_init(); + } + dlScriptVersion = "1.1b"; + dlArea = new Rectangle(0.0, 0.0, 1.0, 1.0); + dlMaxArea = new Rectangle(0.0, 0.0, 1.0, 1.0); + dlTrafo = new Transform(); + dlMarks = new Array(); + dlFlags = new Object(); + elemScaler = null; + picElem = null; + ZOOMFACTOR = Math.sqrt(2); // put the query parameters (sans "?") in the parameters array parseParameters(location.search.slice(1)); @@ -212,6 +218,9 @@ function dl_param_init() { function dl_init() { // initalisation on load + if (!dlScriptVersion) { + dl_param_init(); + } elemScaler = getElement("scaler", true); picElem = getElement("pic", true); if (picElem == null && elemScaler) { @@ -219,7 +228,7 @@ function dl_init() { picElem = elemScaler.document.images[0]; } if ((!elemScaler)||(!picElem)) { - alert("Sorry, zogilib doesn't work here!"); + alert("Sorry, digilib doesn't work here!"); return false; } // give a name to the window containing digilib @@ -405,8 +414,6 @@ function zoomArea() { registerEvent("mousedown", eck4, zoomClick); } -var ZOOMFACTOR = Math.sqrt(2); - function zoomBy(factor) { // zooms by the given factor var newarea = dlArea.copy(); @@ -454,6 +461,23 @@ function moveCenter() { registerEvent("mousedown", elemScaler, moveCenterEvent); } +function moveBy(movx, movy) { + // move visible area by movx and movy (in units of dw, dh) + if ((dlArea.width == 1.0)&&(dlArea.height == 1.0)) { + // nothing to do + return; + } + var newarea = dlArea.copy(); + newarea.x += parseFloat(movx)*dlArea.width; + newarea.y += parseFloat(movy)*dlArea.height; + newarea = dlMaxArea.fit(newarea); + // set parameters + setParamFromArea(newarea); + parseArea(); + display(); +} + + function getRef() { @@ -468,3 +492,11 @@ function getRef() { } return hyperlinkRef; } + +function getRefWin(type, msg) { + // shows an alert with a reference to the current digilib set + if (! msg) { + msg = "Link for HTML documents"; + } + prompt(msg, getRef()); +}