Mercurial > hg > digilib-old
comparison 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 |
comparison
equal
deleted
inserted
replaced
599:a6502d56bc96 | 604:3a2942d2d5cd |
---|---|
1 /* | |
2 * digilib jQuery plugin | |
3 * | |
4 */ | |
5 | |
6 (function($) { | |
7 | |
8 var methods = { | |
9 init : function(options) { | |
10 return this.each(function() { | |
11 var $this = $(this); | |
12 var data = $this.data('digilib'); | |
13 | |
14 // If the plugin hasn't been initialized yet | |
15 if (!data) { | |
16 | |
17 /* | |
18 * Do more setup stuff here | |
19 */ | |
20 | |
21 $(this).data('digilib', { | |
22 target : $this | |
23 }); | |
24 } | |
25 }); | |
26 }, | |
27 destroy : function() { | |
28 return this.each(function(){ | |
29 var $this = $(this); | |
30 var data = $this.data('digilib'); | |
31 // Namespacing FTW | |
32 $(window).unbind('.digilib'); // FIXME: unbinds all digilibs | |
33 data.digilib.remove(); | |
34 $this.removeData('digilib'); | |
35 }); | |
36 } | |
37 }; | |
38 | |
39 $.fn.digilib = function(method) { | |
40 | |
41 if (methods[method]) { | |
42 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); | |
43 } else if (typeof(method) === 'object' || !method) { | |
44 return methods.init.apply(this, arguments); | |
45 } else { | |
46 $.error( 'Method ' + method + ' does not exist on jQuery.digilib' ); | |
47 } | |
48 }; | |
49 | |
50 | |
51 })(jQuery); |