Skip to content

Commit 98003a7

Browse files
committed
Pre-commit fix
1 parent ea95085 commit 98003a7

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
@@ -188,19 +188,23 @@ window.toggleFullScreen = toggleFullScreen;
188188
function addBlurToButtons() {
189189
// List of button selectors that should blur on click to dismiss tooltips
190190
const buttonSelectors = [
191-
'.theme-switch-button',
192-
'.search-button',
193-
'.primary-toggle',
194-
'.secondary-toggle',
191+
".theme-switch-button",
192+
".search-button",
193+
".primary-toggle",
194+
".secondary-toggle",
195195
];
196196

197197
// Add blur on click for each button type
198-
buttonSelectors.forEach(selector => {
198+
buttonSelectors.forEach((selector) => {
199199
const button = document.querySelector(selector);
200200
if (button) {
201-
button.addEventListener('click', () => {
202-
button.blur();
203-
}, true);
201+
button.addEventListener(
202+
"click",
203+
() => {
204+
button.blur();
205+
},
206+
true,
207+
);
204208
}
205209
});
206210
}
@@ -211,25 +215,29 @@ function addBlurToButtons() {
211215
* not open it as a dialog modal. The dialog behavior is only for narrow screens.
212216
*/
213217
function fixSidebarToggle() {
214-
const primaryToggle = document.querySelector('.primary-toggle');
215-
const primarySidebar = document.querySelector('#pst-primary-sidebar');
216-
const primaryDialog = document.querySelector('#pst-primary-sidebar-modal');
218+
const primaryToggle = document.querySelector(".primary-toggle");
219+
const primarySidebar = document.querySelector("#pst-primary-sidebar");
220+
const primaryDialog = document.querySelector("#pst-primary-sidebar-modal");
217221

218222
// Fix primary sidebar toggle
219223
if (primaryToggle && primarySidebar && primaryDialog) {
220224
// Intercept clicks on the toggle button BEFORE pydata-sphinx-theme's handler
221-
primaryToggle.addEventListener('click', (event) => {
222-
const isWideScreen = window.matchMedia('(min-width: 992px)').matches;
223-
224-
if (isWideScreen) {
225-
// On wide screens, prevent the dialog from opening and toggle sidebar visibility instead
226-
event.preventDefault();
227-
event.stopImmediatePropagation();
228-
229-
// Toggle a class to hide/show the sidebar
230-
primarySidebar.classList.toggle('pst-sidebar-hidden');
231-
}
232-
}, true); // Use capture phase to run before PST's handler
225+
primaryToggle.addEventListener(
226+
"click",
227+
(event) => {
228+
const isWideScreen = window.matchMedia("(min-width: 992px)").matches;
229+
230+
if (isWideScreen) {
231+
// On wide screens, prevent the dialog from opening and toggle sidebar visibility instead
232+
event.preventDefault();
233+
event.stopImmediatePropagation();
234+
235+
// Toggle a class to hide/show the sidebar
236+
primarySidebar.classList.toggle("pst-sidebar-hidden");
237+
}
238+
},
239+
true,
240+
); // Use capture phase to run before PST's handler
233241
}
234242
}
235243

0 commit comments

Comments
 (0)