From 9b16504485a14b477aa00ae33a43d91e7e4ce9e6 Mon Sep 17 00:00:00 2001 From: Simone <26844016+simonebortolin@users.noreply.github.com> Date: Fri, 30 Dec 2022 17:54:00 +0100 Subject: Streamlining of customisations: migration of numerous functionalities to the JTD fork and add new functionalities implemented by JTD fork (#75) * use form validation by jdt * migrate theme-switch to new version of jtd * Use new feature of jdt * streamlining of customisations: migrate, aux button, modal and theme switch to fork JTD * fix * fix Co-authored-by: Simone Bortolin --- assets/js/modal.js | 28 ---------------------------- assets/js/theme-switch.js | 37 ------------------------------------- 2 files changed, 65 deletions(-) delete mode 100644 assets/js/modal.js delete mode 100644 assets/js/theme-switch.js (limited to 'assets') diff --git a/assets/js/modal.js b/assets/js/modal.js deleted file mode 100644 index c18d751..0000000 --- a/assets/js/modal.js +++ /dev/null @@ -1,28 +0,0 @@ -var modals = document.querySelectorAll("[data-modal]"); -var modalToogles = document.querySelectorAll("[data-toogle=modal]"); - -[...modals].forEach(modal => { - var closeBtns = modal.getElementsByClassName("close"); - [...closeBtns].forEach(closeBtn => { - closeBtn.addEventListener("click", (event) => { - modal.style.display = "none"; - modal.dispatchEvent( new Event('modal-close')); - }); - }) -}); - -[...modalToogles].forEach(toogle => { - toogle.addEventListener("click", (event) => { - var modal = document.querySelector(toogle.getAttribute('data-target')); - modal.style.display = "block"; - modal.dispatchEvent(new Event('modal-open')); - }); -}); - -window.addEventListener("click", function(event) { - if ([...modals].filter(modal => modal.getAttribute("data-modal-backdrop") !== "static").includes(event.target)) { - event.target.dispatchEvent( new Event('modal-close')); - event.target.style.display = "none"; - } -}); - diff --git a/assets/js/theme-switch.js b/assets/js/theme-switch.js deleted file mode 100644 index caffe6e..0000000 --- a/assets/js/theme-switch.js +++ /dev/null @@ -1,37 +0,0 @@ -if(localStorage.getItem("color-scheme") === null) { - const newColorScheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? "dark" : "light"; - const newTextScheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? "Light mode" : "Dark mode"; - jtd.setTheme(newColorScheme); - localStorage.setItem("color-scheme",newColorScheme); - localStorage.setItem("text-scheme",newTextScheme); - window.addEventListener('load', function () { - toggleDarkMode.textContent = newTextScheme; - }); -} else { - jtd.setTheme(localStorage.getItem("color-scheme")); - window.addEventListener('load', function () { - toggleDarkMode.textContent = localStorage.getItem("text-scheme"); - }); -} - -window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { - if(localStorage.getItem("color-scheme") === null) { - const newColorScheme = event.matches ? "dark" : "light"; - const newTextScheme = event.matches ? "Light mode" : "Dark mode"; - jtd.setTheme(newColorScheme); - toggleDarkMode.textContent = newTextScheme; - localStorage.setItem("color-scheme",newColorScheme); - localStorage.setItem("text-scheme",newTextScheme); - } -}); - - -const toggleDarkMode = document.querySelector('.js-toggle-dark-mode'); -jtd.addEvent(toggleDarkMode, 'click', function(){ - const newColorScheme = jtd.getTheme() !== 'dark' ? "dark" : "light"; - const newTextScheme = jtd.getTheme() !== 'dark' ? "Light mode" : "Dark mode"; - jtd.setTheme(newColorScheme); - toggleDarkMode.textContent = newTextScheme; - localStorage.setItem("color-scheme",newColorScheme); - localStorage.setItem("text-scheme",newTextScheme); -}); \ No newline at end of file -- cgit v1.2.3