-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (24 loc) · 822 Bytes
/
index.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
const closeButton = document.querySelector(".cls-btn");
const modal = document.querySelector(".card-container ");
const overlay_conatiner = document.querySelector(".overlay_container");
const primary_btns = document.querySelectorAll(".btn-primary");
document.addEventListener("keydown", (e) => {
if (e.key === "Escape" && !modal.classList.contains("hide")) {
closeModal();
}
});
const closeModal = () => {
modal.classList.add("hide");
overlay_conatiner.classList.add("hide");
};
const showModal = () => {
overlay_conatiner.classList.remove("hide");
modal.classList.remove("hide");
};
closeButton.addEventListener("click", () => {
closeModal();
});
primary_btns.forEach((pb) => pb.addEventListener("click", () => showModal()));
overlay_conatiner.addEventListener("click", () => {
closeModal();
});