Skip to content

Instantly share code, notes, and snippets.

@ace4gi
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save ace4gi/10960090 to your computer and use it in GitHub Desktop.

Select an option

Save ace4gi/10960090 to your computer and use it in GitHub Desktop.
jQuery - Flugin format
;(function($){
'use strict';
if (!Raphael) { throw new Error("jquery.PluginName.js - requires xxx"); }
var PluginName = function(element, _options){
this.$element = $(element);
this.options = _options;
}
PluginName.DEFAULTS = {
}
PluginName.prototype.show = function($escape){
this.$element.show();
}
PluginName.prototype.hide = function($escape){
}
$.fn.pluginName = function(_options){
return this.each(function(){
var $this = $(this),
data = $this.data('ui.pluginName'),
options = $.extend({}, PluginName.DEFAULTS, $this.data(), typeof _options == 'object' && _options);
if(!data) $this.data('ui.pluginName', (data = new PluginName(this, options)));
if(typeof _options == 'string') data[_options]();
else data.show();
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment