|
230 | 230 | controls.appendChild(themeBtn); |
231 | 231 | bar.appendChild(controls); |
232 | 232 |
|
233 | | - /* Injected only after the topbar is successfully built so that a JS failure |
234 | | - leaves Material's original header navigation intact as a fallback. */ |
235 | | - if (!document.getElementById('utplsql-topbar-style')) { |
236 | | - var style = document.createElement('style'); |
237 | | - style.id = 'utplsql-topbar-style'; |
238 | | - style.textContent = |
239 | | - /* Hide Material's hamburger/logo — our topbar has both */ |
240 | | - '.md-header__button:not([for="__search"]) { display: none !important; }' + |
241 | | - /* Move palette toggle off-screen — our topbar handles theme switching */ |
242 | | - '.md-header__option { position: absolute !important; left: -9999px !important; }' + |
243 | | - /* Back-to-top button: clear topbar + header */ |
244 | | - '.md-top { top: 4.4rem !important; z-index: 11; }'; |
245 | | - document.head.appendChild(style); |
246 | | - } |
247 | | - |
248 | 233 | savedBar = bar; |
249 | 234 | document.body.insertBefore(bar, document.body.firstChild); |
250 | 235 | updateActiveLink(); |
|
258 | 243 | }); |
259 | 244 | } |
260 | 245 |
|
| 246 | + /* Hide Material's built-in header controls immediately — same pattern as |
| 247 | + applyScheme — to prevent a flash where logo/palette appear before the |
| 248 | + topbar is painted. A fallback timeout removes the style if the topbar |
| 249 | + never gets built (e.g. script error), restoring Material's navigation. */ |
| 250 | + if (!document.getElementById('utplsql-topbar-style')) { |
| 251 | + var _style = document.createElement('style'); |
| 252 | + _style.id = 'utplsql-topbar-style'; |
| 253 | + _style.textContent = |
| 254 | + '.md-header__button:not([for="__search"]) { display: none !important; }' + |
| 255 | + '.md-header__option { position: absolute !important; left: -9999px !important; }' + |
| 256 | + '.md-top { top: 4.4rem !important; z-index: 11; }'; |
| 257 | + document.head.appendChild(_style); |
| 258 | + /* Fallback: if topbar not in DOM after 4 s, restore Material's navigation */ |
| 259 | + setTimeout(function () { |
| 260 | + if (!document.getElementById('utplsql-topbar')) { |
| 261 | + var s = document.getElementById('utplsql-topbar-style'); |
| 262 | + if (s) s.parentNode.removeChild(s); |
| 263 | + } |
| 264 | + }, 4000); |
| 265 | + } |
| 266 | + |
261 | 267 | /* Apply initial scheme as early as possible to avoid flash. */ |
262 | 268 | applyScheme(effectiveScheme(getPreference())); |
263 | 269 |
|
|
0 commit comments