|
| 1 | +<h3><a href="{{ pathto(root_doc)|e }}">{{ project|title }}</a></h3> |
| 2 | +<div id="salt-globaltoc"> |
| 3 | +{{ toctree(includehidden=True, collapse=False, maxdepth=2) }} |
| 4 | +</div> |
| 5 | + |
| 6 | +<style> |
| 7 | +#salt-globaltoc { |
| 8 | + font-size: 0.875rem; |
| 9 | +} |
| 10 | + |
| 11 | +#salt-globaltoc ul { |
| 12 | + list-style: none; |
| 13 | + padding: 0; |
| 14 | + margin: 0 0 0.25rem 0; |
| 15 | +} |
| 16 | + |
| 17 | +/* Indent nested levels */ |
| 18 | +#salt-globaltoc ul ul { |
| 19 | + padding-left: 0.75rem; |
| 20 | + margin: 0; |
| 21 | + width: 100%; |
| 22 | +} |
| 23 | + |
| 24 | +#salt-globaltoc p.caption { |
| 25 | + display: flex; |
| 26 | + align-items: center; |
| 27 | + gap: 0.4em; |
| 28 | + cursor: pointer; |
| 29 | + font-size: 0.75rem; |
| 30 | + font-weight: 700; |
| 31 | + text-transform: uppercase; |
| 32 | + letter-spacing: 0.08em; |
| 33 | + color: var(--pst-color-text-muted, #6c757d); |
| 34 | + padding: 0.35rem 0.25rem 0.35rem 0; |
| 35 | + margin: 0.75rem 0 0 0; |
| 36 | + user-select: none; |
| 37 | +} |
| 38 | + |
| 39 | +#salt-globaltoc p.caption:hover { |
| 40 | + color: var(--pst-color-text-base, inherit); |
| 41 | +} |
| 42 | + |
| 43 | +/* Triangle arrow indicator on captions */ |
| 44 | +#salt-globaltoc p.caption::before { |
| 45 | + content: ""; |
| 46 | + display: inline-block; |
| 47 | + flex-shrink: 0; |
| 48 | + width: 0; |
| 49 | + height: 0; |
| 50 | + border-style: solid; |
| 51 | + border-width: 4px 0 4px 6px; |
| 52 | + border-color: transparent transparent transparent currentColor; |
| 53 | + transition: transform 0.15s ease; |
| 54 | +} |
| 55 | + |
| 56 | +#salt-globaltoc p.caption.expanded::before { |
| 57 | + transform: rotate(90deg); |
| 58 | +} |
| 59 | + |
| 60 | +/* Flex layout for li items that have children, so link + toggle button sit on one row */ |
| 61 | +#salt-globaltoc li.has-children { |
| 62 | + display: flex; |
| 63 | + flex-wrap: wrap; |
| 64 | + align-items: flex-start; |
| 65 | +} |
| 66 | + |
| 67 | +#salt-globaltoc li.has-children > a { |
| 68 | + flex: 1; |
| 69 | + min-width: 0; |
| 70 | +} |
| 71 | + |
| 72 | +#salt-globaltoc li.has-children > ul { |
| 73 | + width: 100%; |
| 74 | +} |
| 75 | + |
| 76 | +/* Toggle button injected next to links that have children */ |
| 77 | +#salt-globaltoc .toc-toggle { |
| 78 | + flex-shrink: 0; |
| 79 | + background: none; |
| 80 | + border: none; |
| 81 | + cursor: pointer; |
| 82 | + padding: 0.25rem 0.35rem; |
| 83 | + color: var(--pst-color-text-muted, #6c757d); |
| 84 | + line-height: 1; |
| 85 | + border-radius: 4px; |
| 86 | +} |
| 87 | + |
| 88 | +#salt-globaltoc .toc-toggle:hover { |
| 89 | + color: var(--pst-color-text-base, inherit); |
| 90 | + background-color: var(--pst-color-surface, rgba(0, 0, 0, 0.06)); |
| 91 | +} |
| 92 | + |
| 93 | +#salt-globaltoc .toc-toggle::before { |
| 94 | + content: ""; |
| 95 | + display: inline-block; |
| 96 | + width: 0; |
| 97 | + height: 0; |
| 98 | + border-style: solid; |
| 99 | + border-width: 4px 0 4px 6px; |
| 100 | + border-color: transparent transparent transparent currentColor; |
| 101 | + transition: transform 0.15s ease; |
| 102 | +} |
| 103 | + |
| 104 | +#salt-globaltoc .toc-toggle.expanded::before { |
| 105 | + transform: rotate(90deg); |
| 106 | +} |
| 107 | + |
| 108 | +/* Link styles for all toctree levels */ |
| 109 | +#salt-globaltoc li > a { |
| 110 | + display: block; |
| 111 | + padding: 0.25rem 0.5rem; |
| 112 | + color: var(--pst-color-text-base, inherit); |
| 113 | + text-decoration: none; |
| 114 | + border-radius: 4px; |
| 115 | + line-height: 1.4; |
| 116 | +} |
| 117 | + |
| 118 | +#salt-globaltoc li > a:hover { |
| 119 | + background-color: var(--pst-color-surface, rgba(0, 0, 0, 0.06)); |
| 120 | +} |
| 121 | + |
| 122 | +#salt-globaltoc li.current > a, |
| 123 | +#salt-globaltoc li.current > a:hover { |
| 124 | + font-weight: 600; |
| 125 | + background-color: var(--pst-color-surface, rgba(0, 0, 0, 0.06)); |
| 126 | + color: var(--pst-color-primary, #0099cd); |
| 127 | +} |
| 128 | + |
| 129 | +/* Slightly smaller text for deeper levels */ |
| 130 | +#salt-globaltoc .toctree-l2 > a, |
| 131 | +#salt-globaltoc .toctree-l3 > a, |
| 132 | +#salt-globaltoc .toctree-l4 > a { |
| 133 | + font-size: 0.85rem; |
| 134 | + padding: 0.18rem 0.5rem; |
| 135 | +} |
| 136 | +</style> |
| 137 | + |
| 138 | +<script> |
| 139 | +(function () { |
| 140 | + function hasCurrentDescendant(ul) { |
| 141 | + return !!ul.querySelector("li.current"); |
| 142 | + } |
| 143 | + |
| 144 | + function initCollapsible() { |
| 145 | + var container = document.getElementById("salt-globaltoc"); |
| 146 | + if (!container) return; |
| 147 | + |
| 148 | + // Caption-level collapsing (start expanded by default) |
| 149 | + container.querySelectorAll("p.caption").forEach(function (caption) { |
| 150 | + var ul = caption.nextElementSibling; |
| 151 | + if (!ul || ul.tagName !== "UL") return; |
| 152 | + |
| 153 | + caption.classList.add("expanded"); |
| 154 | + |
| 155 | + caption.addEventListener("click", function () { |
| 156 | + var isCollapsed = ul.style.display === "none"; |
| 157 | + ul.style.display = isCollapsed ? "" : "none"; |
| 158 | + caption.classList.toggle("expanded", isCollapsed); |
| 159 | + }); |
| 160 | + }); |
| 161 | + |
| 162 | + // Nested li collapsing: any li that directly contains a ul |
| 163 | + container.querySelectorAll("li").forEach(function (li) { |
| 164 | + var childUl = li.querySelector(":scope > ul"); |
| 165 | + if (!childUl) return; |
| 166 | + |
| 167 | + var link = li.querySelector(":scope > a"); |
| 168 | + if (!link) return; |
| 169 | + |
| 170 | + // Distinguish sub-pages (no # in href) from intra-page section headers (# in href) |
| 171 | + var childLinks = childUl.querySelectorAll(":scope > li > a"); |
| 172 | + var hasSubPages = false; |
| 173 | + childLinks.forEach(function (childLink) { |
| 174 | + var href = childLink.getAttribute("href") || ""; |
| 175 | + if (href.indexOf("#") === -1) { |
| 176 | + hasSubPages = true; |
| 177 | + } |
| 178 | + }); |
| 179 | + |
| 180 | + if (!hasSubPages) { |
| 181 | + // Children are section headers of this page — hide them entirely |
| 182 | + childUl.style.display = "none"; |
| 183 | + return; |
| 184 | + } |
| 185 | + |
| 186 | + li.classList.add("has-children"); |
| 187 | + |
| 188 | + var btn = document.createElement("button"); |
| 189 | + btn.className = "toc-toggle"; |
| 190 | + btn.setAttribute("aria-label", "Toggle section"); |
| 191 | + |
| 192 | + var expanded = li.classList.contains("current") || hasCurrentDescendant(childUl); |
| 193 | + if (expanded) { |
| 194 | + btn.classList.add("expanded"); |
| 195 | + } else { |
| 196 | + childUl.style.display = "none"; |
| 197 | + } |
| 198 | + |
| 199 | + link.insertAdjacentElement("afterend", btn); |
| 200 | + |
| 201 | + btn.addEventListener("click", function (e) { |
| 202 | + e.stopPropagation(); |
| 203 | + var isCollapsed = childUl.style.display === "none"; |
| 204 | + childUl.style.display = isCollapsed ? "" : "none"; |
| 205 | + btn.classList.toggle("expanded", isCollapsed); |
| 206 | + }); |
| 207 | + }); |
| 208 | + } |
| 209 | + |
| 210 | + if (document.readyState === "loading") { |
| 211 | + document.addEventListener("DOMContentLoaded", initCollapsible); |
| 212 | + } else { |
| 213 | + initCollapsible(); |
| 214 | + } |
| 215 | +})(); |
| 216 | +</script> |
0 commit comments