changeset 604:3a2942d2d5cd jquery

version zero of jquery.digilib
author robcast
date Wed, 12 Jan 2011 09:51:26 +0100
parents a6502d56bc96
children aee94e4a8c48
files client/digitallibrary/jquery/jquery.digilib.js
diffstat 1 files changed, 51 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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