|
1 | 1 | // Collapse inherited members section |
2 | 2 | document.addEventListener("DOMContentLoaded", function () { |
3 | | - document.querySelectorAll("h3, h2").forEach(function (heading) { |
4 | | - if (heading.textContent.trim() === "Inherited Members") { |
5 | | - var list = heading.nextElementSibling; |
6 | | - if (!list) return; |
7 | | - |
8 | | - heading.style.cursor = "pointer"; |
9 | | - heading.style.userSelect = "none"; |
10 | | - |
11 | | - var indicator = document.createElement("span"); |
12 | | - indicator.className = "inherited-toggle"; |
13 | | - indicator.textContent = " ▶"; |
14 | | - heading.appendChild(indicator); |
15 | | - |
16 | | - list.style.display = "none"; |
17 | | - |
18 | | - heading.addEventListener("click", function () { |
19 | | - var collapsed = list.style.display === "none"; |
20 | | - list.style.display = collapsed ? "" : "none"; |
21 | | - indicator.textContent = collapsed ? " ▼" : " ▶"; |
22 | | - }); |
| 3 | + document.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach(function (heading) { |
| 4 | + if (heading.textContent.trim().replace(/\s+/g, ' ') !== "Inherited Members") return; |
| 5 | + |
| 6 | + // find the next sibling that is a list or div (skip hr etc.) |
| 7 | + var list = heading.nextElementSibling; |
| 8 | + while (list && list.tagName === "HR") { |
| 9 | + list = list.nextElementSibling; |
23 | 10 | } |
| 11 | + if (!list) return; |
| 12 | + |
| 13 | + heading.style.cursor = "pointer"; |
| 14 | + heading.style.userSelect = "none"; |
| 15 | + |
| 16 | + var indicator = document.createElement("span"); |
| 17 | + indicator.className = "inherited-toggle"; |
| 18 | + indicator.style.marginLeft = "6px"; |
| 19 | + indicator.style.fontSize = ".8em"; |
| 20 | + indicator.textContent = "▶"; |
| 21 | + heading.appendChild(indicator); |
| 22 | + |
| 23 | + list.style.display = "none"; |
| 24 | + |
| 25 | + heading.addEventListener("click", function () { |
| 26 | + var collapsed = list.style.display === "none"; |
| 27 | + list.style.display = collapsed ? "" : "none"; |
| 28 | + indicator.textContent = collapsed ? "▼" : "▶"; |
| 29 | + }); |
24 | 30 | }); |
25 | 31 | }); |
26 | 32 |
|
|
0 commit comments