/* ============================================================ LWV TEXT-SIZE WIDGET - Inline navbar version ============================================================ Version: 2026.05.27.04 v04 change: DEFAULT_ZOOM changed from "1" to "1.25" so new users land on A+ (middle) zoom by default. Users who have previously tapped a button retain their stored preference. ============================================================ */ (function () { "use strict"; var STORAGE_KEY = "lwv-text-zoom"; var DEFAULT_ZOOM = "1.25"; var ALLOWED = { "1": true, "1.25": true, "1.5": true }; function readZoom() { try { var v = localStorage.getItem(STORAGE_KEY); if (v && ALLOWED[v]) return v; } catch (e) {} return DEFAULT_ZOOM; } var currentZoom = readZoom(); document.documentElement.setAttribute("data-lwv-zoom", currentZoom); function applyZoom(z) { currentZoom = z; document.documentElement.setAttribute("data-lwv-zoom", z); syncActiveButton(); } function syncActiveButton() { var btns = document.querySelectorAll(".lwv-textsize-btn"); Array.prototype.forEach.call(btns, function (b) { if (b.getAttribute("data-zoom") === currentZoom) { b.classList.add("is-active"); b.setAttribute("aria-pressed", "true"); } else { b.classList.remove("is-active"); b.setAttribute("aria-pressed", "false"); } }); } function wireWidget() { var btns = document.querySelectorAll(".lwv-textsize-btn"); if (!btns.length) return; syncActiveButton(); Array.prototype.forEach.call(btns, function (btn) { btn.addEventListener("click", function () { var z = btn.getAttribute("data-zoom"); if (!ALLOWED[z]) return; applyZoom(z); try { localStorage.setItem(STORAGE_KEY, z); } catch (e) {} }); }); window.addEventListener("storage", function (e) { if (e.key === STORAGE_KEY && ALLOWED[e.newValue]) { applyZoom(e.newValue); } }); console.log("[LWV TextSize] Wired. Current zoom:", currentZoom); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", wireWidget); } else { wireWidget(); } })();