Skip to content

Commit 791f825

Browse files
remove unneeded window globals
1 parent c484bf8 commit 791f825

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/resources/formats/html/giscus/giscus.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
if(giscusIframe) {
2323
giscusIframe.addEventListener("load", function() {
2424
window.setTimeout(() => {
25-
window.toggleGiscusIfUsed(window.hasAlternateSentinel(), authorPrefersDark);
25+
toggleGiscusIfUsed(hasAlternateSentinel(), authorPrefersDark);
2626
}, 100);
2727
});
2828
giscusIframeObserver.disconnect();

src/resources/formats/html/templates/quarto-html-after-body.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
2323
window.document.body.appendChild(a);
2424
}
25-
window.setColorSchemeToggle(window.hasAlternateSentinel())
25+
setColorSchemeToggle(hasAlternateSentinel())
2626
2727
<% } %>
2828

src/resources/formats/html/templates/quarto-html-before-body.ejs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
}
2222
}
2323
24-
window.setColorSchemeToggle = (alternate) => {
24+
const setColorSchemeToggle = (alternate) => {
2525
const toggles = window.document.querySelectorAll('.quarto-color-scheme-toggle');
2626
for (let i=0; i < toggles.length; i++) {
2727
const toggle = toggles[i];
@@ -56,7 +56,7 @@
5656
manageTransitions('#quarto-margin-sidebar .nav-link', true);
5757
5858
// Switch the toggles
59-
window.setColorSchemeToggle(alternate)
59+
setColorSchemeToggle(alternate)
6060
6161
// Hack to workaround the fact that safari doesn't
6262
// properly recolor the scrollbar when toggling (#1455)
@@ -103,7 +103,7 @@
103103
return window.location.protocol === 'file:';
104104
}
105105
106-
window.hasAlternateSentinel = () => {
106+
const hasAlternateSentinel = () => {
107107
let styleSentinel = getColorSchemeSentinel();
108108
if (styleSentinel !== null) {
109109
return styleSentinel === "alternate";
@@ -182,14 +182,12 @@
182182
// Dark / light mode switch
183183
window.quartoToggleColorScheme = () => {
184184
// Read the current dark / light value
185-
let toAlternate = !window.hasAlternateSentinel();
185+
let toAlternate = !hasAlternateSentinel();
186186
toggleColorMode(toAlternate);
187187
setStyleSentinel(toAlternate);
188188
toggleGiscusIfUsed(toAlternate, darkModeDefault);
189189
};
190190
191-
window.toggleGiscusIfUsed = toggleGiscusIfUsed;
192-
193191
<% if (respectUserColorScheme) { %>
194192
queryPrefersDark.addEventListener("change", e => {
195193
if(window.localStorage.getItem("quarto-color-scheme") !== null)
@@ -202,7 +200,7 @@
202200
<% } %>
203201
204202
// Switch to dark mode if need be
205-
if (window.hasAlternateSentinel()) {
203+
if (hasAlternateSentinel()) {
206204
toggleColorMode(true);
207205
} else {
208206
toggleColorMode(false);

0 commit comments

Comments
 (0)