Skip to content

Instantly share code, notes, and snippets.

@dirq
Created February 18, 2015 21:47
Show Gist options
  • Save dirq/db47a4277250fa0ce101 to your computer and use it in GitHub Desktop.
Save dirq/db47a4277250fa0ce101 to your computer and use it in GitHub Desktop.
Webstorm Code Template - New JavaScript File with Closure
#set( $className = "$NAME.substring(0,1).toLowerCase()$NAME.substring(1)" )
/**
* Created by ${USER} on ${DATE}.
*/
var ${className} = (function () {
'use strict';
var self = {},
debug = true;
function log(msg) {
if (debug && console && console.log) {
console.log(msg);
}
}
self.init = function () {
log('init');
};
return self;
}());
//plan JS load
if (document.addEventListener) {
//For modern browsers:
document.addEventListener('DOMContentLoaded', ${className}.init, false);
}
else if (document.attachEvent) {
//For IE:
document.attachEvent('onreadystatechange', ${className}.init);
}
//jquery load
//$(${className}.init);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment