23 lines
791 B
JavaScript
23 lines
791 B
JavaScript
|
var header = document.getElementById("header");
|
||
|
var hamburgerMenu = document.getElementById("header-hamburger");
|
||
|
var nav = document.getElementById("header-nav");
|
||
|
header.className += " header-js";
|
||
|
var className = header.className;
|
||
|
var oldHamburgerTabIndex = hamburgerMenu.tabIndex;
|
||
|
|
||
|
function toggleHamburger() {
|
||
|
if (header.className.match(/(?:^| )header-nav-opened( |$)/)) {
|
||
|
header.className = className;
|
||
|
document.documentElement.style.overflow = null;
|
||
|
hamburgerMenu.tabIndex = oldHamburgerTabIndex;
|
||
|
} else {
|
||
|
header.className += " header-nav-opened";
|
||
|
document.documentElement.style.overflow = "hidden";
|
||
|
hamburgerMenu.tabIndex = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
hamburgerMenu.onclick = toggleHamburger;
|
||
|
hamburgerMenu.onkeydown = function (e) {
|
||
|
if (e.key == "Enter") toggleHamburger();
|
||
|
}
|