summaryrefslogtreecommitdiff
path: root/src/rendermail.js
blob: 1331913313d8ea1a4aca71db8309ef70094fd0e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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));
    }
})