Ekapp/skolehjem/resources/js/navmenu/menu.js

32 lines
1.2 KiB
JavaScript

function toggleMenu(menu) {
let menuElement = document.getElementById(menu);
let logoElement = document.getElementById("sdeLogo");
let htmlElement = document.getElementsByTagName('html')[0];
let mainElement = document.getElementsByTagName('main')[0];
let iconElement = document.getElementById("icon");
let headerElement = document.getElementById("header");
if(menuElement.classList.contains("hide")) {
menuElement.classList.remove("hide");
mainElement.classList.remove("d-none");
htmlElement.style.backgroundColor = 'rgb(255, 255, 255)';
logoElement.src = '/images/logos/Logo-hvid.svg';
iconElement.classList.remove("fa-times");
iconElement.classList.add("fa-bars");
headerElement.style.position = 'fixed';
} else {
menuElement.classList.add("hide");
mainElement.classList.add("d-none");
htmlElement.style.backgroundColor = 'rgb(0, 120, 138)';
logoElement.src = '/images/logos/Logo-hvid.svg';
iconElement.classList.remove("fa-bars");
iconElement.classList.add("fa-times");
headerElement.style.position = 'relative';
headerElement.style.top = '0';
}
}
module.exports = {
toggleMenu
};