|
1 | 1 | <!DOCTYPE HTML> |
2 | | -<html lang="{{ language }}" class="{{ default_theme }}" dir="{{ text_direction }}"> |
| 2 | +<html lang="{{ language }}" class="{{ default_theme }} sidebar-visible" dir="{{ text_direction }}"> |
3 | 3 | <head> |
4 | 4 | <!-- Book generated using mdBook --> |
5 | 5 | <meta charset="UTF-8"> |
|
52 | 52 | <!-- MathJax --> |
53 | 53 | <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
54 | 54 | {{/if}} |
55 | | - </head> |
56 | | - <body class="sidebar-visible no-js"> |
57 | | - <div id="body-container"> |
| 55 | + |
58 | 56 | <!-- Provide site root to javascript --> |
59 | 57 | <script> |
60 | 58 | var path_to_root = "{{ path_to_root }}"; |
61 | 59 | var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}"; |
62 | 60 | </script> |
63 | | - |
| 61 | + <!-- Start loading toc.js asap --> |
| 62 | + <script src="{{ path_to_root }}toc.js"></script> |
| 63 | + </head> |
| 64 | + <body> |
| 65 | + <div id="body-container"> |
64 | 66 | <!-- Work around some values being stored in localStorage wrapped in quotes --> |
65 | 67 | <script> |
66 | 68 | try { |
|
82 | 84 | var theme; |
83 | 85 | try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } |
84 | 86 | if (theme === null || theme === undefined) { theme = default_theme; } |
85 | | - var html = document.querySelector('html'); |
| 87 | + const html = document.documentElement; |
86 | 88 | html.classList.remove('{{ default_theme }}') |
87 | 89 | html.classList.add(theme); |
88 | | - var body = document.querySelector('body'); |
89 | | - body.classList.remove('no-js') |
90 | | - body.classList.add('js'); |
| 90 | + html.classList.add("js"); |
91 | 91 | </script> |
92 | 92 |
|
93 | 93 | <input type="checkbox" id="sidebar-toggle-anchor" class="hidden"> |
94 | 94 |
|
95 | 95 | <!-- Hide / unhide sidebar before it is displayed --> |
96 | 96 | <script> |
97 | | - var body = document.querySelector('body'); |
98 | 97 | var sidebar = null; |
99 | 98 | var sidebar_toggle = document.getElementById("sidebar-toggle-anchor"); |
100 | 99 | if (document.body.clientWidth >= 1080) { |
|
104 | 103 | sidebar = 'hidden'; |
105 | 104 | } |
106 | 105 | sidebar_toggle.checked = sidebar === 'visible'; |
107 | | - body.classList.remove('sidebar-visible'); |
108 | | - body.classList.add("sidebar-" + sidebar); |
| 106 | + html.classList.remove('sidebar-visible'); |
| 107 | + html.classList.add("sidebar-" + sidebar); |
109 | 108 | </script> |
110 | 109 |
|
111 | 110 | <nav id="sidebar" class="sidebar" aria-label="Table of contents"> |
112 | | - <div class="sidebar-scrollbox"> |
113 | | - {{#toc}}{{/toc}} |
| 111 | + <!-- populated by js --> |
| 112 | + <mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox> |
| 113 | + <noscript> |
| 114 | + <iframe class="sidebar-iframe-outer" src="{{ path_to_root }}toc.html"></iframe> |
| 115 | + </noscript> |
| 116 | + <div id="sidebar-resize-handle" class="sidebar-resize-handle"> |
| 117 | + <div class="sidebar-resize-indicator"></div> |
114 | 118 | </div> |
115 | | - <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div> |
116 | 119 | </nav> |
117 | 120 |
|
118 | | - <!-- Track and set sidebar scroll position --> |
119 | | - <script> |
120 | | - var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox'); |
121 | | - sidebarScrollbox.addEventListener('click', function(e) { |
122 | | - if (e.target.tagName === 'A') { |
123 | | - sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop); |
124 | | - } |
125 | | - }, { passive: true }); |
126 | | - var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll'); |
127 | | - sessionStorage.removeItem('sidebar-scroll'); |
128 | | - if (sidebarScrollTop) { |
129 | | - // preserve sidebar scroll position when navigating via links within sidebar |
130 | | - sidebarScrollbox.scrollTop = sidebarScrollTop; |
131 | | - } else { |
132 | | - // scroll sidebar to current active section when navigating via "next/previous chapter" buttons |
133 | | - var activeSection = document.querySelector('#sidebar .active'); |
134 | | - if (activeSection) { |
135 | | - activeSection.scrollIntoView({ block: 'center' }); |
136 | | - } |
137 | | - } |
138 | | - </script> |
139 | | - |
140 | 121 | <div id="page-wrapper" class="page-wrapper"> |
141 | 122 |
|
142 | 123 | <div class="page"> |
|
0 commit comments