Skip to content

Instantly share code, notes, and snippets.

@arnogues
Last active August 29, 2015 14:04
Show Gist options
  • Save arnogues/19f462338b51995b786a to your computer and use it in GitHub Desktop.
Save arnogues/19f462338b51995b786a to your computer and use it in GitHub Desktop.
/**
* Class Prototype ${USER} ${DATE}
*/
/* global Utils */
'use strict';
(function ($, context) {
var ${NAME} = context.${NAME} = function () {
this.init.apply(this, arguments);
};
${NAME}.prototype = {
constructor: ${NAME}.prototype.constructor,
options: {
},
/**
* Constructor
*/
init: function (element, options) {
this.options = $.extend(true, {}, this.options, options, Utils.getOptionsFromDom('${lowercaseName}', element));
this.\$element = $(element);
this.create();
this.events();
},
/**
* Create dom and init dom references to this
*/
create: function () {
},
/**
* Init all events
*/
events: function () {
}
};
//jquery plugin implementation
$.fn.${NAME} = function(options) {
return this.each(function() {
if(!$(this).data('${NAME}-plugin')) {
$(this).data('${NAME}-plugin', new ${NAME}(this, options));
}
});
};
})(jQuery, window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment