|
1 | 1 | {% extends "base.html" %} |
2 | | -{% endblock %} |
3 | | -{{ super() }} |
4 | | -</script> |
5 | | -})(); |
6 | | - } |
7 | | - } |
8 | | - header.appendChild(btn); |
9 | | - } else { |
10 | | - searchButton.parentNode.insertBefore(btn, searchButton); |
11 | | - if (searchButton) { |
12 | | - || header.querySelector("label.md-header__button"); |
13 | | - const searchButton = header.querySelector(".md-header__button.md-icon[for='__search']") |
14 | | - if (header) { |
15 | | - const header = document.querySelector(".md-header__inner"); |
16 | | - |
17 | | - btn.innerHTML = mode === "full" ? window.__mdWidthIcons.minimize : window.__mdWidthIcons.maximize; |
18 | | - btn.setAttribute("aria-label", "Toggle page width"); |
19 | | - btn.className = "md-header__button md-width-toggle"; |
20 | | - btn.id = "md-width-toggle"; |
21 | | - const btn = document.createElement("button"); |
22 | | - const mode = window.__mdWidthMode || "slim"; |
23 | 2 |
|
24 | | - }; |
25 | | - minimize: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="-2 -2 28 28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><g transform="rotate(45 12 12)"><path d="m14 10 7-7"/><path d="M20 10h-6V4"/><path d="m3 21 7-7"/><path d="M4 14h6v6"/></g></svg>' |
26 | | - maximize: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="-2 -2 28 28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><g transform="rotate(45 12 12)"><path d="M15 3h6v6"/><path d="m21 3-7 7"/><path d="m3 21 7-7"/><path d="M9 21H3v-6"/></g></svg>', |
27 | | - window.__mdWidthIcons = { |
28 | | -(function() { |
29 | | -// Inject toggle button immediately when header is available |
| 3 | +{% block styles %} |
30 | 4 | <script> |
31 | | -{% block content %} |
32 | | - |
33 | | -{% endblock %} |
34 | | -{{ super() }} |
| 5 | + (function () { |
| 6 | + const savedWidth = localStorage.getItem("md-width") || "slim"; |
| 7 | + if (savedWidth === "wide" || savedWidth === "full") { |
| 8 | + document.documentElement.setAttribute("data-md-width", savedWidth); |
| 9 | + } |
| 10 | + // Store for width-toggle.js to use |
| 11 | + window.__mdWidthMode = savedWidth; |
| 12 | + })(); |
35 | 13 | </script> |
36 | | -})(); |
37 | | - window.__mdWidthMode = savedWidth; |
38 | | - // Store for width-toggle.js to use |
39 | | - } |
40 | | - document.documentElement.setAttribute("data-md-width", savedWidth); |
41 | | - if (savedWidth === "wide" || savedWidth === "full") { |
42 | | - const savedWidth = localStorage.getItem("md-width") || "slim"; |
43 | | -(function() { |
| 14 | +{{ super() }} |
| 15 | +{% endblock %} |
| 16 | + |
| 17 | +{% block content %} |
44 | 18 | <script> |
45 | | -{% block styles %} |
| 19 | + // Inject toggle button immediately when header is available |
| 20 | + (function () { |
| 21 | + window.__mdWidthIcons = { |
| 22 | + maximize: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="-2 -2 28 28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><g transform="rotate(45 12 12)"><path d="M15 3h6v6"/><path d="m21 3-7 7"/><path d="m3 21 7-7"/><path d="M9 21H3v-6"/></g></svg>', |
| 23 | + minimize: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="-2 -2 28 28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><g transform="rotate(45 12 12)"><path d="m14 10 7-7"/><path d="M20 10h-6V4"/><path d="m3 21 7-7"/><path d="M4 14h6v6"/></g></svg>' |
| 24 | + }; |
46 | 25 |
|
| 26 | + const mode = window.__mdWidthMode || "slim"; |
| 27 | + const btn = document.createElement("button"); |
| 28 | + btn.id = "md-width-toggle"; |
| 29 | + btn.className = "md-header__button md-width-toggle"; |
| 30 | + btn.setAttribute("aria-label", "Toggle page width"); |
| 31 | + btn.innerHTML = mode === "full" ? window.__mdWidthIcons.minimize : window.__mdWidthIcons.maximize; |
| 32 | + |
| 33 | + const header = document.querySelector(".md-header__inner"); |
| 34 | + if (header) { |
| 35 | + const searchButton = header.querySelector(".md-header__button.md-icon[for='__search']") |
| 36 | + || header.querySelector("label.md-header__button"); |
| 37 | + if (searchButton) { |
| 38 | + searchButton.parentNode.insertBefore(btn, searchButton); |
| 39 | + } else { |
| 40 | + header.appendChild(btn); |
| 41 | + } |
| 42 | + } |
| 43 | + })(); |
| 44 | +</script> |
| 45 | +{{ super() }} |
| 46 | +{% endblock %} |
47 | 47 |
|
0 commit comments