Skip to content

Instantly share code, notes, and snippets.

@paceaux
Created June 3, 2014 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paceaux/57fbcb7597074754c14f to your computer and use it in GitHub Desktop.
Save paceaux/57fbcb7597074754c14f to your computer and use it in GitHub Desktop.
Vanilla JS module
var moduleName;
moduleName = {
init: function () {
var _this = moduleName;
_this.bindUiEvents();
},
data: {
els: {
}
},
helpers: {
addEvents: function (els, evt, func) {
if (els.length !== undefined) {
[].forEach.call(els, function (el) {
el.addEventListener(evt, func);
});
} else {
els.addEventListener(evt, func);
}
},
hasClass: function (el, elClass) {
return (' ' + el.className + ' ').indexOf(' ' + elClass + ' ') > -1;
},
getParentByClass: function (el, parentClass) {
var _this = moduleName;
do {
el = el.parentElement;
}
while (_this.helpers.hasClass(el,parentClass) === false);
return el;
}
},
bindUiEvents: function () {
var _this = moduleName;
},
functions: {
}
};
moduleName.init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment