deploy
This commit is contained in:
@@ -22,6 +22,54 @@
|
||||
};
|
||||
|
||||
const bindInteractions = (host, loadRoute) => {
|
||||
host.querySelectorAll('[data-aa-open-modal]').forEach((button) => {
|
||||
if (button.dataset.aaBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
button.dataset.aaBound = '1';
|
||||
button.addEventListener('click', () => {
|
||||
const modalId = button.getAttribute('data-aa-open-modal') || '';
|
||||
const modal = host.querySelector(`[data-aa-modal="${CSS.escape(modalId)}"]`);
|
||||
if (modal instanceof HTMLDialogElement) {
|
||||
modal.showModal();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
host.querySelectorAll('[data-aa-close-modal]').forEach((button) => {
|
||||
if (button.dataset.aaBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
button.dataset.aaBound = '1';
|
||||
button.addEventListener('click', () => {
|
||||
const modal = button.closest('dialog');
|
||||
if (modal instanceof HTMLDialogElement) {
|
||||
modal.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
host.querySelectorAll('dialog[data-aa-modal]').forEach((dialog) => {
|
||||
if (dialog.dataset.aaBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
dialog.dataset.aaBound = '1';
|
||||
dialog.addEventListener('click', (event) => {
|
||||
const rect = dialog.getBoundingClientRect();
|
||||
const inside = event.clientX >= rect.left
|
||||
&& event.clientX <= rect.right
|
||||
&& event.clientY >= rect.top
|
||||
&& event.clientY <= rect.bottom;
|
||||
|
||||
if (!inside) {
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
host.querySelectorAll('a[href]').forEach((link) => {
|
||||
if (link.dataset.aaBound === '1') {
|
||||
return;
|
||||
@@ -66,6 +114,11 @@
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
const modal = form.closest('dialog');
|
||||
if (modal instanceof HTMLDialogElement) {
|
||||
modal.close();
|
||||
}
|
||||
|
||||
host.innerHTML = html;
|
||||
bindInteractions(host, loadRoute);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user