# HG changeset patch # User robcast # Date 1294822286 -3600 # Node ID 3a2942d2d5cd22bba240d1a06fcd94bf9c0cc1a3 # Parent a6502d56bc96a4991a44382278756dfacc672fff version zero of jquery.digilib diff -r a6502d56bc96 -r 3a2942d2d5cd client/digitallibrary/jquery/jquery.digilib.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/digitallibrary/jquery/jquery.digilib.js Wed Jan 12 09:51:26 2011 +0100 @@ -0,0 +1,51 @@ +/* + * digilib jQuery plugin + * + */ + +(function($) { + + var methods = { + init : function(options) { + return this.each(function() { + var $this = $(this); + var data = $this.data('digilib'); + + // If the plugin hasn't been initialized yet + if (!data) { + + /* + * Do more setup stuff here + */ + + $(this).data('digilib', { + target : $this + }); + } + }); + }, + destroy : function() { + return this.each(function(){ + var $this = $(this); + var data = $this.data('digilib'); + // Namespacing FTW + $(window).unbind('.digilib'); // FIXME: 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' ); + } + }; + + +})(jQuery); \ No newline at end of file