Mercurial > hg > digilib-old
comparison webapp/src/main/webapp/jquery/jquery.digilib.regions.js @ 1093:75a54db031dd
move found region into view, keep zoom factor if possible
author | hertzhaft |
---|---|
date | Thu, 18 Oct 2012 18:49:05 +0200 |
parents | 4964a1e252eb |
children | 8d6bc18f7145 |
comparison
equal
deleted
inserted
replaced
1092:4964a1e252eb | 1093:75a54db031dd |
---|---|
29 | 29 |
30 (function($) { | 30 (function($) { |
31 // the digilib object | 31 // the digilib object |
32 var digilib = null; | 32 var digilib = null; |
33 // the functions made available by digilib | 33 // the functions made available by digilib |
34 var FULL_AREA = null; | |
34 var fn = { | 35 var fn = { |
35 // dummy function to avoid errors, gets overwritten by buttons plugin | 36 // dummy function to avoid errors, gets overwritten by buttons plugin |
36 highlightButtons : function () { | 37 highlightButtons : function () { |
37 console.debug('regions: dummy function - highlightButtons'); | 38 console.debug('regions: dummy function - highlightButtons'); |
38 } | 39 } |
310 // handle submit | 311 // handle submit |
311 $form.on('submit', function () { | 312 $form.on('submit', function () { |
312 var coords = $input.val(); | 313 var coords = $input.val(); |
313 var attr = { 'class' : cssPrefix+'regionURL '+cssPrefix+'findregion' }; | 314 var attr = { 'class' : cssPrefix+'regionURL '+cssPrefix+'findregion' }; |
314 console.debug('findCoords', coords); | 315 console.debug('findCoords', coords); |
315 createRegionFromCoords(data, data.userRegions, coords, attr); | 316 var rect = createRegionFromCoords(data, data.userRegions, coords, attr); |
317 var za = data.zoomArea; | |
318 if (!fn.isFullArea(za)) { | |
319 za.setCenter(rect.getCenter()); | |
320 za.clipTo(FULL_AREA); | |
321 if (!za.containsRect(rect)) { | |
322 fn.setZoomArea(data, FULL_AREA.copy()); | |
323 } else { | |
324 fn.setZoomArea(data, za); | |
325 } | |
326 } | |
316 fn.withdraw($info); | 327 fn.withdraw($info); |
317 redisplay(data); | 328 redisplay(data); |
318 return false; | 329 return false; |
319 }); | 330 }); |
320 // handle cancel | 331 // handle cancel |
695 var init = function (data) { | 706 var init = function (data) { |
696 console.debug('initialising regions plugin. data:', data); | 707 console.debug('initialising regions plugin. data:', data); |
697 var $elem = data.$elem; | 708 var $elem = data.$elem; |
698 var settings = data.settings; | 709 var settings = data.settings; |
699 var cssPrefix = data.settings.cssPrefix; | 710 var cssPrefix = data.settings.cssPrefix; |
711 FULL_AREA = geom.rectangle(0, 0, 1, 1); | |
700 // region arrays | 712 // region arrays |
701 data.userRegions = []; | 713 data.userRegions = []; |
702 data.htmlRegions = []; | 714 data.htmlRegions = []; |
703 // install event handlers | 715 // install event handlers |
704 var $data = $(data); | 716 var $data = $(data); |