Skip to content

Instantly share code, notes, and snippets.

@jacksonhoose
Last active April 21, 2018 12:22
Show Gist options
  • Save jacksonhoose/737d5a7a0a8d3db68cf1 to your computer and use it in GitHub Desktop.
Save jacksonhoose/737d5a7a0a8d3db68cf1 to your computer and use it in GitHub Desktop.
Paul Irish's Markup-based Unobtrusive Comprehensive DOM-ready Execution
var ODPHP = {};
ODPHP.common = {
init: function() {
// common code running on all pages
}
};
ODPHP.objective_search = {
init: function() {
// objective search initi
}
};
var UTIL = {
fire: function(func, funcname, args) {
var namespace = ODPHP;
funcname = (funcname === undefined) ? 'init' : funcname;
if (func !== '' && namespace[func] && typeof namespace[func][funcname] === 'function') {
namespace[func][funcname](args);
}
},
loadEvents: function() {
UTIL.fire('common');
$.each(document.body.className.replace(/-/g, '_').split(/\s+/),function(i,classnm) {
UTIL.fire(classnm);
});
UTIL.fire('common', 'finalize');
}
};
jQuery(function($){
$(document).ready(UTIL.loadEvents);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment