Skip to content

Commit 6a0b502

Browse files
author
Jani Giannoudis
committed
docfx: expandable inherited members
1 parent a5bbea3 commit 6a0b502

1 file changed

Lines changed: 26 additions & 20 deletions

File tree

docfx/templates/darkerfx/styles/toggle-theme.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
// Collapse inherited members section
22
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;
2310
}
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+
});
2430
});
2531
});
2632

0 commit comments

Comments
 (0)