forked from scheme-requests-for-implementation/srfi-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maillist.js
46 lines (45 loc) · 1.37 KB
/
maillist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function addCloser(div) {
div.querySelector(".close").addEventListener(
"click",
function(event) {
event.preventDefault();
event.stopPropagation();
for (let button of div.querySelectorAll("button")) {
button.classList.remove("invisible");
}
event.target.classList.add("invisible");
for (let form of div.querySelectorAll("form")) {
form.classList.add("invisible");
}
});
}
function addRevealer(div, selector) {
div.querySelector("button" + selector).addEventListener(
"click",
function(event) {
event.preventDefault();
event.stopPropagation();
div.querySelector("form" + selector).classList.remove("invisible");
for (let button of div.querySelectorAll("button")) {
if (button.classList.contains("close")) {
button.classList.remove("invisible");
} else {
button.classList.add("invisible");
}
}
});
}
for (let div of document.querySelectorAll(".subunsub")) {
for (let button of div.querySelectorAll("button.sub")) {
button.classList.remove("invisible");
}
for (let button of div.querySelectorAll("button.unsub")) {
button.classList.remove("invisible");
}
for (let form of div.querySelectorAll("form")) {
form.classList.add("invisible");
}
addCloser(div);
addRevealer(div, ".sub");
addRevealer(div, ".unsub");
}