Files
sage/assets/js/_main.js
2013-02-22 20:17:48 +01:00

47 lines
1006 B
JavaScript

// Modified http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/
// Only fires on body class (working off strictly WordPress body_class)
var ExampleSite = {
// All pages
common: {
init: function() {
// JS here
},
finalize: function() { }
},
// Home page
home: {
init: function() {
// JS here
}
},
// About page
about: {
init: function() {
// JS here
}
}
};
var UTIL = {
fire: function(func, funcname, args) {
var namespace = ExampleSite;
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');
}
};
$(document).ready(UTIL.loadEvents);