summaryrefslogtreecommitdiff
path: root/venv/lib/python3.11/site-packages/litestar/middleware/exceptions/templates/scripts.js
blob: 014a256cc5b0cd8a74acf666ab00195920f679cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const expanders = document.querySelectorAll(".frame .expander");

for (const expander of expanders) {
  expander.addEventListener("click", (evt) => {
    const currentSnippet = evt.currentTarget.closest(".frame");
    const snippetWrapper = currentSnippet.querySelector(
      ".code-snippet-wrapper",
    );
    if (currentSnippet.classList.contains("collapsed")) {
      snippetWrapper.style.height = `${snippetWrapper.scrollHeight}px`;
      currentSnippet.classList.remove("collapsed");
    } else {
      currentSnippet.classList.add("collapsed");
      snippetWrapper.style.height = "0px";
    }
  });
}

// init height for non-collapsed code snippets so animation will be show
// their first collapse
const nonCollapsedSnippets = document.querySelectorAll(
  ".frame:not(.collapsed) .code-snippet-wrapper",
);

for (const snippet of nonCollapsedSnippets) {
  snippet.style.height = `${snippet.scrollHeight}px`;
}