# HG changeset patch # User robcast # Date 1298038590 -3600 # Node ID 63c1b33e38b1d342eb6f897876f690d4247ada8a # Parent 304488c72344af422cc836e8d10e45f69c68eb90 documentation for new plugin api in jquery-digilib-plugin.txt. more steps towards plugification of birdseye view. diff -r 304488c72344 -r 63c1b33e38b1 client/digitallibrary/jquery/jquery-digilib-plugins.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/digitallibrary/jquery/jquery-digilib-plugins.txt Fri Feb 18 15:16:30 2011 +0100 @@ -0,0 +1,38 @@ + +The plugin API of jquery.digilib +-------------------------------- + +* The plugin Javascript file has to be loaded after jquery.digilib.js. + +* The plugin should be written as a closure on jQuery (like a jquery plugin) exporting a plugin object as its interface: + + var plugin = { + name : 'mydigilibplugin', + install : install, + init : init, + buttons : {}, + actions : {}, + fn : {}, + plugins : {}, + defaults : {} + }; + + The "name" string, "install" function and "init" function are provided by the plugin and called by digilib. + "buttons", "actions", "fn" and "plugins" are shared objects provided by digilib. + "buttons" is the array of button objects. The plugin can add its own buttons to this array. + "actions" is the array of action objects. The plugin can add its own actions to this array. + "fn" is an object with functions from digilib. + "plugins" is an object with all digilib plugin objects. + "defaults" is an object with all digilib defaults. + +* the plugin object is passed to digilib in the "plugin" action on loading the plugin javascript file: + + $.fn.digilib('plugin', plugin); + + digilib then calls the "install" function on the populated plugin object (i.e. this = plugin) with the plugin object as parameter. + +* digilib calls the "init" function from the plugin object with the data object instance as a parameter in digilibs init phase. + +* further actions should be implemented as custom events on the data object. + +* events should be documented here... diff -r 304488c72344 -r 63c1b33e38b1 client/digitallibrary/jquery/jquery.digilib.birdseye.js --- a/client/digitallibrary/jquery/jquery.digilib.birdseye.js Fri Feb 18 10:39:40 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.birdseye.js Fri Feb 18 15:16:30 2011 +0100 @@ -8,13 +8,34 @@ var FULL_AREA; + var buttons = { + bird : { + onclick : "showBirdDiv", + tooltip : "show bird's eye view", + icon : "birds-eye.png" + } + }; + var actions = { + // event handler: toggles the visibility of the bird's eye window + showBirdDiv : function (data, show) { + var settings = data.settings; + if (data.$birdDiv == null) { + // no bird div -> create + setupBirdDiv(data); + } + var on = showDiv(settings.isBirdDivVisible, data.$birdDiv, show); + settings.isBirdDivVisible = on; + highlightButtons(data, 'bird', on); + updateBirdDiv(data); + storeOptions(data); + } }; - // init: plugin initialization - var plugInit = function(data) { + // plugin initialization called by digilib on plugin object. + var install = function() { // import geometry classes - geom = digilib.fn.geometry; + geom = this.fn.geometry; FULL_AREA = digilib.fn.FULL_AREA; // TODO: add actions // TODO: add buttons @@ -22,11 +43,225 @@ }; + // returns URL for bird's eye view image + var getBirdImgUrl = function (data, moreParams) { + var settings = data.settings; + var birdDivOptions = { + dw : settings.birdDivWidth, + dh : settings.birdDivHeight + }; + var birdSettings = $.extend({}, settings, birdDivOptions); + // use only the relevant parameters + if (moreParams == null) { + var params = getParamString(birdSettings, settings.birdDivParams, defaults); + } else { + // filter scaler flags + if (birdSettings.mo != null) { + var mo = ''; + if (data.scalerFlags.hmir != null) { + mo += 'hmir,'; + } + if (data.scalerFlags.vmir != null) { + mo += 'vmir'; + } + birdSettings.mo = mo; + } + var params = getParamString(birdSettings, + settings.birdDivParams.concat(moreParams), defaults); + } + var url = settings.scalerBaseUrl + '?' + params; + return url; + }; + + // creates HTML structure for the bird's eye view in elem + var setupBirdDiv = function (data) { + var $elem = data.$elem; + // the bird's eye div + var $birdDiv = $('