Skip to content

Instantly share code, notes, and snippets.

@ryanlombardo
Last active August 29, 2015 13:56
Show Gist options
  • Save ryanlombardo/9009582 to your computer and use it in GitHub Desktop.
Save ryanlombardo/9009582 to your computer and use it in GitHub Desktop.
var BuzzFeed = {
create : function(core, moduleSelector) {
var Container = core.dom.query('#' + moduleSelector);
return {
find : function(selector) {
return Container.query(selector);
}
};
}
};
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