parent
3f74e15115
commit
7121cfaabd
@ -0,0 +1,11 @@ |
|||||||
|
{ |
||||||
|
"extends": "standard", |
||||||
|
"globals": { |
||||||
|
"$": false, |
||||||
|
"Vue": false, |
||||||
|
"_": false |
||||||
|
}, |
||||||
|
"rules": { |
||||||
|
"camelcase": ["off", { "properties": "never" }] |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -1,35 +1,35 @@ |
|||||||
$(function () { |
$(function () { |
||||||
// theme switcher without reloading
|
// theme switcher without reloading
|
||||||
|
|
||||||
let themeStyle = $('#theme-style'); |
let themeStyle = $('#theme-style') |
||||||
const lightURL = themeStyle.data('light-url'); |
const lightURL = themeStyle.data('light-url') |
||||||
const darkURL = themeStyle.data('dark-url'); |
const darkURL = themeStyle.data('dark-url') |
||||||
const navbar = $('.page-navbar'); |
const navbar = $('.page-navbar') |
||||||
const logo = $('#navbar-logo'); |
const logo = $('#navbar-logo') |
||||||
|
|
||||||
window.toggleDarkMode = function () { |
window.toggleDarkMode = function () { |
||||||
let newStyle = document.createElement('link'); |
let newStyle = document.createElement('link') |
||||||
newStyle.rel = 'stylesheet'; |
newStyle.rel = 'stylesheet' |
||||||
if (themeStyle.attr('href') === lightURL) { |
if (themeStyle.attr('href') === lightURL) { |
||||||
newStyle.href = darkURL; |
newStyle.href = darkURL |
||||||
navbar.removeClass('navbar-light'); |
navbar.removeClass('navbar-light') |
||||||
navbar.addClass('navbar-dark'); |
navbar.addClass('navbar-dark') |
||||||
logo.attr('src', logo.data('src-dark')); |
logo.attr('src', logo.data('src-dark')) |
||||||
|
|
||||||
document.cookie = "dark_mode=1"; |
document.cookie = 'dark_mode=1' |
||||||
} else { |
} else { |
||||||
newStyle.href = lightURL; |
newStyle.href = lightURL |
||||||
navbar.removeClass('navbar-dark'); |
navbar.removeClass('navbar-dark') |
||||||
navbar.addClass('navbar-light'); |
navbar.addClass('navbar-light') |
||||||
logo.attr('src', logo.data('src-light')); |
logo.attr('src', logo.data('src-light')) |
||||||
|
|
||||||
document.cookie = "dark_mode=0;expires=" + new Date().toUTCString(); |
document.cookie = 'dark_mode=0;expires=' + new Date().toUTCString() |
||||||
} |
} |
||||||
|
|
||||||
// remove old css after new css has loaded to prevent FOUC
|
// remove old css after new css has loaded to prevent FOUC
|
||||||
let oldThemeStyle = themeStyle; |
let oldThemeStyle = themeStyle |
||||||
themeStyle = $(newStyle); |
themeStyle = $(newStyle) |
||||||
themeStyle.on('load', () => oldThemeStyle.remove()); |
themeStyle.on('load', () => oldThemeStyle.remove()) |
||||||
$(document.head).append(themeStyle); |
$(document.head).append(themeStyle) |
||||||
}; |
} |
||||||
}); |
}) |
||||||
|
Loading…
Reference in new issue