# HG changeset patch # User hertzhaft # Date 1298204689 -3600 # Node ID ae8e98c479d5b51e29d916d60790b6a25f9ec4d2 # Parent 1b172892653450f16e89319d63e90a20d8ec0f61 stub for new plugins; overlay div for regions plugin diff -r 1b1728926534 -r ae8e98c479d5 client/digitallibrary/jquery/jquery-digilib-plugins.txt --- a/client/digitallibrary/jquery/jquery-digilib-plugins.txt Sun Feb 20 11:55:51 2011 +0100 +++ b/client/digitallibrary/jquery/jquery-digilib-plugins.txt Sun Feb 20 13:24:49 2011 +0100 @@ -40,3 +40,8 @@ "update", updateDisplay(): after small updates in the display, e.g. when the scaler-img finished loading. "redisplay", redisplay(): after changes in the display, e.g. after changing zoom factor. "dragZoom(newZoomArea)": while dragging the zoom area (with parameter newZoomArea). + +* initial options for the plugin can be passed to digilib, together with digilib options, by passing an object to the 'digilib' function: $div.digilib(options); +The passed options extend/override the default digilib options. The options are stored in the "data.settings" array. + +* A functional stub for new digilib plugins is available in the file "jquery.digilib.pluginstub.js" diff -r 1b1728926534 -r ae8e98c479d5 client/digitallibrary/jquery/jquery-test-full.html --- a/client/digitallibrary/jquery/jquery-test-full.html Sun Feb 20 11:55:51 2011 +0100 +++ b/client/digitallibrary/jquery/jquery-test-full.html Sun Feb 20 13:24:49 2011 +0100 @@ -61,6 +61,7 @@ + diff -r 1b1728926534 -r ae8e98c479d5 client/digitallibrary/jquery/jquery.digilib.birdseye.js --- a/client/digitallibrary/jquery/jquery.digilib.birdseye.js Sun Feb 20 11:55:51 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.birdseye.js Sun Feb 20 13:24:49 2011 +0100 @@ -45,6 +45,7 @@ // plugin installation called by digilib on plugin object. var install = function(digilib) { + console.debug('installing birdseye plugin. digilib:', digilib); // import geometry classes geom = digilib.fn.geometry; FULL_AREA = geom.rectangle(0,0,1,1); @@ -61,6 +62,7 @@ // plugin initialization var init = function (data) { + console.debug('initialising birdseye plugin. data:', data); var $data = $(data); // install event handler $data.bind('setup', handleSetup); @@ -305,7 +307,7 @@ // plugin object with name and init // shared objects filled by digilib on registration - var digilib = { + var plugin = { name : 'birdseye', install : install, init : init, @@ -318,6 +320,6 @@ if ($.fn.digilib == null) { $.error("jquery.digilib.birdview must be loaded after jquery.digilib!"); } else { - $.fn.digilib('plugin', digilib); + $.fn.digilib('plugin', plugin); } })(jQuery); diff -r 1b1728926534 -r ae8e98c479d5 client/digitallibrary/jquery/jquery.digilib.pluginstub.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/digitallibrary/jquery/jquery.digilib.pluginstub.js Sun Feb 20 13:24:49 2011 +0100 @@ -0,0 +1,95 @@ +/** +digilib plugin stub + */ + +(function($) { + + var geom; + + var FULL_AREA; + + var buttons = { + stub : { + onclick : ["doStub", 1], + tooltip : "what does this button do?", + icon : "stub.png" + } + }; + + var defaults = { + // is stub active? + 'isStubActive' : true + }; + + var actions = { + // action code goes here + doStub : function (data, param) { + var settings = data.settings; + console.log('isStubActive', settings.isStubActive); + // do some useful stuff ... + } + }; + + // plugin installation called by digilib on plugin object. + var install = function(digilib) { + console.debug('installing stub plugin. digilib:', digilib); + // import geometry classes + geom = digilib.fn.geometry; + FULL_AREA = geom.rectangle(0,0,1,1); + // add defaults + $.extend(digilib.defaults, defaults); + // add actions + $.extend(digilib.actions, actions); + // add buttons + $.extend(digilib.buttons, buttons); + }; + + // plugin initialization + var init = function (data) { + console.debug('initialising stub plugin. data:', data); + var $data = $(data); + // install event handler + $data.bind('setup', handleSetup); + $data.bind('update', handleUpdate); + $data.bind('redisplay', handleRedisplay); + $data.bind('dragZoom', handleDragZoom); + }; + + + var handleSetup = function (evt) { + console.debug("stub: handleSetup"); + var data = this; + }; + + var handleUpdate = function (evt) { + console.debug("stub: handleUpdate"); + var data = this; + }; + + var handleRedisplay = function (evt) { + console.debug("stub: handleRedisplay"); + var data = this; + }; + + var handleDragZoom = function (evt, zoomArea) { + var data = this; + }; + + // plugin object with name and init + // shared objects filled by digilib on registration + var plugin = { + name : 'pluginstub', + install : install, + init : init, + buttons : {}, + actions : {}, + fn : {}, + plugins : {} + }; + + if ($.fn.digilib == null) { + $.error("jquery.digilib.pluginstub must be loaded after jquery.digilib!"); + } else { + $.fn.digilib('plugin', plugin); + } +})(jQuery); diff -r 1b1728926534 -r ae8e98c479d5 client/digitallibrary/jquery/jquery.digilib.regions.js --- a/client/digitallibrary/jquery/jquery.digilib.regions.js Sun Feb 20 11:55:51 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.regions.js Sun Feb 20 13:24:49 2011 +0100 @@ -53,61 +53,66 @@ }; var actions = { + // define a region interactively with two clicked points "setRegion" : function(data) { var $elem = data.$elem; + var $body = $('body'); + var bodyRect = geom.rectangle($body); var $scaler = data.$scaler; - var picRect = geom.rectangle($scaler); + var scalerRect = geom.rectangle($scaler); var pt1, pt2; - // TODO: temporary rectangle only, pass values to "addRegion" factory - var $tempDiv = $('