# HG changeset patch # User hertzhaft # Date 1350667167 -7200 # Node ID 8d6bc18f7145e471f40d35ec0f3ac2699b566b42 # Parent 75a54db031ddc1ba8715d8ae9f47706c27e2a5da some polishing and refactoring, preparation for region text search diff -r 75a54db031dd -r 8d6bc18f7145 webapp/src/main/webapp/jquery/jquery.digilib.regions.js --- a/webapp/src/main/webapp/jquery/jquery.digilib.regions.js Thu Oct 18 18:49:05 2012 +0200 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.regions.js Fri Oct 19 19:19:27 2012 +0200 @@ -30,8 +30,9 @@ (function($) { // the digilib object var digilib = null; + // the normal zoom area + var FULL_AREA = null; // the functions made available by digilib - var FULL_AREA = null; var fn = { // dummy function to avoid errors, gets overwritten by buttons plugin highlightButtons : function () { @@ -81,6 +82,8 @@ 'isRegionVisible' : true, // are region numbers shown? 'showRegionNumbers' : true, + // default width for region when only point is given + 'regionWidth' : 0.005, // is there region content in the page? 'processHtmlRegions' : false, // region defined by users and in the URL @@ -290,12 +293,35 @@ console.debug('showRegionCoords', coords); }, + // draw a find region from coords and move into view + regionFromCoords : function (data, coords) { + var rect = parseCoordsString(data, coords); + if (rect == null) { + alert('invalid coordinates: ' + coords); + return; + } + var cssPrefix = data.settings.cssPrefix; + var attr = { 'class' : cssPrefix+'regionURL '+cssPrefix+'findregion' }; + createRegion(data, data.userRegions, rect, attr); + 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); + redisplay(data); + }, + // find coordinates and display as new region findCoords : function (data) { var $elem = data.$elem; var cssPrefix = data.settings.cssPrefix; var html = '\