-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.js
28 lines (25 loc) · 928 Bytes
/
menu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function ready(callback) {
if (document.readyState !== 'loading') {
callback();
} else {
document.addEventListener('DOMContentLoaded', callback);
}
}
ready(function () {
const toggleButtonOn = document.getElementById("toggleButtonOn");
const toggleButtonOff = document.getElementById("toggleButtonOff");
const flyoutMenu = document.getElementById("flyoutMenu");
const flyoutMenuItems = document.querySelectorAll("#flyoutMenu a");
const toggleMenu = function () {
if (flyoutMenu.classList.contains("hidden")) {
flyoutMenu.classList.remove("hidden");
} else {
flyoutMenu.classList.add("hidden");
}
};
flyoutMenuItems.forEach(function (item) {
item.addEventListener("click", toggleMenu);
});
toggleButtonOn.addEventListener("click", toggleMenu);
toggleButtonOff.addEventListener("click", toggleMenu);
});