Skip to content

Instantly share code, notes, and snippets.

@etiennetalbot
Last active August 31, 2016 06:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etiennetalbot/e7f72a915d97f026ac8f to your computer and use it in GitHub Desktop.
Save etiennetalbot/e7f72a915d97f026ac8f to your computer and use it in GitHub Desktop.
Javascript Module
/*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