Mercurial > hg > digilib-old
diff client/digitallibrary/jquery/jquery.digilib.pluginstub.js @ 808:ae8e98c479d5 jquery
stub for new plugins; overlay div for regions plugin
author | hertzhaft |
---|---|
date | Sun, 20 Feb 2011 13:24:49 +0100 |
parents | |
children | 1a7b14deae3a |
line wrap: on
line diff
--- /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);