From eb1dcb7d003293a56993552f6cc130ad13abcc30 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Fri, 18 Aug 2023 23:20:57 +0200 Subject: added tabbing to multipart/alternative --- src/rendermail.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/rendermail.js (limited to 'src/rendermail.js') diff --git a/src/rendermail.js b/src/rendermail.js new file mode 100644 index 0000000..1331913 --- /dev/null +++ b/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)); + } +}) -- cgit v1.2.3