Last active
July 6, 2016 05:34
-
-
Save jmcorpdev/31206cd15020b7f4d326 to your computer and use it in GitHub Desktop.
Javascript Class Template for webstorm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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