@@ -82,39 +82,36 @@ document.addEventListener("readystatechange", () => {
8282 ========================================================================== */
8383
8484$ ( document ) . ready ( function ( ) {
85- setTheme ( ) ;
86-
87- // if user hasn't chosen a theme, follow OS changes
88- window
89- . matchMedia ( '(prefers-color-scheme: dark)' )
90- . addEventListener ( "change" , ( e ) => {
91- if ( ! localStorage . getItem ( "theme" ) ) {
92- setTheme ( e . matches ? "dark" : "light" ) ;
93- }
94- } ) ;
85+ // SCSS SETTINGS - These should be the same as the settings in the relevant files
86+ const scssLarge = 925 ; // pixels, from /_sass/_themes.scss
87+ const scssMastheadHeight = 70 ; // pixels, from the current theme (e.g., /_sass/theme/_default.scss)
9588
89+ // If the user hasn't chosen a theme, follow the OS preference
90+ setTheme ( ) ;
91+ window . matchMedia ( '(prefers-color-scheme: dark)' )
92+ . addEventListener ( "change" , ( e ) => {
93+ if ( ! localStorage . getItem ( "theme" ) ) {
94+ setTheme ( e . matches ? "dark" : "light" ) ;
95+ }
96+ } ) ;
97+
98+ // Enable the theme toggle
9699 $ ( '#theme-toggle' ) . on ( 'click' , toggleTheme ) ;
97100
98- // These should be the same as the settings in _variables.scss
99- const scssLarge = 925 ; // pixels
100-
101- // Sticky footer
101+ // Enable the sticky footer
102102 var bumpIt = function ( ) {
103103 $ ( "body" ) . css ( "margin-bottom" , $ ( ".page__footer" ) . outerHeight ( true ) ) ;
104- } ,
105- didResize = false ;
106-
107- bumpIt ( ) ;
108-
104+ }
109105 $ ( window ) . resize ( function ( ) {
110106 didResize = true ;
111107 } ) ;
112108 setInterval ( function ( ) {
113109 if ( didResize ) {
114110 didResize = false ;
115111 bumpIt ( ) ;
116- }
117- } , 250 ) ;
112+ } } , 250 ) ;
113+ var didResize = false ;
114+ bumpIt ( ) ;
118115
119116 // FitVids init
120117 fitvids ( ) ;
@@ -132,9 +129,9 @@ $(document).ready(function () {
132129 }
133130 } ) ;
134131
135- // init smooth scroll, this needs to be slightly more than then fixed masthead height
132+ // Init smooth scroll, this needs to be slightly more than then fixed masthead height
136133 $ ( "a" ) . smoothScroll ( {
137- offset : - 75 , // needs to match $masthead-height
134+ offset : - scssMastheadHeight ,
138135 preventDefault : false ,
139136 } ) ;
140137
0 commit comments