Created
July 17, 2009 22:42
-
-
Save charliek/149322 to your computer and use it in GitHub Desktop.
JQuery Template v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.myplugin = function(options){ | |
// support mutltiple elements | |
if (this.length > 1){ | |
this.each(function() { $(this).myplugin(options) }); | |
return this; | |
} | |
// private variables | |
var opts = $.extend({}, $.fn.myplugin.defaults, options); | |
// private functions | |
var log = function(msg){ | |
if (window.console && window.console.log) | |
window.console.log(msg); | |
}; | |
// public functions | |
this.init = function(){ | |
return this; | |
}; | |
this.doSomething = function(num){ | |
}; | |
return this.init(); | |
}; | |
// class functions | |
$.fn.myplugin.do_something = function(txt) { | |
return '<strong>' + txt + '</strong>'; | |
}; | |
// plugin defaults set publicly so that they can be changed globally. | |
$.fn.myplugin.defaults = { | |
foreground: 'red', | |
background: 'yellow' | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment