privacyguides.org/assets/js/main.js
Dawid Potocki ed127c0500 Fix tooltips (#1203)
Fixes #1202
2019-08-23 11:23:18 +00:00

34 lines
768 B
JavaScript

// Tooltips
$(function () {
$("[data-toggle='tooltip']").tooltip();
});
//
// 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;
});
}