changeset 1510:b213cf27152b

merge
author robcast
date Mon, 02 May 2016 20:14:10 +0200
parents e7e38e1f68df (current diff) b3d81e4581a7 (diff)
children 7995afe760a8
files
diffstat 1 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.regions.js	Mon May 02 20:06:46 2016 +0200
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.regions.js	Mon May 02 20:14:10 2016 +0200
@@ -143,8 +143,10 @@
         'userRegionSet' : ['defineregion', 'removeregion', 'removeallregions'],
         // url param for regions
         'rg' : null,
-        // array with region data
+        // precalculated array with region data, used by createRegionsFromJS
         'regions' : null,
+        // JSON array with region data (x,y,w,h,title,index), used by createRegionsFromJSON
+        'regionsJSON' : null,
         // function for extracting the sort string (for the region search window)
         'regionSortString' : null,
         // region attributes to copy from HTML
@@ -491,6 +493,18 @@
             });
     };
 
+    // create regions from a JSON array of items (x,y,w,h,title,index)
+    var createRegionsFromJSON = function (data, items) {
+      var ww = data.settings.regionWidth;
+      $.each(items, function (index, item) {
+        addRegionDiv(data, {
+          rect: geom.rectangle(item.x, item.y, item.w || ww, item.h || ww),
+          attributes: {'class' : CSS+"regionJSON "+CSS+"overlay", title: item.title },
+          index: item.index || index+1
+          });
+        });
+    };
+
     // create regions from URL parameters
     var createRegionsFromURL = function (data) {
         var userRegions = unpackRegions(data);
@@ -593,6 +607,7 @@
     };
 
     // show a region on top of the scaler image 
+    // TODO: faster rendering for large numbers of regions?
     var renderRegion = function (data, $regionDiv, anim) {
         if (!data.imgTrafo) return;
         var zoomArea = data.zoomArea;
@@ -725,6 +740,10 @@
         if (settings.regions) {
             createRegionsFromJS(data, settings.regions);
         }
+        // regions with content are given in a JSON array
+        if (settings.regionsJSON) {
+            createRegionsFromJSON(data, settings.regionsJSON);
+        }
         // regions with content are given in HTML divs
         if (settings.processHtmlRegions) {
             createRegionsFromHTML(data);