Add comments to _main.js, remove finalize

This commit is contained in:
Ben Word
2014-01-18 18:43:25 -06:00
parent 9663bb489f
commit d6fc59e041
3 changed files with 15 additions and 14 deletions

View File

@@ -1,45 +1,46 @@
// Modified http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/ /* ========================================================================
// Only fires on body class (working off strictly WordPress body_class) * DOM-based Routing
* Based on http://goo.gl/EUTi53 by Paul Irish
*
* Only fires on body classes that match. If a body class contains a dash,
* replace the dash with an underscore when adding it to the object below.
* ======================================================================== */
var ExampleSite = { var Roots = {
// All pages // All pages
common: { common: {
init: function() { init: function() {
// JS here // JavaScript to be fired on all pages
}, }
finalize: function() { }
}, },
// Home page // Home page
home: { home: {
init: function() { init: function() {
// JS here // JavaScript to be fired on the home page
} }
}, },
// About page // About page
about: { about: {
init: function() { init: function() {
// JS here // JavaScript to be fired on the about page
} }
} }
}; };
var UTIL = { var UTIL = {
fire: function(func, funcname, args) { fire: function(func, funcname, args) {
var namespace = ExampleSite; var namespace = Roots;
funcname = (funcname === undefined) ? 'init' : funcname; funcname = (funcname === undefined) ? 'init' : funcname;
if (func !== '' && namespace[func] && typeof namespace[func][funcname] === 'function') { if (func !== '' && namespace[func] && typeof namespace[func][funcname] === 'function') {
namespace[func][funcname](args); namespace[func][funcname](args);
} }
}, },
loadEvents: function() { loadEvents: function() {
UTIL.fire('common'); UTIL.fire('common');
$.each(document.body.className.replace(/-/g, '_').split(/\s+/),function(i,classnm) { $.each(document.body.className.replace(/-/g, '_').split(/\s+/),function(i,classnm) {
UTIL.fire(classnm); UTIL.fire(classnm);
}); });
UTIL.fire('common', 'finalize');
} }
}; };

File diff suppressed because one or more lines are too long

View File

@@ -27,7 +27,7 @@ function roots_scripts() {
} }
wp_register_script('modernizr', get_template_directory_uri() . '/assets/js/vendor/modernizr-2.7.0.min.js', array(), null, false); wp_register_script('modernizr', get_template_directory_uri() . '/assets/js/vendor/modernizr-2.7.0.min.js', array(), null, false);
wp_register_script('roots_scripts', get_template_directory_uri() . '/assets/js/scripts.min.js', array(), '01d073428e4e54f227f8a0a3bad4b804', true); wp_register_script('roots_scripts', get_template_directory_uri() . '/assets/js/scripts.min.js', array(), '0c433827b6da033cda9b7082ca2812e2', true);
wp_enqueue_script('modernizr'); wp_enqueue_script('modernizr');
wp_enqueue_script('jquery'); wp_enqueue_script('jquery');
wp_enqueue_script('roots_scripts'); wp_enqueue_script('roots_scripts');