changeset 972:2ad5ba781e88

better scale mode change handling.
author robcast
date Thu, 26 Jan 2012 15:00:13 +0100
parents 800150ab7b6f
children 55572a4bbf68
files webapp/src/main/webapp/jquery/jquery.digilib.js
diffstat 1 files changed, 42 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.js	Thu Jan 26 12:20:22 2012 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.js	Thu Jan 26 15:00:13 2012 +0100
@@ -340,16 +340,9 @@
          */
         zoomFull : function (data, mode) {
             data.zoomArea = FULL_AREA.copy();
-            if (mode === 'width') {
-                data.dlOpts.fitwidth = 1;
-                delete data.dlOpts.fitheight;
-            } else if (mode === 'height') {
-                data.dlOpts.fitheight = 1;
-                delete data.dlOpts.fitwidth;
-            } else {
-                delete data.dlOpts.fitwidth;
-                delete data.dlOpts.fitheight;
-            }
+            setFitMode(data, mode);
+            // zoom full only works in screen mode
+            setScaleMode(data, 'screen');
             redisplay(data);
         },
 
@@ -549,7 +542,6 @@
             }
             if (mode != null) {
                 setScaleMode(data, mode);
-                data.scaleMode = mode;
                 redisplay(data);
             }
         }
@@ -1332,6 +1324,9 @@
         newarea.y -= 0.5 * (newarea.height - area.height);
         newarea = FULL_AREA.fit(newarea);
         setZoomArea(data, newarea);
+        // reset modes
+        setScaleMode(data, 'screen');
+        setFitMode(data, 'both');
         redisplay(data);
     };
 
@@ -1406,10 +1401,9 @@
             clickRect.clipTo(picRect);
             var area = data.imgTrafo.invtransform(clickRect);
             setZoomArea(data, area);
-            // zoomed is always fit
-            data.settings.ws = 1;
-            delete data.dlOpts.fitwidth;
-            delete data.dlOpts.fitheight;
+            // reset modes
+            setFitMode(data, 'both');
+            setScaleMode(data, 'screen');
             redisplay(data);
             return false;
         };
@@ -1613,8 +1607,39 @@
             data.scalerFlags.osize = 'osize';
         }
         // mo=fit is default
+        // save mode
+        data.scaleMode = mode;
     };
 
+    /** get screen fit mode (width, height, both).
+     * 
+     */
+    var getFitMode = function (data) {
+    	if (data.dlOpts.fitwidth != null) {
+    		return "width";
+    	} else if (data.dlOpts.fitheight != null) {
+    		return "height";
+    	}
+    	// "both" is default
+    	return "both";
+    };
+    
+    /** 
+     * set screen fit mode (width, height, both).
+     */
+    var setFitMode = function (data, mode) {
+    	if (mode === 'width') {
+    		data.dlOpts.fitwidth = 1;
+    		delete data.dlOpts.fitheight;
+    	} else if (mode === 'height') {
+    		data.dlOpts.fitheight = 1;
+    		delete data.dlOpts.fitwidth;
+    	} else {
+    		delete data.dlOpts.fitwidth;
+    		delete data.dlOpts.fitheight;
+    	}
+    };
+    	
     /** sets a key to a value (relative values with +/- if relative=true).
      * 
      */
@@ -1729,6 +1754,8 @@
             setQuality : setQuality,
             getScaleMode : getScaleMode,
             setScaleMode : setScaleMode,
+            getFitMode : getFitMode,
+            setFitMode : setFitMode,
             canMove : canMove,
             isFullArea : isFullArea,
             getBorderWidth : getBorderWidth,