mirror of
https://github.com/privacyguides/privacyguides.org.git
synced 2025-06-08 14:52:49 -04:00
parent
85efc93d4d
commit
8eb8cf5225
4 changed files with 321 additions and 115 deletions
27
assets/js/main.js
Normal file
27
assets/js/main.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// Navbar dropdowns
|
||||
//
|
||||
|
||||
const navSections = document.querySelectorAll(".nav-details");
|
||||
|
||||
navSections.forEach(navSection => {
|
||||
navSection.addEventListener("toggle", navSectionsToggle);
|
||||
});
|
||||
document.addEventListener("click", navSectionsClose);
|
||||
|
||||
function navSectionsToggle() {
|
||||
// When opening next dropdown, hide previous
|
||||
if (this.open) {
|
||||
navSections.forEach(navSection => {
|
||||
if (navSection != this && navSection.open) navSection.open = !open;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function navSectionsClose(event) {
|
||||
// Hide all dropdowns when clicking in different place
|
||||
if (event.target.matches(".nav-summary")) return;
|
||||
navSections.forEach(navSection => {
|
||||
navSection.open = !open;
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue