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

57 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-06-23 13:32:42 +00:00
// function toggleMenu() {
// var buttonElement = document.getElementById('menuIcon');
//
// var htmlElement = document.getElementsByTagName('html')[0];
// var logoElement = document.getElementById('sdeLogo');
// var mainElement = document.getElementsByTagName('main')[0];
//
// var menu = document.getElementById('menu');
//
// if(buttonElement.alt === '-')
// {
// htmlElement.style.backgroundColor = 'rgb(0, 120, 138)';
// logoElement.src = '/images/logos/Logo-hvid.svg';
// menu.classList.remove('d-none');
// mainElement.classList.add('d-none');
//
// buttonElement.alt = 'X';
// }
// else
// {
// htmlElement.style.backgroundColor = 'rgb(255, 255, 255)';
// logoElement.src = '/images/logos/Logo-normal.svg';
// menu.classList.add('d-none');
// mainElement.classList.remove('d-none');
//
// buttonElement.alt = '-';
// }
// }
2020-06-15 13:09:13 +00:00
2020-06-23 13:32:42 +00:00
function toggleMenu(menu) {
let menuElement = document.getElementById(menu);
2020-06-29 06:13:53 +00:00
let logoElement = document.getElementById("sdeLogo");
let htmlElement = document.getElementsByTagName('html')[0];
let mainElement = document.getElementsByTagName('main')[0];
2020-06-29 06:35:08 +00:00
let iconElement = document.getElementById("icon");
2020-06-29 06:13:53 +00:00
if(menuElement.classList.contains("hide")) {
2020-06-23 13:32:42 +00:00
menuElement.classList.remove("hide");
2020-06-29 06:13:53 +00:00
mainElement.classList.remove("d-none");
htmlElement.style.backgroundColor = 'rgb(255, 255, 255)';
logoElement.src = '/images/logos/Logo-normal.svg';
2020-06-29 06:35:08 +00:00
iconElement.classList.remove("fa-times");
iconElement.classList.add("fa-bars");
2020-06-29 06:13:53 +00:00
} else {
2020-06-23 13:32:42 +00:00
menuElement.classList.add("hide");
2020-06-29 06:13:53 +00:00
mainElement.classList.add("d-none");
htmlElement.style.backgroundColor = 'rgb(0, 120, 138)';
logoElement.src = '/images/logos/Logo-hvid.svg';
2020-06-29 06:35:08 +00:00
iconElement.classList.remove("fa-bars");
iconElement.classList.add("fa-times");
2020-06-29 06:13:53 +00:00
}
}
2020-06-25 13:01:33 +00:00
module.exports = {
toggleMenu
};