export const bindConfig = () => { document.querySelectorAll('a[data-click]').forEach((e) => { e.addEventListener('click', (evt) => { evt.preventDefault(); const dialog = document.querySelector('dialog.'+e.getAttribute('data-click')); document.getElementById('menu-toggle').checked = false; dialog?.classList.remove('hidden'); dialog?.showModal(); dialog?.addEventListener('click', (evt) => { if (evt.target === dialog) { dialog?.close(); dialog?.classList.add('hidden'); } }); }); }); document.querySelectorAll('dialog.config').forEach((dialog) => { dialog.querySelectorAll('input[name=mode]').forEach((input) => { if (input.value === 'none' && localStorage.af_enabled === '0') { input.checked = true; } else if (input.value === 'dyslexia' && (localStorage.af_enabled === '1' && localStorage.af_mode === 'df')) { input.checked = true; } input.addEventListener('change', (evt) => { if (evt.target.value === 'dyslexia') { document.documentElement.classList.remove('dark'); document.documentElement.classList.remove('hc'); document.documentElement.classList.add('df'); // Set accessibility features. localStorage.af_enabled = 1; localStorage.af_mode = 'df'; } else if (evt.target.value === 'none') { document.documentElement.classList.remove('df'); document.documentElement.classList.remove('hc'); localStorage.af_enabled = 0; } else if (evt.target.value === 'hc') { document.documentElement.classList.remove('df'); document.documentElement.classList.remove('dark'); document.documentElement.classList.add('hc'); localStorage.af_enabled = 1; localStorage.af_mode = 'hc'; } }); }); dialog.querySelectorAll('button.close').forEach((btn) => { btn.addEventListener('click', (evt) => { evt.preventDefault(); dialog.close(); }); }); }); }; export const bindMenu = () => { const menu = document.getElementById('nav-menu'); window.addEventListener('click', (evt) => { if (!evt.composedPath().includes(menu)) { document.getElementById('menu-toggle').checked = false; } }); };