mirror of https://github.com/docker/docs.git
Show dark version of site when prefers-color-scheme:dark (#8921)
This commit is contained in:
parent
71c3891877
commit
ec3da7c84d
11
js/docs.js
11
js/docs.js
|
@ -223,7 +223,10 @@ function eraseCookie(name) {
|
|||
createCookie(name,"",-1);
|
||||
}
|
||||
|
||||
if (readCookie("night") == "true") {
|
||||
var prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
var selectedNightTheme = readCookie("night");
|
||||
|
||||
if (selectedNightTheme == "true" || (selectedNightTheme === null && prefersDark)) {
|
||||
applyNight();
|
||||
$('#switch-style').prop('checked', true);
|
||||
} else {
|
||||
|
@ -344,8 +347,7 @@ $('ul.nav li.dropdown').hover(function() {
|
|||
// document.getElementById('pagestyle').setAttribute('href', sheet);
|
||||
// }
|
||||
|
||||
function applyNight()
|
||||
{
|
||||
function applyNight() {
|
||||
$( "body" ).addClass( "night" );
|
||||
}
|
||||
|
||||
|
@ -360,8 +362,7 @@ $('#switch-style').change(function() {
|
|||
createCookie("night",true,999)
|
||||
} else {
|
||||
applyDay();
|
||||
// swapStyleSheet('/css/style.css');
|
||||
eraseCookie("night")
|
||||
createCookie("night",false,999);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue