MCPcopy Index your code
hub / github.com/stemdeckapp/stemdeck / wireWidgets

Function wireWidgets

static/js/catalog.js:1500–1518  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1498// ─── Collapsible widgets ───
1499
1500function wireWidgets() {
1501 for (const head of document.querySelectorAll(".widget-head")) {
1502 const widget = head.closest(".widget");
1503 if (!widget) continue;
1504 const key = `stemdeck.widget.${widget.dataset.widget}`;
1505 if (localStorage.getItem(key) === "collapsed") {
1506 widget.classList.add("collapsed");
1507 head.setAttribute("aria-expanded", "false");
1508 }
1509 head.addEventListener("click", () => {
1510 const isCollapsed = widget.classList.toggle("collapsed");
1511 head.setAttribute("aria-expanded", String(!isCollapsed));
1512 localStorage.setItem(key, isCollapsed ? "collapsed" : "open");
1513 });
1514 head.addEventListener("keydown", (e) => {
1515 if (e.code === "Enter" || e.code === "Space") { e.preventDefault(); head.click(); }
1516 });
1517 }
1518}
1519
1520// ─── Init ───
1521

Callers 1

initCatalogFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected