24 lines
970 B
JavaScript
24 lines
970 B
JavaScript
// Core flows use native links and forms. These enhancements are optional.
|
|
document.addEventListener('click', (event) => {
|
|
const close = event.target.closest('[data-dismiss]');
|
|
if (close) {
|
|
const notice = close.closest('.notice');
|
|
const next = document.querySelector('.add-action, .entry-form input:not([type=hidden]), #main');
|
|
notice.remove();
|
|
next?.focus();
|
|
}
|
|
if (event.target.closest('[data-print]')) window.print();
|
|
document.querySelectorAll('.account-menu[open]').forEach((menu) => {
|
|
if (!menu.contains(event.target)) menu.open = false;
|
|
});
|
|
});
|
|
document.addEventListener('keydown', (event) => {
|
|
if (event.key === 'Escape') {
|
|
document.querySelectorAll('.account-menu[open]').forEach((menu) => {
|
|
menu.open = false;
|
|
menu.querySelector('summary').focus();
|
|
});
|
|
}
|
|
});
|
|
document.querySelectorAll('[data-print]').forEach((button) => { button.hidden = false; });
|