Last active
August 31, 2016 06:34
-
-
Save etiennetalbot/e7f72a915d97f026ac8f to your computer and use it in GitHub Desktop.
Javascript Module
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
/*jslint nomen: true */ | |
window.App = window.App || {}; | |
window.App.ModuleName = (function (document, $) { | |
'use strict'; //OPTIONAL if you don't want your code to be strict | |
var _vars, _els, _privateMethod, init; | |
// Module's common variables (private) | |
_vars = { | |
//someVariable: true | |
}; | |
// Module's common elements (private) | |
_els = { | |
//someElement: document.querySelectorAll('.js-something') || $('.js-something'), | |
}; | |
/* -------------------------------------------- | |
Private method example (private) | |
Function is called on init | |
@Params: none | |
@Returns: undefined | |
*/ | |
_privateMethod = function () { | |
// private stuff | |
}; | |
/* -------------------------------------------- | |
Init Module's methods (public) | |
Function is called on document ready | |
@Params: none | |
@Returns: undefined | |
*/ | |
init = function () { | |
_privateMethod(); | |
}; | |
// Return all public methods | |
return { | |
init: init | |
}; | |
}(window.document, window.jQuery)); | |
// Start this module | |
window.jQuery(window.document).on('ready', App.ModuleName.init); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment