From 675cacac8408403a907e2937b3e485eeefe05b1c Mon Sep 17 00:00:00 2001
From: Alexander Bilz <mail@alexbilz.com>
Date: Fri, 08 Jan 2021 11:14:07 +0000
Subject: [PATCH] Merge branch 'master' into pr/72
---
assets/js/anatole-header.js | 54 +-----------------------------------------------------
1 files changed, 1 insertions(+), 53 deletions(-)
diff --git a/assets/js/anatole-header.js b/assets/js/anatole-header.js
index 901fc0f..0bae781 100644
--- a/assets/js/anatole-header.js
+++ b/assets/js/anatole-header.js
@@ -1,53 +1,3 @@
-// initialize default value
-function getTheme() {
- return localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
-}
-
-function setTheme(style) {
- document.documentElement.setAttribute('data-theme', style);
- localStorage.setItem('theme', style);
-}
-
-function init() {
- // initialize default value
- var theme = getTheme();
-
- // check if a prefered color theme is set for users that have never been to our site
- const userPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
- if (theme === null) {
- if (userPrefersDark) {
- setTheme('dark');
- } else if (!document.documentElement.getAttribute('data-theme')) {
- setTheme('light');
- } else {
- setTheme(document.documentElement.getAttribute('data-theme'));
- }
- } else {
- // load a stored theme
- if (theme == 'light') {
- document.documentElement.setAttribute('data-theme', 'light');
- } else {
- document.documentElement.setAttribute('data-theme', 'dark');
- }
- }
-}
-
-
-// switch themes
-function switchTheme(e) {
- var theme = getTheme();
- if (theme == 'light') {
- setTheme('dark');
- } else {
- setTheme('light');
- }
-}
-
-document.addEventListener('DOMContentLoaded', function () {
- var themeSwitcher = document.querySelector('.theme-switch');
- themeSwitcher.addEventListener('click', switchTheme, false);
-}, false);
-
document.addEventListener("DOMContentLoaded", function () {
// Get all "navbar-burger" elements
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll(".navbar-burger"), 0);
@@ -63,6 +13,4 @@
});
});
}
-});
-
-init();
+});
\ No newline at end of file
--
Gitblit v1.10.0