Skip to content

Commit 6c32b5d

Browse files
author
committed
Deployed 6c80d8f with MkDocs version: 1.6.1
1 parent 6e1275a commit 6c32b5d

1 file changed

Lines changed: 15 additions & 27 deletions

File tree

assets/topbar.js

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
'<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>' +
3232
'</svg>';
3333

34-
var SVG_SEARCH =
35-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">' +
36-
'<path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/>' +
37-
'</svg>';
38-
3934
var SVG_SUN =
4035
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">' +
4136
'<path d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zM2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1zm18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1zM11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1zm0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1zM5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41L5.99 4.58zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41l-1.06-1.06zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06z"/>' +
@@ -46,9 +41,10 @@
4641
'<path d="M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9 9-4.03 9-9c0-.46-.04-.92-.1-1.36-.98 1.37-2.58 2.26-4.4 2.26-2.98 0-5.4-2.42-5.4-5.4 0-1.81.89-3.42 2.26-4.4-.44-.06-.9-.1-1.36-.1z"/>' +
4742
'</svg>';
4843

49-
/* Module-level reference so updateThemeIcon can be called from anywhere,
50-
including the instant-navigation callback after the topbar is already built. */
44+
/* Module-level references so the built bar can be re-inserted on instant
45+
navigation without recreating it (prevents the logo img from reloading). */
5146
var themeBtn = null;
47+
var savedBar = null;
5248

5349
function getScheme() {
5450
/* Prefer our own stored key — avoids Material overwriting it on navigation */
@@ -100,15 +96,23 @@
10096
}
10197

10298
function inject() {
103-
/* On instant navigation the topbar persists — sync state and exit. */
99+
/* Topbar already in DOM — just sync state. */
104100
if (document.getElementById('utplsql-topbar')) {
105101
updateActiveLink();
106-
/* Re-apply our scheme AFTER Material's navigation hook may have changed it */
107102
applyStoredScheme();
108103
return;
109104
}
110105

111-
/* ── Bar ── */
106+
/* Material's instant navigation removed the topbar — re-insert the same
107+
DOM node so the logo <img> is not recreated and doesn't flash/reload. */
108+
if (savedBar) {
109+
document.body.insertBefore(savedBar, document.body.firstChild);
110+
updateActiveLink();
111+
applyStoredScheme();
112+
return;
113+
}
114+
115+
/* ── First load: build the bar ── */
112116
var bar = document.createElement('nav');
113117
bar.id = 'utplsql-topbar';
114118
bar.setAttribute('aria-label', 'utPLSQL.org site navigation');
@@ -151,23 +155,6 @@
151155
var controls = document.createElement('div');
152156
controls.className = 'utplsql-controls';
153157

154-
/* Search button — on mobile triggers Material's search overlay via its
155-
own label (the form is hidden until that label is clicked); on desktop
156-
the form is already visible so focusing the input is enough. */
157-
var searchBtn = document.createElement('button');
158-
searchBtn.setAttribute('aria-label', 'Search');
159-
searchBtn.innerHTML = SVG_SEARCH;
160-
searchBtn.addEventListener('click', function () {
161-
var searchLabel = document.querySelector('label[for="__search"]');
162-
if (searchLabel) {
163-
searchLabel.click();
164-
} else {
165-
var input = document.querySelector('.md-search__input');
166-
if (input) input.focus();
167-
}
168-
});
169-
controls.appendChild(searchBtn);
170-
171158
/* Theme toggle — assigned to module-level themeBtn so updateThemeIcon
172159
can be called from the navigation callback without re-injecting. */
173160
themeBtn = document.createElement('button');
@@ -195,6 +182,7 @@
195182
controls.appendChild(themeBtn);
196183
bar.appendChild(controls);
197184

185+
savedBar = bar;
198186
document.body.insertBefore(bar, document.body.firstChild);
199187
updateActiveLink();
200188
}

0 commit comments

Comments
 (0)