1- import  Base  from  "../../core/base" ; 
1+ import  $  from  "jquery" ; 
2+ import  {  BasePattern  }  from  "../../core/basepattern" ; 
23import  Parser  from  "../../core/parser" ; 
34import  logging  from  "../../core/logging" ; 
45import  events  from  "../../core/events" ; 
6+ import  registry  from  "../../core/registry" ; 
57
68const  log  =  logging . getLogger ( "navigation" ) ; 
79
@@ -10,16 +12,18 @@ parser.addArgument("item-wrapper", "li");
1012parser . addArgument ( "in-path-class" ,  "navigation-in-path" ) ; 
1113parser . addArgument ( "current-class" ,  "current" ) ; 
1214
13- export  default  Base . extend ( { 
14-     name : "navigation" , 
15-     trigger : ".pat-navigation" , 
15+ class  Pattern  extends  BasePattern  { 
16+     static  name  =  "navigation" ; 
17+     static  trigger  =  ".pat-navigation" ; 
18+     static  parser  =  parser ; 
1619
1720    init ( )  { 
1821        this . options  =  parser . parse ( this . el ,  this . options ) ; 
22+         this . $el  =  $ ( this . el ) ; 
1923
2024        this . init_listeners ( ) ; 
2125        this . init_markings ( ) ; 
22-     } , 
26+     } 
2327
2428    /** 
2529     * Initialize listeners for the navigation. 
@@ -64,7 +68,7 @@ export default Base.extend({
6468            } ) ; 
6569            this . el . querySelector ( `a.${ current }  , .${ current }   a` ) ?. click ( ) ; 
6670        } 
67-     } , 
71+     } 
6872
6973    /** 
7074     * Initial run to mark the current item and its parents. 
@@ -77,7 +81,7 @@ export default Base.extend({
7781            log . debug ( "Mark navigation items based on URL pattern." ) ; 
7882            this . mark_items_url ( ) ; 
7983        } 
80-     } , 
84+     } 
8185
8286    /** 
8387     * Get a matching parent or stop at stop_el. 
@@ -99,7 +103,7 @@ export default Base.extend({
99103            } 
100104            matching_parent  =  matching_parent . parentNode ; 
101105        } 
102-     } , 
106+     } 
103107
104108    /** 
105109     * Mark an item and it's wrapper as current. 
@@ -120,7 +124,7 @@ export default Base.extend({
120124            this . mark_in_path ( wrapper  ||  item ) ; 
121125            log . debug ( "Statically set current item marked as current" ,  item ) ; 
122126        } 
123-     } , 
127+     } 
124128
125129    /** 
126130     * Mark all parent navigation elements as in path. 
@@ -140,7 +144,7 @@ export default Base.extend({
140144            } 
141145            path_el  =  this . get_parent ( path_el ,  this . options . itemWrapper ,  this . el ) ; 
142146        } 
143-     } , 
147+     } 
144148
145149    /** 
146150     * Mark all navigation items that are in the path of the current url. 
@@ -183,7 +187,7 @@ export default Base.extend({
183187                continue ; 
184188            } 
185189        } 
186-     } , 
190+     } 
187191
188192    /** 
189193     * Clear all navigation items from the inPath and current classes 
@@ -196,7 +200,7 @@ export default Base.extend({
196200            item . classList . remove ( this . options . inPathClass ) ; 
197201            item . classList . remove ( this . options . currentClass ) ; 
198202        } 
199-     } , 
203+     } 
200204
201205    /** 
202206     * Prepare a URL for comparison. 
@@ -208,7 +212,7 @@ export default Base.extend({
208212     */ 
209213    prepare_url ( url )  { 
210214        return  url ?. replace ( "/view" ,  "" ) . replaceAll ( "@@" ,  "" ) . replace ( / \/ $ / ,  "" ) ; 
211-     } , 
215+     } 
212216
213217    /** 
214218     * Get the URL of the current page. 
@@ -223,5 +227,9 @@ export default Base.extend({
223227            document . querySelector ( 'head link[rel="canonical"]' ) ?. href  || 
224228                window . location . href 
225229        ) ; 
226-     } , 
227- } ) ; 
230+     } 
231+ } 
232+ 
233+ registry . register ( Pattern ) ; 
234+ export  default  Pattern ; 
235+ export  {  Pattern  } ; 
0 commit comments