Mercurial > hg > digilib-old
view client/digitallibrary/jquery/jquery.digilib.js @ 604:3a2942d2d5cd jquery
version zero of jquery.digilib
author | robcast |
---|---|
date | Wed, 12 Jan 2011 09:51:26 +0100 |
parents | |
children | aee94e4a8c48 |
line wrap: on
line source
/* * 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);