Skip to content

Instantly share code, notes, and snippets.

@jas-
Last active September 27, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jas-/1303525 to your computer and use it in GitHub Desktop.
Save jas-/1303525 to your computer and use it in GitHub Desktop.
jQuery method plug-in framework
(function($){
$.fn.tool = function(method) {
var defaults = defaults || {
foo: 'bar'
};
var methods = methods || {
init: function(opts) {
opts = $.extend({}, defaults, opts);
}
};
var util = util || {
init: function(opts) {
}
};
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 {
console.log('Method '+method+' does not exist');
return true;
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment