# HG changeset patch # User hertzhaft # Date 1298067206 -3600 # Node ID 12f790cb30de0ac42ff62fb9921d7a3215243b7b # Parent b07d1824ca2aeb32dac1c9fdbe96a3a44420d1b8 started to adapt regions plugin to new plugin mechanism diff -r b07d1824ca2a -r 12f790cb30de client/digitallibrary/jquery/jquery.digilib.birdseye.js --- a/client/digitallibrary/jquery/jquery.digilib.birdseye.js Fri Feb 18 20:09:15 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.birdseye.js Fri Feb 18 23:13:26 2011 +0100 @@ -1,4 +1,5 @@ -/** required digilib geometry plugin +/** +digilib bird's eye view plugin */ (function($) { @@ -25,7 +26,7 @@ // parameters used by bird's eye div 'birdDivParams' : ['fn','pn','dw','dh'] }; - + var actions = { // event handler: toggles the visibility of the bird's eye window showBirdDiv : function (data, show) { @@ -40,8 +41,8 @@ updateBirdDiv(data); digilib.fn.storeOptions(data); } - }; - + }; + // plugin installation called by digilib on plugin object. var install = function(digilib) { // import geometry classes @@ -67,7 +68,7 @@ $data.bind('redisplay', handleRedisplay); $data.bind('dragZoom', handleDragZoom); }; - + var handleSetup = function (evt) { console.debug("birdseye: handleSetup"); @@ -78,7 +79,7 @@ data.$birdDiv.show(); } }; - + var handleUpdate = function (evt) { console.debug("birdseye: handleUpdate"); data = this; @@ -87,7 +88,7 @@ setupBirdDrag(data); } }; - + var handleRedisplay = function (evt) { console.debug("birdseye: handleRedisplay"); data = this; @@ -95,7 +96,7 @@ updateBirdDiv(data); } }; - + var handleDragZoom = function (evt, zoomArea) { //console.debug("birdseye: handleDragZoom za="+zoomArea); data = this; @@ -103,7 +104,7 @@ setBirdZoom(data, zoomArea); } }; - + // returns URL for bird's eye view image var getBirdImgUrl = function (data) { var settings = data.settings; @@ -313,7 +314,7 @@ fn : {}, plugins : {} }; - + if ($.fn.digilib == null) { $.error("jquery.digilib.birdview must be loaded after jquery.digilib!"); } else { diff -r b07d1824ca2a -r 12f790cb30de client/digitallibrary/jquery/jquery.digilib.js --- a/client/digitallibrary/jquery/jquery.digilib.js Fri Feb 18 20:09:15 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Fri Feb 18 23:13:26 2011 +0100 @@ -1596,9 +1596,9 @@ getBorderWidth : getBorderWidth }; - // hook plugin into jquery + // hook digilib plugin into jquery $.fn.digilib = function (action) { - // plugin extension mechanism + // plugin extension mechanism, called when the plugins' code is read if (action === 'plugin') { var plugin = arguments[1]; // each plugin needs a name @@ -1615,7 +1615,7 @@ plugin.install(plugin); } } - // initialisation of plugins done later + // plugins will be initialised when action.init is called } else if (actions[action]) { // call action on this with the remaining arguments (inserting data as first argument) var $elem = $(this); @@ -1624,7 +1624,7 @@ args.unshift(data); return actions[action].apply(this, args); } else if (typeof action === 'object' || !action) { - // call init on this + // call init on the digilib jQuery object return actions.init.apply(this, arguments); } else { $.error('action ' + action + ' does not exist on jQuery.digilib'); diff -r b07d1824ca2a -r 12f790cb30de client/digitallibrary/jquery/jquery.digilib.regions.js --- a/client/digitallibrary/jquery/jquery.digilib.regions.js Fri Feb 18 20:09:15 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.regions.js Fri Feb 18 23:13:26 2011 +0100 @@ -15,8 +15,11 @@ var data; var buttons; var fn; + // affine geometry plugin stub var geom; + var FULL_AREA; + var buttons = { addregion : { onclick : "setRegion", @@ -39,25 +42,33 @@ icon : "regioninfo.png" } }; - var regionSet = ['addregion', 'delregion', 'regions', 'regioninfo', 'lessoptions']; + + var defaults = { + // are regions shown? + 'isRegionVisible' : true, + // buttonset of this plugin + 'regionSet' : ['addregion', 'delregion', 'regions', 'regioninfo', 'lessoptions'], + // array of defined regions + 'regions' : [] + }; var actions = { // define a region interactively with two clicked points "setRegion" : function(data) { - $elem = data.$elem; - $scaler = data.$scaler; + var $elem = data.$elem; + var $scaler = data.$scaler; + var picRect = geom.rectangle($scaler); var pt1, pt2; - var $regionDiv = $('