The First One:
(function($) {
$.fn.joey = function(options) {
debug(this);
var opts = $.extend({}, $.fn.joey.defaults, options);
return this.each(function() {
$this = $(this);
// build element specific options
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
// do something
});
};
// private function for debugging
function debug($obj) {
if (window.console && window.console.log)
window.console.log('joey selection count: ' + $obj.size());
}
;
// plugin defaults
$.fn.joey.defaults = {
// some options
};
})(jQuery);
The Other One:
;(function($) {
$.fn.theplugin = function(options) {
debug(this);
var opts = $.extend({}, $.fn.theplugin.defaults, options);
if (this.length > 1) {
this.each(function() {
$(this).theplugin(options)
});
return this;
}
this.initialize = function() {
$this = $(this);
// build element specific options
var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
// do something
return this;
};
// public function
this.foo = function() {
// do someting
}
// private fucntion
function debug($obj) {
if (window.console && window.console.log)
window.console.log('theplugin selection count: ' + $obj.size());
}
;
// plugin defaults
$.fn.theplugin.defaults = {
// options
};
return this.initialize();
}
})(jQuery);