router doesn't require jQuery. use default params

This commit is contained in:
QWp6t
2016-07-16 10:02:03 -07:00
parent 34253864fa
commit 339cc8e01e
2 changed files with 10 additions and 19 deletions

View File

@@ -21,11 +21,11 @@ import 'bootstrap/dist/js/umd/popover.js';
// rename this variable, you will also need to rename the namespace below.
const routes = {
// All pages
'common': Common,
common: Common,
// Home page
'home': Home,
home: Home,
// About us page, note the change from about-us to about_us.
'about_us': About
about_us: About
};
// Load Events

View File

@@ -1,5 +1,3 @@
import $ from 'jquery';
/* ========================================================================
* DOM-based Routing
* Based on http://goo.gl/EUTi53 by Paul Irish
@@ -15,14 +13,10 @@ export default class Router {
this.routes = routes;
}
fire(func, funcname, args) {
funcname = (funcname === undefined) ? 'init' : funcname;
let fire = func !== '';
fire = fire && this.routes[func];
fire = fire && typeof this.routes[func][funcname] === 'function';
fire(route, fn = 'init', args) {
let fire = route !== '' && this.routes[route] && typeof this.routes[route][fn] === 'function';
if (fire) {
this.routes[func][funcname](args);
this.routes[route][fn](args);
}
}
@@ -31,13 +25,10 @@ export default class Router {
this.fire('common');
// Fire page-specific init JS, and then finalize JS
$.each(
document.body.className.replace(/-/g, '_').split(/\s+/),
(i, className) => {
this.fire(className);
this.fire(className, 'finalize');
}
);
document.body.className.replace(/-/g, '_').split(/\s+/).forEach((className) => {
this.fire(className);
this.fire(className, 'finalize');
});
// Fire common finalize JS
this.fire('common', 'finalize');