File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 11function hideAllButCurrent ( ) {
2- // only current page (if it exists) should be opened
3- var file = window . location . pathname . split ( "/" ) . pop ( ) . replace ( / \. h t m l / , '' ) ;
4- document . querySelectorAll ( "nav > ul > li > a" ) . forEach ( function ( parent ) {
5- var href = parent . attributes . href . value . replace ( / \. h t m l / , '' ) ;
6- if ( file === href ) {
2+ //by default all submenut items are hidden
3+ //but we need to rehide them for search
4+ document . querySelectorAll ( "nav > ul > li > ul li" ) . forEach ( function ( parent ) {
5+ parent . style . display = "none" ;
6+ } ) ;
7+
8+ //only current page (if it exists) should be opened
9+ var file = window . location . pathname . split ( "/" ) . pop ( ) ;
10+ document . querySelectorAll ( "nav > ul > li > a[href^='" + file + "']" ) . forEach ( function ( parent ) {
711 parent . parentNode . querySelectorAll ( "ul li" ) . forEach ( function ( elem ) {
8- elem . style . display = "block" ;
12+ elem . style . display = "block" ;
913 } ) ;
10- }
1114 } ) ;
12- }
15+ }
1316
14- hideAllButCurrent ( ) ;
17+ hideAllButCurrent ( ) ;
You can’t perform that action at this time.
0 commit comments