get element utils

This commit is contained in:
Adam Bradley
2013-08-23 13:11:56 -05:00
parent dedfe2dc69
commit 63cc305579
2 changed files with 21 additions and 5 deletions

View File

@ -1,11 +1,24 @@
(function(window, document, framework) {
framework.get = function(id) {
return document.getElementById(id);
};
framework.getByClass = function(classname) {
return document.getElementByClassName(classname);
};
framework.getByTag = function(tagName) {
return document.getElementsByTagName(tagName);
};
framework.trigger = function(type, data) {
window.dispatchEvent( new CustomEvent(type, data) );
};
framework.on = function(type, callback) {
window.addEventListener(type, callback);
framework.on = function(type, callback, element) {
var e = element || window;
e.addEventListener(type, callback);
};
})(this, document, this.FM = this.FM || {});