mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-08-16 23:03:24 +02:00
- podcast name was too vague and didn't come clearly for users: handle is more relevant - update package.json dependencies and remove unnused packages closes #126
33 lines
948 B
TypeScript
33 lines
948 B
TypeScript
const Modal = (): void => {
|
|
const modalTriggerElements: NodeListOf<HTMLElement> =
|
|
document.querySelectorAll("[data-modal-target]");
|
|
|
|
for (let i = 0; i < modalTriggerElements.length; i++) {
|
|
const modalTrigger = modalTriggerElements[i];
|
|
|
|
if (modalTrigger.dataset.modalTarget) {
|
|
const modal: HTMLElement | null = document.getElementById(
|
|
modalTrigger.dataset.modalTarget
|
|
);
|
|
|
|
if (modal) {
|
|
modalTrigger.addEventListener("click", () => {
|
|
modal.classList.toggle("hidden");
|
|
});
|
|
|
|
const closeButtonsElements: NodeListOf<HTMLElement> =
|
|
modal.querySelectorAll("[data-modal-button]");
|
|
|
|
for (let j = 0; j < closeButtonsElements.length; j++) {
|
|
const closeButton = closeButtonsElements[j];
|
|
closeButton.addEventListener("click", () => {
|
|
modal.classList.toggle("hidden");
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
export default Modal;
|