1
- import $ from 'jquery' ;
2
-
3
1
/* ========================================================================
4
2
* DOM-based Routing
5
3
* Based on http://goo.gl/EUTi53 by Paul Irish
@@ -15,14 +13,10 @@ export default class Router {
15
13
this . routes = routes ;
16
14
}
17
15
18
- fire ( func , funcname , args ) {
19
- funcname = ( funcname === undefined ) ? 'init' : funcname ;
20
- let fire = func !== '' ;
21
- fire = fire && this . routes [ func ] ;
22
- fire = fire && typeof this . routes [ func ] [ funcname ] === 'function' ;
23
-
16
+ fire ( route , fn = 'init' , args ) {
17
+ let fire = route !== '' && this . routes [ route ] && typeof this . routes [ route ] [ fn ] === 'function' ;
24
18
if ( fire ) {
25
- this . routes [ func ] [ funcname ] ( args ) ;
19
+ this . routes [ route ] [ fn ] ( args ) ;
26
20
}
27
21
}
28
22
@@ -31,13 +25,10 @@ export default class Router {
31
25
this . fire ( 'common' ) ;
32
26
33
27
// Fire page-specific init JS, and then finalize JS
34
- $ . each (
35
- document . body . className . replace ( / - / g, '_' ) . split ( / \s + / ) ,
36
- ( i , className ) => {
37
- this . fire ( className ) ;
38
- this . fire ( className , 'finalize' ) ;
39
- }
40
- ) ;
28
+ document . body . className . replace ( / - / g, '_' ) . split ( / \s + / ) . forEach ( ( className ) => {
29
+ this . fire ( className ) ;
30
+ this . fire ( className , 'finalize' ) ;
31
+ } ) ;
41
32
42
33
// Fire common finalize JS
43
34
this . fire ( 'common' , 'finalize' ) ;
0 commit comments