1
0
mirror of https://github.com/lancedikson/bowser synced 2024-09-30 07:10:43 +00:00
lancedikson_bowser/docs/scripts/collapse.js
Tim Gates fdf56240ce
docs: Fix simple typo, submenut -> submenu
There is a small typo in docs/scripts/collapse.js.

Should read `submenu` rather than `submenut`.
2020-09-04 06:27:38 +10:00

21 lines
753 B
JavaScript

function hideAllButCurrent(){
//by default all submenu items are hidden
//but we need to rehide them for search
document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) {
parent.style.display = "none";
});
//only current page (if it exists) should be opened
var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
var href = parent.attributes.href.value.replace(/\.html/, '');
if (file === href) {
parent.parentNode.querySelectorAll("ul li").forEach(function(elem) {
elem.style.display = "block";
});
}
});
}
hideAllButCurrent();