Skip to content

Commit c3b1724

Browse files
committed
We need to rehide menus for search capabilities
1 parent c8e1fa8 commit c3b1724

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

static/scripts/collapse.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
function hideAllButCurrent(){
2-
// only current page (if it exists) should be opened
3-
var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
4-
document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
5-
var href = parent.attributes.href.value.replace(/\.html/, '');
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();

0 commit comments

Comments
 (0)