js code for a11y toggle

This commit is contained in:
sefaria
2026-05-26 23:37:28 +02:00
parent 48de33f495
commit 430602caa3
+22
View File
@@ -58,6 +58,28 @@
}
});
// accessibility toggle
const STORAGE_KEY = 'extra-css-enabled';
function applyOverrideState(enabled) {
const link = document.getElementById('a11y-css');
const button = document.getElementById('a11y-toggle');
if (!link) return;
link.disabled = !enabled;
button?.setAttribute('aria-pressed', String(enabled));
}
const enabled = localStorage.getItem(STORAGE_KEY) === 'true';
applyOverrideState(enabled);
document.getElementById('a11y-toggle')?.addEventListener('click', () => {
const nextState = localStorage.getItem(STORAGE_KEY) !== 'true';
localStorage.setItem(STORAGE_KEY, String(nextState));
applyOverrideState(nextState);
});
// light-dark toggle
const STORAGE_KEY = 'theme-preference';