--- zogiLib/js/dllib.js 2005/11/08 10:13:31 1.6 +++ zogiLib/js/dllib.js 2011/07/26 18:10:24 1.11 @@ -17,7 +17,7 @@ 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, 2.11.2004 + Robert Casties, 14.7.2006 ! Requires baselib.js ! @@ -178,15 +178,24 @@ function bestPicSize(elem, inset) { inset = 25; } var ws = getWinSize(); + var wsold = ws.copy(); var es = getElementPosition(elem); if (es) { - ws.width = ws.width - es.x - inset; - ws.height = ws.height - es.y - inset; + if ((es.x > ws.width)||(es.y > ws.height)) { + alert("es="+es+" is outside ws="+ws+" fixing..."); + ws.width = ws.width - inset; + ws.height = ws.height - inset; + } else { + ws.width = ws.width - es.x - inset; + ws.height = ws.height - es.y - inset; + } } + //alert("ws="+wsold+" es="+es+" -> ws="+ws); + //alert("ws="+ws+"("+typeof(ws)+") es="+es); return ws; } -function setDLParam(e, s) { +function setDLParam(e, s, relative) { // sets parameter based on HTML event var nam; var val; @@ -198,10 +207,10 @@ function setDLParam(e, s) { val = s.value; } if (nam && val) { - setParameter(nam, val); + setParameter(nam, val, relative); display(); } else { - alert("unable to process event!"); + alert("ERROR: unable to process event!"); } return true; } @@ -217,7 +226,7 @@ function dl_param_init() { if (!baseScriptVersion) { base_init(); } - dlScriptVersion = "1.1b"; + dlScriptVersion = "1.3a"; 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(); @@ -228,11 +237,14 @@ function dl_param_init() { ZOOMFACTOR = Math.sqrt(2); // put the query parameters (sans "?") in the parameters array - parseParameters(location.search.slice(1)); + // non-digilib parameters get detail level 32 + parseParameters(location.search.slice(1),32); // treat special parameters dlMarks = parseMarks(); dlArea = parseArea(); dlFlags = parseFlags(); + // mask for parameters when creating new URL + dlUrlParamMask = 255; } @@ -258,7 +270,7 @@ function dl_init() { window.name = "digilib"; } // put the query parameters (sans "?") in the parameters array - parseParameters(location.search.slice(1)); + //parseParameters(location.search.slice(1),32); // treat special parameters dlMarks = parseMarks(); dlArea = parseArea(); @@ -274,9 +286,9 @@ function dl_init() { function display(detail) { // redisplay the page if (! detail) { - detail = 9; + detail = 255; } - var queryString = getAllParameters(detail); + var queryString = getAllParameters(detail & dlUrlParamMask); location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString; } @@ -460,7 +472,7 @@ function zoomFullpage() { function moveCenter() { // move visible area so that it's centered around the clicked point if ( (dlArea.width == 1.0) && (dlArea.height == 1.0) ) { - // noting to do + // nothing to do return; } window.focus(); @@ -503,7 +515,7 @@ function getRef() { var baseUrl = location.protocol + "//" + location.host + location.pathname; } var hyperlinkRef = baseUrl; - var par = getAllParameters(9); + var par = getAllParameters((7+32+64) & dlUrlParamMask); // all without ddpi, pt if (par.length > 0) { hyperlinkRef += "?" + par; } @@ -563,33 +575,46 @@ function mirror(dir) { display(); } -function gotoPage(gopage) { - // goto given page nr (+/- relative) - setParameter("pn", gopage); +function gotoPage(gopage, keep) { + // goto given page nr (+/-: relative) + var oldpn = parseInt(getParameter("pn")); + setParameter("pn", gopage, true); var pn = parseInt(getParameter("pn")); if (pn < 1) { - pn = 1; - setParameter("pn", pn); + alert("No such page! (Page number too low)"); + setParameter("pn", oldpn); + return; + } + if (hasParameter("pt")) { + pt = parseInt(getParameter("pt")) + if (pn > pt) { + alert("No such page! (Page number too high)"); + setParameter("pn", oldpn); + return; + } + } + if (keep) { + display(63+128); // all, no mark + } else { + display(3+32+128); // fn, pn, ws, mo + pt } - // TODO: check for last page - display(1); } function gotoPageWin() { // dialog to ask for new page nr - var pn = getParameter('pn'); + var pn = getParameter("pn"); var gopage = window.prompt("Go to page", pn); if (gopage) { gotoPage(gopage); } } -function setParamWin(param, text) { +function setParamWin(param, text, relative) { // dialog to ask for new parameter value var val = getParameter(param); var newval = window.prompt(text, val); if (newval) { - setParameter(param, newval); + setParameter(param, newval, relative); display(); } } @@ -598,4 +623,10 @@ function showOptions(show) { // show or hide option div var elem = getElement("dloptions"); showElement(elem, show); -} \ No newline at end of file +} + +function toggleOptions() { + // toggle option div + var elem = getElement("dloptions"); + showOptions(! isElementVisible(elem)); +}