summaryrefslogtreecommitdiff
path: root/src/jwebmail/static
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2023-12-03 19:22:12 +0100
committerJannis M. Hoffmann <jannis@fehcom.de>2023-12-03 19:22:12 +0100
commit2cf2a68bd1c25d8fe4f3126f40bd57982cc6b2a4 (patch)
treeb5c8ed0e1cfe8eac311829296a9aca062bb1abc1 /src/jwebmail/static
initial commit
Diffstat (limited to 'src/jwebmail/static')
-rw-r--r--src/jwebmail/static/src/displayheaders.js35
-rw-r--r--src/jwebmail/static/src/rendermail.js21
2 files changed, 56 insertions, 0 deletions
diff --git a/src/jwebmail/static/src/displayheaders.js b/src/jwebmail/static/src/displayheaders.js
new file mode 100644
index 0000000..3c0936a
--- /dev/null
+++ b/src/jwebmail/static/src/displayheaders.js
@@ -0,0 +1,35 @@
+function toggle_navbar() {
+ // Get the target from the "data-target" attribute
+ const target = this.dataset.target;
+ const $target = document.getElementById(target);
+
+ // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
+ this.classList.toggle('is-active');
+ $target.classList.toggle('is-active');
+}
+
+function sort_select_submit() {
+ this.children[0].form.submit();
+}
+
+function check_all() {
+ const setTo = this.checked;
+ const chkbox = document.getElementsByClassName('jwm-mail-checkbox');
+
+ for (const m of chkbox)
+ m.checked = setTo;
+}
+
+document.addEventListener("DOMContentLoaded", function() {
+ {
+ const sort_select = document.getElementById("sort");
+ const current_option_name = new URL(document.location).searchParams.get("sort");
+ if (current_option_name)
+ sort_select.value = current_option_name;
+ }
+
+ document.getElementById("sort-select").addEventListener("change", sort_select_submit);
+ document.getElementById("navbar-toggle").addEventListener("click", toggle_navbar);
+ document.getElementById("check-all").addEventListener("click", check_all);
+});
+
diff --git a/src/jwebmail/static/src/rendermail.js b/src/jwebmail/static/src/rendermail.js
new file mode 100644
index 0000000..1331913
--- /dev/null
+++ b/src/jwebmail/static/src/rendermail.js
@@ -0,0 +1,21 @@
+function tabSelection(evt) {
+ const self = evt.target;
+
+ for (const ts of self.parentElement.parentElement.children) {
+ ts.classList.remove('is-active');
+ }
+ self.parentNode.classList.add('is-active');
+
+ const bodies = self.parentElement.parentElement.parentElement.parentElement.children[1].children;
+ for (const ts of bodies) {
+ ts.classList.add('is-hidden');
+ }
+ bodies[+self.parentElement.attributes.data.value].classList.remove('is-hidden');
+}
+
+document.addEventListener("DOMContentLoaded", function() {
+ const tabSections = document.getElementsByClassName("jwm-mail-body-multipart-alternative");
+ for (const ts of tabSections) {
+ Array.from(ts.children[0].children[0].children).forEach(element => element.children[0].addEventListener('click', tabSelection));
+ }
+})