Created
June 3, 2014 22:24
-
-
Save paceaux/57fbcb7597074754c14f to your computer and use it in GitHub Desktop.
Vanilla JS 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
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