webseite/assets/js/nav_toggle.js
muli 9e36de87a1 fix: Menü in mobile und PC-Version gesplittet.
Etwas Overhead im Template, dafür weniger verschwurbelte Logik.
2024-03-22 23:48:42 +01:00

23 lines
815 B
JavaScript

document.getElementsByClassName('primary_nav__toggle')[0].addEventListener('click', function(){
let mobile_nav_list = document.getElementsByClassName('primary_nav__mobile_navlist')[0]
if (mobile_nav_list.style.display === 'block') {
mobile_nav_list.style.display = 'none';
} else {
mobile_nav_list.style.display = 'block';
}
});
let primary_menu_items = document.getElementsByClassName('primary_nav__navitem');
for (let i = 0; i < primary_menu_items.length; i++) {
primary_menu_items[i].addEventListener('click', function(event) {
let dropdown = event.currentTarget.children[1];
if (dropdown.classList.contains('-closed')) {
dropdown.classList.remove('-closed');
dropdown.classList.add('-open');
} else {
dropdown.classList.remove('-open');
dropdown.classList.add('-closed');
}
});
}