70 lines
4.4 KiB
JavaScript
70 lines
4.4 KiB
JavaScript
document.addEventListener("DOMContentLoaded", function() {
|
|
// Menu Toggle
|
|
const toggleBtn = document.getElementById("mobile-menu-toggle");
|
|
const navMenu = document.getElementById("site-navigation");
|
|
if (toggleBtn && navMenu) {
|
|
toggleBtn.addEventListener("click", function() {
|
|
toggleBtn.classList.toggle("active");
|
|
navMenu.classList.toggle("active");
|
|
});
|
|
}
|
|
|
|
// Back to Top
|
|
const bttBtn = document.getElementById("back-to-top");
|
|
if (bttBtn) {
|
|
window.addEventListener("scroll", function() {
|
|
if (window.scrollY > 350) { bttBtn.classList.add("show"); } else { bttBtn.classList.remove("show"); }
|
|
});
|
|
bttBtn.addEventListener("click", function() {
|
|
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
});
|
|
}
|
|
|
|
// Accessibility Panel
|
|
const a11yTrigger = document.getElementById("a11y-trigger");
|
|
const a11yPanel = document.getElementById("a11y-panel");
|
|
const a11yClose = document.getElementById("a11y-close");
|
|
if (a11yTrigger && a11yPanel) {
|
|
a11yTrigger.addEventListener("click", function() { a11yPanel.classList.toggle("active"); });
|
|
if (a11yClose) { a11yClose.addEventListener("click", function() { a11yPanel.classList.remove("active"); }); }
|
|
|
|
const fontLevels = ['', 'a11y-font-lg', 'a11y-font-xl'];
|
|
let currentFontIdx = parseInt(localStorage.getItem('edukarsa_a11y_font') || '0', 10);
|
|
function applyA11y() {
|
|
fontLevels.forEach(function(c) { if (c) document.body.classList.remove(c); });
|
|
if (fontLevels[currentFontIdx]) { document.body.classList.add(fontLevels[currentFontIdx]); }
|
|
if (localStorage.getItem('edukarsa_a11y_contrast') === '1') { document.body.classList.add('a11y-high-contrast'); } else { document.body.classList.remove('a11y-high-contrast'); }
|
|
if (localStorage.getItem('edukarsa_a11y_grayscale') === '1') { document.body.classList.add('a11y-grayscale'); } else { document.body.classList.remove('a11y-grayscale'); }
|
|
if (localStorage.getItem('edukarsa_a11y_links') === '1') { document.body.classList.add('a11y-underline-links'); } else { document.body.classList.remove('a11y-underline-links'); }
|
|
}
|
|
applyA11y();
|
|
|
|
document.getElementById("a11y-font-inc")?.addEventListener("click", function() { if (currentFontIdx < fontLevels.length - 1) currentFontIdx++; localStorage.setItem('edukarsa_a11y_font', currentFontIdx); applyA11y(); });
|
|
document.getElementById("a11y-font-dec")?.addEventListener("click", function() { if (currentFontIdx > 0) currentFontIdx--; localStorage.setItem('edukarsa_a11y_font', currentFontIdx); applyA11y(); });
|
|
document.getElementById("a11y-font-reset")?.addEventListener("click", function() { currentFontIdx = 0; localStorage.setItem('edukarsa_a11y_font', currentFontIdx); applyA11y(); });
|
|
document.getElementById("a11y-contrast")?.addEventListener("click", function() { const active = localStorage.getItem('edukarsa_a11y_contrast') === '1'; localStorage.setItem('edukarsa_a11y_contrast', active ? '0' : '1'); applyA11y(); });
|
|
document.getElementById("a11y-grayscale")?.addEventListener("click", function() { const active = localStorage.getItem('edukarsa_a11y_grayscale') === '1'; localStorage.setItem('edukarsa_a11y_grayscale', active ? '0' : '1'); applyA11y(); });
|
|
document.getElementById("a11y-links")?.addEventListener("click", function() { const active = localStorage.getItem('edukarsa_a11y_links') === '1'; localStorage.setItem('edukarsa_a11y_links', active ? '0' : '1'); applyA11y(); });
|
|
document.getElementById("a11y-reset-all")?.addEventListener("click", function() {
|
|
currentFontIdx = 0;
|
|
localStorage.removeItem('edukarsa_a11y_font');
|
|
localStorage.removeItem('edukarsa_a11y_contrast');
|
|
localStorage.removeItem('edukarsa_a11y_grayscale');
|
|
localStorage.removeItem('edukarsa_a11y_links');
|
|
applyA11y();
|
|
});
|
|
}
|
|
|
|
// Homepage Hero Slider Scroll
|
|
const slider = document.getElementById('hero-slider-wrapper');
|
|
if (slider && slider.children.length > 1) {
|
|
setInterval(function() {
|
|
if (slider.scrollLeft + slider.clientWidth >= slider.scrollWidth - 10) {
|
|
slider.scrollTo({ left: 0, behavior: 'smooth' });
|
|
} else {
|
|
slider.scrollBy({ left: slider.clientWidth, behavior: 'smooth' });
|
|
}
|
|
}, 4000);
|
|
}
|
|
});
|