PEed the themer

This commit is contained in:
Heydon Pickering 2017-08-19 18:18:18 +01:00
parent 91db19dfae
commit 5c07e6d1a4
5 changed files with 33 additions and 11 deletions

View File

@ -71,6 +71,10 @@ figure p img {
div:not([tabindex]):focus {
outline: none;
}
[hidden] {
display: none;
}
/* skip link */
[href="#main"] {

View File

@ -128,11 +128,16 @@
/* Switch and persist theme */
(function () {
var checkbox = document.getElementById('themer');
var invertor = document.getElementById('inverter');
var inverter = document.getElementById('inverter');
function darkTheme(media) {
invertor.setAttribute('media', media);
invertor.textContent = invertor.textContent.trim();
if (!('filter' in document.body.style)) {
checkbox.parentNode.hidden = true;
return;
}
inverter.setAttribute('media', media);
inverter.textContent = inverter.textContent.trim();
localStorage.setItem('darkTheme', media);
}
@ -141,8 +146,10 @@
});
window.addEventListener('DOMContentLoaded', function () {
if ('filter' in document.body.style) {
if (localStorage.getItem('darkTheme') === 'screen') {
checkbox.click();
}
}
});
}());

File diff suppressed because one or more lines are too long

View File

@ -71,6 +71,10 @@ figure p img {
div:not([tabindex]):focus {
outline: none;
}
[hidden] {
display: none;
}
/* skip link */
[href="#main"] {

View File

@ -128,11 +128,16 @@
/* Switch and persist theme */
(function () {
var checkbox = document.getElementById('themer');
var invertor = document.getElementById('inverter');
var inverter = document.getElementById('inverter');
function darkTheme(media) {
invertor.setAttribute('media', media);
invertor.textContent = invertor.textContent.trim();
if (!('filter' in document.body.style)) {
checkbox.parentNode.hidden = true;
return;
}
inverter.setAttribute('media', media);
inverter.textContent = inverter.textContent.trim();
localStorage.setItem('darkTheme', media);
}
@ -141,8 +146,10 @@
});
window.addEventListener('DOMContentLoaded', function () {
if ('filter' in document.body.style) {
if (localStorage.getItem('darkTheme') === 'screen') {
checkbox.click();
}
}
});
}());