You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
/*
|
|
============ JS Load Begin ============
|
|
Creé par : Sigfrido Gonzalez Puga
|
|
Projet: EMICA | ANNEXE | 462166 | Connâitre Raspberry Pi
|
|
Date : Juin 2022
|
|
*/
|
|
|
|
|
|
/* ============ Menu multi leve ============ */
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
// make it as accordion for smaller screens
|
|
if (window.innerWidth < 992) {
|
|
|
|
// close all inner dropdowns when parent is closed
|
|
document.querySelectorAll('.navbar .dropdown').forEach(function (everydropdown) {
|
|
everydropdown.addEventListener('hidden.bs.dropdown', function () {
|
|
// after dropdown is hidden, then find all submenus
|
|
this.querySelectorAll('.submenu').forEach(function (everysubmenu) {
|
|
// hide every submenu as well
|
|
everysubmenu.style.display = 'none';
|
|
});
|
|
})
|
|
});
|
|
|
|
document.querySelectorAll('.dropdown-menu a').forEach(function (element) {
|
|
element.addEventListener('click', function (e) {
|
|
let nextEl = this.nextElementSibling;
|
|
if (nextEl && nextEl.classList.contains('submenu')) {
|
|
// prevent opening link if link needs to open dropdown
|
|
e.preventDefault();
|
|
if (nextEl.style.display == 'block') {
|
|
nextEl.style.display = 'none';
|
|
} else {
|
|
nextEl.style.display = 'block';
|
|
}
|
|
|
|
}
|
|
});
|
|
})
|
|
}
|
|
// end if innerWidth
|
|
});
|
|
/* ============ Menu multi level ============ */
|
|
|