Skip to content

Instantly share code, notes, and snippets.

@mygoare
Created May 9, 2014 08:34
Show Gist options
  • Save mygoare/afd62eed7382f14db45a to your computer and use it in GitHub Desktop.
Save mygoare/afd62eed7382f14db45a to your computer and use it in GitHub Desktop.
jQuery Plugin snippet
(function($){
function Demo(props, settings)
{
this.demo = null;
if (typeof props == 'object')
{
settings = props;
}
this.options = $.extend({}, $.fn.demo.defaultSettings, settings || {});
}
Demo.prototype =
{
init: function(){
}
};
$.fn.demo = function(props, settings){
return this.each(function(){
var demo = new Demo(props, settings);
if (!this.el)
{
this.el = $(this);
demo.init();
this.el.data('demo', demo);
}
});
};
$.fn.demo.defaultSettings =
{
d: 0,
f: function () {
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment