Mercurial > hg > digilib-old
changeset 605:aee94e4a8c48 jquery
next version zero of jquery.digilib
author | robcast |
---|---|
date | Wed, 12 Jan 2011 19:36:11 +0100 |
parents | 3a2942d2d5cd |
children | 8204615dad77 |
files | client/digitallibrary/jquery/jquery.digilib.js |
diffstat | 1 files changed, 41 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js Wed Jan 12 09:51:26 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Wed Jan 12 19:36:11 2011 +0100 @@ -4,22 +4,37 @@ */ (function($) { + + var defaults = { + /* base URL to Scaler servlet */ + 'scalerUrl' : 'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler', + /* digilib image path i.e. fn */ + 'imagePath' : '', + /* mode of operation. + * fullscreen: takes parameters from page URL, keeps state in page URL + * embedded: takes parameters from Javascript options, keeps state inside object + */ + 'interactionMode' : 'fullscreen' + }; + + /* parameters from the query string */ + var params = {}; var methods = { init : function(options) { return this.each(function() { - var $this = $(this); - var data = $this.data('digilib'); - + var $elem = $(this); + var data = $elem.data('digilib'); // If the plugin hasn't been initialized yet if (!data) { - - /* - * Do more setup stuff here - */ - - $(this).data('digilib', { - target : $this + // settings for this digilib instance are merged from defaults and options + var settings = $.extend({}, defaults, options); + // merge query parameters + settings = $.extend(settings, parseParams(settings.interactionMode)); + // store in data element + $elem.data('digilib', { + target : $elem, + settings : settings }); } }); @@ -29,23 +44,27 @@ var $this = $(this); var data = $this.data('digilib'); // Namespacing FTW - $(window).unbind('.digilib'); // FIXME: unbinds all digilibs + $(window).unbind('.digilib'); // unbinds all digilibs(?) data.digilib.remove(); $this.removeData('digilib'); }); } - }; + }; - $.fn.digilib = function(method) { - - if (methods[method]) { - return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); - } else if (typeof(method) === 'object' || !method) { - return methods.init.apply(this, arguments); - } else { - $.error( 'Method ' + method + ' does not exist on jQuery.digilib' ); - } - }; + // returns object with parameters from the query string or an embedded img-tag (depending on interactionMode) + var parseParams = function(interactionMode) { + alert("parseParams() not implemented"); + }; + // hook plugin into jquery + $.fn.digilib = function(method) { + if (methods[method]) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof(method) === 'object' || !method) { + return methods.init.apply(this, arguments); + } else { + $.error( 'Method ' + method + ' does not exist on jQuery.digilib' ); + } + }; })(jQuery); \ No newline at end of file