diff options
author | Paul Duncan <pabs@pablotron.org> | 2025-04-01 00:32:34 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2025-04-01 00:32:34 -0400 |
commit | b0f57851570b3229b034eb0f2e05ebdf67bbf0e6 (patch) | |
tree | 6e1a37cf838d8f925301d3d99c0517179fe6244e /themes/hugo-pt2021/assets | |
parent | 6d847d70254379fb21744cfe91f2ef5860a3129d (diff) | |
download | pablotron.org-b0f57851570b3229b034eb0f2e05ebdf67bbf0e6.tar.xz pablotron.org-b0f57851570b3229b034eb0f2e05ebdf67bbf0e6.zip |
themes/hugo-pt2021/assets/script.js: remove old notes
Diffstat (limited to 'themes/hugo-pt2021/assets')
-rw-r--r-- | themes/hugo-pt2021/assets/script.js | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/themes/hugo-pt2021/assets/script.js b/themes/hugo-pt2021/assets/script.js index c1086cc..8eb527c 100644 --- a/themes/hugo-pt2021/assets/script.js +++ b/themes/hugo-pt2021/assets/script.js @@ -1,16 +1,13 @@ 'use strict'; // -// script.js - script which handles: +// script.js: minimal JS for pablotron.org // -// - check/set dark mode (added 2024-05-27) -// - enable burger menu support +// - set theme on page load +// - bind theme switcher and burger menu event handlers // -// original notes regarding burger menu and minification are in the -// "burger menu" section below -// -// burger menu (2024-05-27) -// ------------------------ +// theme switcher (2024-05-27) +// --------------------------- // does the following: // // 1. checks for user setting and use that, if present. @@ -56,25 +53,16 @@ const D = document, M = window.matchMedia, on = (el, id, fn) => el.addEventListener(id, fn); -// use theme if set, otherwise fall back to dark mode -// FIXME: move to DOMContentLoaded? -// -// update (2025-03-31): prefer dark mode by default and only set light -// mode if the user has explicitly selected the light theme using the -// theme toggle. -// -// the old logic also attempted to account for "prefers-color-scheme: -// light", but i want the default to be dark unless it is explicitly -// overridden. +// light theme selected by user? if (L && L.theme && L.theme === 'light') { C.remove('dark'); // set light theme } -document.addEventListener('DOMContentLoaded', () => { +D.addEventListener('DOMContentLoaded', () => { // theme toggle event handler - on(D.querySelector('.navbar-item[data-id="theme"]'), 'click', (e) => { + on(D.querySelector('.navbar-item[data-id="theme"]'), 'click', e => { e.preventDefault(); // stop event - L.theme = C.toggle('dark') ? 'dark' : 'light'; // toggle + L.theme = C.toggle('dark') ? 'dark' : 'light'; // toggle theme }); // iterate through burgers, bind to click events |