22 jQuery plugin settings and other scripts
33 ========================================================================== */
44
5- $ ( document ) . ready ( function ( ) {
5+ $ ( document ) . ready ( function ( ) {
6+ // Set the theme on page load
7+ var setTheme = function ( theme ) {
8+ const use_theme = theme || localStorage . getItem ( "theme" ) || $ ( "html" ) . attr ( "data-theme" ) ;
9+ if ( use_theme === "dark" ) {
10+ $ ( "html" ) . attr ( "data-theme" , "dark" ) ;
11+ $ ( "#theme-icon" ) . removeClass ( "fa-sun" ) . addClass ( "fa-moon" ) ;
12+ } else if ( use_theme === "light" ) {
13+ $ ( "html" ) . removeAttr ( "data-theme" ) ;
14+ $ ( "#theme-icon" ) . removeClass ( "fa-moon" ) . addClass ( "fa-sun" ) ;
15+ }
16+ }
17+ setTheme ( ) ;
18+
19+ // Toggle the theme
20+ var toggleTheme = function ( ) {
21+ const current_theme = $ ( "html" ) . attr ( "data-theme" ) ;
22+ const new_theme = current_theme === "dark" ? "light" : "dark" ;
23+ localStorage . setItem ( "theme" , new_theme ) ;
24+ setTheme ( new_theme ) ;
25+ }
26+ $ ( '#theme-toggle' ) . on ( 'click' , function ( ) {
27+ toggleTheme ( ) ;
28+ } ) ;
29+
630 // These should be the same as the settings in _variables.scss
7- scssLarge = 925 ; // pixels
31+ const scssLarge = 925 ; // pixels
832
933 // Sticky footer
10- var bumpIt = function ( ) {
11- $ ( "body" ) . css ( "margin-bottom" , $ ( ".page__footer" ) . outerHeight ( true ) ) ;
12- } ,
34+ var bumpIt = function ( ) {
35+ $ ( "body" ) . css ( "margin-bottom" , $ ( ".page__footer" ) . outerHeight ( true ) ) ;
36+ } ,
1337 didResize = false ;
1438
1539 bumpIt ( ) ;
1640
17- $ ( window ) . resize ( function ( ) {
41+ $ ( window ) . resize ( function ( ) {
1842 didResize = true ;
1943 } ) ;
20- setInterval ( function ( ) {
44+ setInterval ( function ( ) {
2145 if ( didResize ) {
2246 didResize = false ;
2347 bumpIt ( ) ;
2448 }
2549 } , 250 ) ;
26-
50+
2751 // FitVids init
2852 fitvids ( ) ;
2953
3054 // Follow menu drop down
31- $ ( ".author__urls-wrapper button" ) . on ( "click" , function ( ) {
32- $ ( ".author__urls" ) . fadeToggle ( "fast" , function ( ) { } ) ;
55+ $ ( ".author__urls-wrapper button" ) . on ( "click" , function ( ) {
56+ $ ( ".author__urls" ) . fadeToggle ( "fast" , function ( ) { } ) ;
3357 $ ( ".author__urls-wrapper button" ) . toggleClass ( "open" ) ;
3458 } ) ;
3559
3660 // Restore the follow menu if toggled on a window resize
37- jQuery ( window ) . on ( 'resize' , function ( ) {
61+ jQuery ( window ) . on ( 'resize' , function ( ) {
3862 if ( $ ( '.author__urls.social-icons' ) . css ( 'display' ) == 'none' && $ ( window ) . width ( ) >= scssLarge ) {
3963 $ ( ".author__urls" ) . css ( 'display' , 'block' )
4064 }
41- } ) ;
65+ } ) ;
4266
4367 // init smooth scroll, this needs to be slightly more than then fixed masthead height
44- $ ( "a" ) . smoothScroll ( { offset : - 65 } ) ;
68+ $ ( "a" ) . smoothScroll ( { offset : - 65 } ) ;
4569
4670 // add lightbox class to all image links
4771 $ ( "a[href$='.jpg'],a[href$='.jpeg'],a[href$='.JPG'],a[href$='.png'],a[href$='.gif']" ) . addClass ( "image-popup" ) ;
@@ -53,7 +77,7 @@ $(document).ready(function(){
5377 gallery : {
5478 enabled : true ,
5579 navigateByImgClick : true ,
56- preload : [ 0 , 1 ] // Will preload 0 - before current, and 1 after the current image
80+ preload : [ 0 , 1 ] // Will preload 0 - before current, and 1 after the current image
5781 } ,
5882 image : {
5983 tError : '<a href="%url%">Image #%curr%</a> could not be loaded.' ,
@@ -63,7 +87,7 @@ $(document).ready(function(){
6387 // make it unique to apply your CSS animations just to this exact popup
6488 mainClass : 'mfp-zoom-in' ,
6589 callbacks : {
66- beforeOpen : function ( ) {
90+ beforeOpen : function ( ) {
6791 // just a hack that adds mfp-anim class to markup
6892 this . st . image . markup = this . st . image . markup . replace ( 'mfp-figure' , 'mfp-figure mfp-with-anim' ) ;
6993 }
0 commit comments