Skip to content

Commit 2134b99

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4289e33 commit 2134b99

1 file changed

Lines changed: 31 additions & 23 deletions

File tree

  • src/sphinx_book_theme/assets/scripts

src/sphinx_book_theme/assets/scripts/index.js

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -187,38 +187,46 @@ window.toggleFullScreen = toggleFullScreen;
187187
* not open it as a dialog modal. The dialog behavior is only for narrow screens.
188188
*/
189189
function fixSidebarToggle() {
190-
const primaryToggle = document.querySelector('.primary-toggle');
191-
const secondaryToggle = document.querySelector('.secondary-toggle');
192-
const primarySidebar = document.querySelector('#pst-primary-sidebar');
193-
const primaryDialog = document.querySelector('#pst-primary-sidebar-modal');
190+
const primaryToggle = document.querySelector(".primary-toggle");
191+
const secondaryToggle = document.querySelector(".secondary-toggle");
192+
const primarySidebar = document.querySelector("#pst-primary-sidebar");
193+
const primaryDialog = document.querySelector("#pst-primary-sidebar-modal");
194194

195195
// Fix primary sidebar toggle
196196
if (primaryToggle && primarySidebar && primaryDialog) {
197197
// Intercept clicks on the toggle button BEFORE pydata-sphinx-theme's handler
198-
primaryToggle.addEventListener('click', (event) => {
199-
const isWideScreen = window.matchMedia('(min-width: 992px)').matches;
200-
201-
if (isWideScreen) {
202-
// On wide screens, prevent the dialog from opening and toggle sidebar visibility instead
203-
event.preventDefault();
204-
event.stopImmediatePropagation();
205-
206-
// Toggle a class to hide/show the sidebar
207-
primarySidebar.classList.toggle('pst-sidebar-hidden');
208-
}
198+
primaryToggle.addEventListener(
199+
"click",
200+
(event) => {
201+
const isWideScreen = window.matchMedia("(min-width: 992px)").matches;
202+
203+
if (isWideScreen) {
204+
// On wide screens, prevent the dialog from opening and toggle sidebar visibility instead
205+
event.preventDefault();
206+
event.stopImmediatePropagation();
207+
208+
// Toggle a class to hide/show the sidebar
209+
primarySidebar.classList.toggle("pst-sidebar-hidden");
210+
}
209211

210-
// Blur the button so it loses focus and tooltip dismisses naturally
211-
// This works for both wide screens (after collapse) and narrow screens (before dialog opens)
212-
primaryToggle.blur();
213-
}, true); // Use capture phase to run before PST's handler
212+
// Blur the button so it loses focus and tooltip dismisses naturally
213+
// This works for both wide screens (after collapse) and narrow screens (before dialog opens)
214+
primaryToggle.blur();
215+
},
216+
true,
217+
); // Use capture phase to run before PST's handler
214218
}
215219

216220
// Fix secondary sidebar toggle
217221
if (secondaryToggle) {
218-
secondaryToggle.addEventListener('click', () => {
219-
// Blur the button so tooltip dismisses naturally
220-
secondaryToggle.blur();
221-
}, true);
222+
secondaryToggle.addEventListener(
223+
"click",
224+
() => {
225+
// Blur the button so tooltip dismisses naturally
226+
secondaryToggle.blur();
227+
},
228+
true,
229+
);
222230
}
223231
}
224232

0 commit comments

Comments
 (0)