aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2024-02-09 19:00:31 -0500
committertdro <tdro@noreply.example.com>2024-02-09 19:00:31 -0500
commita0e27279c740611b7a6a47a6a419abbb1559ae6c (patch)
treefb791df54cf931163bcadf70c77b0756b015950d
parent565847b63d5ee98c04ea9e30deaa91bf35cc3880 (diff)
downloadcanory-a0e27279c740611b7a6a47a6a419abbb1559ae6c.tar.gz
canory-a0e27279c740611b7a6a47a6a419abbb1559ae6c.tar.bz2
canory-a0e27279c740611b7a6a47a6a419abbb1559ae6c.zip
static/js/forms: Activate on storage + DOM load
Always expose alternate stylesheets
-rw-r--r--assets/js/index.js13
-rw-r--r--static/js/forms.ts12
-rw-r--r--themes/default/layouts/partials/head-css.html3
3 files changed, 18 insertions, 10 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index e80d794..9374f5d 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -720,10 +720,15 @@
}
});
});
- self.addEventListener("storage", function() {
- let stylesheet = document.querySelector('link[href$="default-simple.css"]');
- if (localStorage["config.density.low"] === "on") stylesheet.rel = "stylesheet";
- if (localStorage["config.density.high"] === "on") stylesheet.rel = "alternate stylesheet";
+ [
+ "storage",
+ "DOMContentLoaded"
+ ].forEach(function(event) {
+ self.addEventListener(event, function() {
+ let stylesheet = document.querySelector('link[href$="default-simple.css"]');
+ if (localStorage["config.density.low"] === "on") stylesheet.rel = "stylesheet";
+ if (localStorage["config.density.high"] === "on") stylesheet.rel = "alternate stylesheet";
+ });
});
})();
(function() {
diff --git a/static/js/forms.ts b/static/js/forms.ts
index 24c3d09..3b1aedc 100644
--- a/static/js/forms.ts
+++ b/static/js/forms.ts
@@ -49,11 +49,13 @@
});
});
- self.addEventListener("storage", function () {
- let stylesheet = document.querySelector('link[href$="default-simple.css"]')
+ ["storage", "DOMContentLoaded"].forEach(function (event) {
+ self.addEventListener(event, function () {
+ let stylesheet = document.querySelector('link[href$="default-simple.css"]')
- if (localStorage["config.density.low"] === "on") stylesheet.rel = "stylesheet"
- if (localStorage["config.density.high"] === "on") stylesheet.rel = "alternate stylesheet"
- });
+ if (localStorage["config.density.low"] === "on") stylesheet.rel = "stylesheet"
+ if (localStorage["config.density.high"] === "on") stylesheet.rel = "alternate stylesheet"
+ });
+ });
})();
diff --git a/themes/default/layouts/partials/head-css.html b/themes/default/layouts/partials/head-css.html
index 662aa6b..3aaac30 100644
--- a/themes/default/layouts/partials/head-css.html
+++ b/themes/default/layouts/partials/head-css.html
@@ -14,5 +14,6 @@
{{ else }}
<link rel="stylesheet" href="{{ $default.Permalink }}" title="Default" />
<link rel="stylesheet" href="{{ $syntax.Permalink }}" />
-<link rel="alternate stylesheet" href="{{ $simple.Permalink }}" />
{{ end }}
+
+<link rel="alternate stylesheet" href="{{ $simple.Permalink }}" />