Last active
August 29, 2015 13:56
-
-
Save ryanlombardo/9009582 to your computer and use it in GitHub Desktop.
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 BuzzFeed = { | |
create : function(core, moduleSelector) { | |
var Container = core.dom.query('#' + moduleSelector); | |
return { | |
find : function(selector) { | |
return Container.query(selector); | |
} | |
}; | |
} | |
}; |
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 Core = (function() { | |
var moduleData = {}, | |
debug = true; | |
return { | |
define : function(moduleID, creator) { | |
var temp; | |
if(typeof moduleID === 'string' && typeof creator === 'function') { | |
temp = creator(BuzzFeed.create(this, moduleID)); | |
if(temp.init && typeof temp.init === 'function' && temp.destroy && typeof temp.destroy === 'function') { | |
temp = null; | |
moduleData[moduleID] = { | |
create : creator, | |
instance : null | |
}; | |
} else { | |
// Log missing init and/or destroy methods | |
} | |
} else { | |
// Log incorrect parameters | |
} | |
}, | |
dom : { | |
query : function(selector, context) { | |
var i = 0, | |
ret = {}, | |
that = this, | |
jqEls; | |
if(context && context.find) { | |
jqEls = context.find(selector); | |
} else { | |
jqEls = jQuery(selector); | |
} | |
ret = jqEls.get(); | |
ret.length = jqEls.length; | |
ret.query = function(sel) { | |
return that.query(sel, jqEls); | |
}; | |
return ret; | |
} | |
} | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment