mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-08-17 07:13:22 +02:00
- replace rollup config with vitejs - use vite dev server during development to take advantage of hot module replacement (HMR) - add vite service using Vite library to load css and js assets - update package.json scripts and remove unnecessary dependencies - update scripts/bundle-prepare.sh closes #107
35 lines
962 B
TypeScript
35 lines
962 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;
|