summaryrefslogtreecommitdiff
path: root/layouts/partials/header.html
diff options
context:
space:
mode:
authorReorx <novoreorx@gmail.com>2022-06-01 17:42:42 +0800
committerReorx <novoreorx@gmail.com>2022-06-01 17:42:42 +0800
commitb67d5df2e08a69f850db68f1fa9075e367623508 (patch)
tree353ce5e9f37d4c286ed3d1f0cfee6022f4bc60f3 /layouts/partials/header.html
parent07c4add7bed65cb14f70aed58e7f71133df32814 (diff)
ensure the toggle theme click event listener is only added once
Diffstat (limited to 'layouts/partials/header.html')
-rw-r--r--layouts/partials/header.html7
1 files changed, 7 insertions, 0 deletions
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 2e7512d..1061d5b 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -48,6 +48,13 @@ window.addEventListener('toggle-theme', function() {
toggleThemeCallbacks[key](isDark)
}
});
+
+// this function is used as the event listener for toggle-theme button click
+function toggleThemeListener() {
+ // console.log('click theme-toggle')
+ window.dispatchEvent(new CustomEvent('toggle-theme'));
+}
+
</script>
<script>
// load theme, as early as possible