# HG changeset patch # User robcast # Date 1302077463 -7200 # Node ID cb23fe100d7ece58591a6b74155ee9bceacde076 # Parent 07926f0b9a1aaf4c0056fd8b0bf031cad4b8fa19 make getFullscreenImgSize more robust. put button width in settings. diff -r 07926f0b9a1a -r cb23fe100d7e client/digitallibrary/jquery/jquery.digilib.js --- a/client/digitallibrary/jquery/jquery.digilib.js Tue Mar 22 12:31:41 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Wed Apr 06 10:11:03 2011 +0200 @@ -237,6 +237,7 @@ 'fullscreen' : { // path to button images (must end with a slash) 'imagePath' : 'img/fullscreen/', + 'buttonSetWidth' : 36, 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","pagewidth","back","fwd","page","help","reset","toggleoptions"], 'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","size","calibrationx","scale","lessoptions"], 'arrowSet' : ["up", "down", "left", "right"], @@ -244,6 +245,7 @@ }, 'embedded' : { 'imagePath' : 'img/embedded/16/', + 'buttonSetWidth' : 18, 'standardSet' : ["reference","zoomin","zoomout","zoomarea","zoomfull","help","reset","toggleoptions"], 'specialSet' : ["mark","delmark","hmir","vmir","rot","brgt","cont","rgb","quality","scale","lessoptions"], 'arrowSet' : ["up", "down", "left", "right"], @@ -929,6 +931,8 @@ if (typeof history.pushState === 'function') { console.debug("faking reload to "+url); // change url without reloading (stateObj, title, url) + // TODO: we really need to put the state in stateObj and listen to pop-events + // TODO: use replace-state(?) history.pushState({}, '', url); // change img src var imgurl = getScalerUrl(data); @@ -962,23 +966,33 @@ // returns maximum size for scaler img in fullscreen mode var getFullscreenImgSize = function (data) { + var mode = data.settings.interactionMode; var $win = $(window); var winH = $win.height(); var winW = $win.width(); var $body = $('body'); - // include standard body margins + // include standard body margins and check plausibility var borderW = $body.outerWidth(true) - $body.width(); + if (borderW === 0 || borderW > 100) { + console.debug("fixing border width for getFullscreenImgSize!"); + borderW = data.settings.scalerInset; + } var borderH = $body.outerHeight(true) - $body.height(); - // get width of first button div + if (borderH === 0 || borderH > 100) { + console.debug("fixing border height for getFullscreenImgSize!"); + borderH = 5; + } var buttonsW = 0; - if (data.$buttonSets) { - buttonsW = data.$buttonSets[0].outerWidth(); + if (data.settings.visibleButtonSets) { + // get button width from settings + buttonsW = data.settings.buttonSettings[mode].buttonSetWidth; + // TODO: leave space for all button sets? } // account for left/right border, body margins and additional requirements - var calcW = winW - borderW - buttonsW - data.settings.scalerInset; - var calcH = winH - borderH; - console.debug(winW, winH, 'winW:', $win.width(), 'border:', borderW, 'buttonsW:', buttonsW, 'calc:', calcW); - return geom.size(calcW, calcH); + var imgW = winW - borderW - buttonsW; + var imgH = winH - borderH; + console.debug(winW, winH, 'winW:', $win.width(), 'border:', borderW, 'buttonsW:', buttonsW, 'calc:', imgW); + return geom.size(imgW, imgH); }; // creates HTML structure for digilib in elem @@ -1168,7 +1182,7 @@ }, { name : 'left', rect : geom.rectangle(r.x, r.y, aw, r.height), - show : canMove(data, -1, 0), + show : canMove(data, -1, 0) }, { name : 'right', rect : geom.rectangle(r.x + r.width - aw, r.y, aw, r.height), @@ -1202,7 +1216,7 @@ var $elem = data.$elem; var settings = data.settings; var $aboutDiv = $('