-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
46 lines (39 loc) · 1.33 KB
/
script.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Pop up windows
const openWindowButtons = document.querySelectorAll('[data-window-target]');
const closeWindowButtons = document.querySelectorAll('[data-close-button]');
const overlay = document.getElementById("overlay");
openWindowButtons.forEach(button => {
button.addEventListener("click", () => {
const window = document.querySelector(button.dataset.windowTarget);
openWindow(window);
});
}
)
closeWindowButtons.forEach(button => {
button.addEventListener("click", () => {
const window = button.closest(".window");
closeWindow(window);
});
}
)
function openWindow(window) {
if (window == null) return
window.classList.add("active");
overlay.classList.add("active");
}
function closeWindow(window) {
if (window == null) return
window.classList.remove("active");
overlay.classList.remove("active");
}
// Hamburger menu
const hamburgerMenu = document.getElementById("menu-hamburger");
const openHamburgerMenu = document.getElementById("open-menu-hamburger");
openHamburgerMenu.onclick = () => {
hamburgerMenu.style.display = "flex";
openHamburgerMenu.style.display = "none";
}
document.getElementById("close-menu-hamburger").onclick = () => {
hamburgerMenu.style.display = "none";
openHamburgerMenu.style.display = "block";
}