Keep controls table while editing
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
76decaf203
commit
5f780c751a
@ -1,34 +0,0 @@
|
|||||||
let modal: HTMLElement | null = null;
|
|
||||||
|
|
||||||
function openModal(event: Event) {
|
|
||||||
event.preventDefault();
|
|
||||||
const el = document.querySelector((event.target as HTMLElement).getAttribute('href')!)! as HTMLElement;
|
|
||||||
// @ts-expect-error reset
|
|
||||||
el.style.display = null;
|
|
||||||
el.removeAttribute('hidden');
|
|
||||||
el.setAttribute('aria-modal', 'true');
|
|
||||||
modal = el;
|
|
||||||
modal.addEventListener('click', closeModal);
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeModal(event: Event) {
|
|
||||||
event.preventDefault();
|
|
||||||
if (modal === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
modal.style.display = 'none';
|
|
||||||
modal.setAttribute('hidden', 'hidden');
|
|
||||||
modal.removeAttribute('aria-modal');
|
|
||||||
modal.removeEventListener('click', closeModal);
|
|
||||||
modal = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelectorAll('.open-modal').forEach((el) => {
|
|
||||||
el.addEventListener('click', openModal);
|
|
||||||
});
|
|
||||||
|
|
||||||
window.addEventListener('keydown', (event) => {
|
|
||||||
if (event.key === 'Escape' && modal !== null) {
|
|
||||||
closeModal(event);
|
|
||||||
}
|
|
||||||
});
|
|
Loading…
Reference in new issue