Skip to content

Instantly share code, notes, and snippets.

@jookyboi
Created July 30, 2013 00:18
Show Gist options
  • Save jookyboi/6109051 to your computer and use it in GitHub Desktop.
Save jookyboi/6109051 to your computer and use it in GitHub Desktop.
var Plugin = function($self, options) {
this.$self = $self;
this.options = $.extend({}, $.fn.plugin.defaults, options);
};
Plugin.prototype.display = function(){
console.debug("Plugin.display");
};
Plugin.prototype.update = function() {
console.debug("Plugin.update");
};
$.fn.plugin = function(option) {
var options = typeof option == "object" && option;
return this.each(function() {
var $this = $(this);
var $plugin = $this.data("plugin");
if(!$plugin) {
$plugin = new Plugin($this, options);
$this.data("plugin", $plugin);
}
if (typeof option == 'string') {
$plugin[option]();
} else {
$plugin.display();
}
});
};
$.fn.plugin.defaults = {
propname: "propdefault"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment