Graphite/website/static/js/developer-guide-editor-structure.js
Keavon Chambers 6b315c3b68
Some checks failed
Editor: Dev & CI / build (push) Waiting to run
Editor: Dev & CI / cargo-deny (push) Waiting to run
Website / build (push) Has been cancelled
Modernize and fix website build tooling deps and utilize JS type checking (#3348)
* Modernize and fix website build tooling deps and utilize JS type checking

* Upgrade to the latest Node.js
2025-11-06 16:30:35 -08:00

18 lines
684 B
JavaScript

document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".tree-node").forEach((toggle) => {
toggle.addEventListener("click", (event) => {
// Prevent link click from also toggling parent
if (event.target instanceof HTMLElement && event.target.tagName === "A") return;
const nestedList = toggle.parentElement?.querySelector(".nested");
if (nestedList) {
toggle.classList.toggle("expanded");
nestedList.classList.toggle("active");
}
});
});
// Expand the first level by default
const firstLevel = document.querySelector(".structure-outline > ul > li > .tree-node");
if (firstLevel instanceof HTMLElement) firstLevel.click();
});