changeset 1111:0a01d5cc66fe

center zoom area (not yet working for text search + highlight)
author hertzhaft
date Mon, 29 Oct 2012 21:25:07 +0100
parents ffda96c2fde0
children 121d3aadfa1e
files webapp/src/main/webapp/jquery/jquery.digilib.js webapp/src/main/webapp/jquery/jquery.digilib.regions.js
diffstat 2 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.js	Sun Oct 28 15:10:41 2012 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.js	Mon Oct 29 21:25:07 2012 +0100
@@ -1441,6 +1441,18 @@
         data.zoomArea = za;
     };
 
+    /** move the zoom area and center it on rectangle "rect"
+     */
+    var centerZoomArea = function(data, rect) {
+        var za = data.zoomArea;
+        if (isFullArea(za)) return;
+        za.setCenter(rect.getCenter()).stayInside(FULL_AREA);
+        if (!za.containsRect(rect)) {
+            za = FULL_AREA.copy();
+            }
+        setZoomArea(data, za);
+    };
+
     /** get image quality as a number (0..2).
      * 
      */
@@ -1695,6 +1707,7 @@
             showDiv : showDiv,
             defineArea : defineArea,
             setZoomArea : setZoomArea,
+            centerZoomArea : centerZoomArea,
             setPreviewBg : setPreviewBg,
             getImgTrafo : getImgTrafo,
             getQuality : getQuality,
--- a/webapp/src/main/webapp/jquery/jquery.digilib.regions.js	Sun Oct 28 15:10:41 2012 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.regions.js	Mon Oct 29 21:25:07 2012 +0100
@@ -304,15 +304,8 @@
             var attr = { 'class' : CSS+'findregion' };
             var item = { 'rect' : rect, 'attributes' : attr };
             var $regionDiv = addRegionDiv(data, item);
-            var za = data.zoomArea;
-            if (!fn.isFullArea(za)) {
-                za.setCenter(rect.getCenter()).stayInside(FULL_AREA);
-                if (!za.containsRect(rect)) {
-                    za = FULL_AREA.copy();
-                    }
-                fn.setZoomArea(data, za);
-                }
-            console.debug('regionFromCoords', coords, rect, za);
+            var newZoomArea = fn.centerZoomArea(data, rect);
+            console.debug('regionFromCoords', coords, rect, newZoomArea);
             redisplay(data);
             },
 
@@ -322,6 +315,11 @@
             var selector = '#'+ids.join(',#');
             var $regions = data.$elem.find(selector);
             $regions.addClass(CSS+'highlightregion');
+            if (ids.length == 1) {
+                var rect = $regions.data('rect');
+                fn.centerZoomArea(data, rect);
+                redisplay(data);
+            }
             },
 
         // find coordinates and display as new region
@@ -394,8 +392,8 @@
             // callback if a region is selected by name
             var findRegion = function () {
                 var id = [$select.val()];
+                fn.withdraw($info);
                 actions.highlightRegions(data, id);
-                fn.withdraw($info);
                 return false;
                 };
             // adapt dropdown, show only matching entries 
@@ -594,6 +592,8 @@
             var item = {'rect' : rect, 'attributes' : attr, 'inner' : $inner};
             var $regionDiv = addRegionDiv(data, item);
         });
+        // $areas.removeAttr('id');
+        $areas.remove();
     };
 
     // select region divs (HTML or URL)