Mercurial > hg > digilib-old
changeset 761:16778bd2de7c jquery
added setScaleMode. no compensation for change in scaling yet.
author | robcast |
---|---|
date | Wed, 09 Feb 2011 10:22:29 +0100 |
parents | f0be4432f515 |
children | aab01da232ef 31664707999e |
files | client/digitallibrary/jquery/jquery.digilib.js |
diffstat | 1 files changed, 39 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js Tue Feb 08 23:57:39 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Wed Feb 09 10:22:29 2011 +0100 @@ -153,7 +153,7 @@ img : "calibration-x.png" }, scale : { - onclick : "javascript:toggleScaleMenu()", + onclick : "setScaleMode", tooltip : "change image scale", img : "original-size.png" }, @@ -590,6 +590,18 @@ calibrate : function (data) { getImageInfo(data); }, + + // set image scale mode + setScaleMode : function (data, mode) { + var oldM = getScaleMode(data); + if (mode == null) { + mode = window.prompt("Image scale mode (screen, pixel, size)", oldM); + } + if (mode != null) { + setScaleMode(data, mode); + redisplay(data); + } + } }; @@ -1149,7 +1161,7 @@ console.debug("birdImg loaded!", $birdImg, "rect=", birdRect, "data=", data); if (birdRect.width === 0) { // malheureusement IE7 calls load handler when there is no size info yet - setTimeout(function () { $birdImg.triggerHandler('load') }, 200); + setTimeout(function () { $birdImg.triggerHandler('load'); }, 200); } // display red indicator around zoomarea renderBirdArea(data); @@ -1526,7 +1538,31 @@ flags['q'+qual] = 'q'+qual; }; - // sets a key to a value (relative values with +/- if relative=true) + // get image scale mode (screen, pixel, size) + var getScaleMode = function (data) { + if (data.scalerFlags.clip != null) { + return 'pixel'; + } else if (data.scalerFlags.osize != null) { + return 'size'; + } + // mo=fit is default + return 'screen'; + }; + + // set image scale mode (screen, pixel, size) + var setScaleMode = function (data, mode) { + delete data.scalerFlags.fit; + delete data.scalerFlags.clip; + delete data.scalerFlags.osize; + if (mode === 'pixel') { + data.scalerFlags.clip = 'clip'; + } else if (mode === 'size') { + data.scalerFlags.osize = 'osize'; + } + // mo=fit is default + }; + + // sets a key to a value (relative values with +/- if relative=true) var setNumValue = function(settings, key, value) { if (value == null) return null; if (isNumber(value)) {