Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arnogues/31206cd15020b7f4d326 to your computer and use it in GitHub Desktop.
Save arnogues/31206cd15020b7f4d326 to your computer and use it in GitHub Desktop.
Javascript Class Template for webstorm
/**
* Class Jquery Prototype ${USER} ${DATE}
*/
/* global Utils */
'use strict';
(function ($, context) {
var ${className} = context.${className} = function () {
this.init.apply(this, arguments);
};
${className}.prototype = {
constructor: ${className}.prototype.constructor,
options: {
},
/**
* Constructor
*/
init: function (element, options) {
this.options = $.extend(true, {}, this.options, options, Utils.getOptionsFromDom('${className.toLowerCase()}', element));
this.${DS}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.${className.substring(0,1).toLowerCase()}${className.substring(1)} = function(options) {
return this.each(function() {
if(!$(this).data('${className}-plugin')) {
$(this).data('${className}-plugin', new ${className}(this, options));
}
});
};
})(jQuery, window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment