forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscardAllMail.js
More file actions
30 lines (24 loc) · 1018 Bytes
/
discardAllMail.js
File metadata and controls
30 lines (24 loc) · 1018 Bytes
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
// "Discard all mail" checkbox behavior on Add/Edit Mail Account pages
export default function handleDiscardAllMail() {
const discardAllMailCheckbox = document.querySelector('.js-discard-all-mail');
if (!discardAllMailCheckbox) {
return;
}
discardAllMailCheckbox.addEventListener('click', () => {
const forwardToTextarea = document.querySelector('.js-forward-to-textarea');
const doNotStoreCheckbox = document.querySelector('.js-do-not-store-checkbox');
if (discardAllMailCheckbox.checked) {
// Disable "Forward to" textarea
forwardToTextarea.disabled = true;
// Check "Do not store forwarded mail" checkbox
doNotStoreCheckbox.checked = true;
// Hide "Do not store forwarded mail" checkbox container
doNotStoreCheckbox.parentElement.classList.add('u-hidden');
} else {
// Enable "Forward to" textarea
forwardToTextarea.disabled = false;
// Show "Do not store forwarded mail" checkbox container
doNotStoreCheckbox.parentElement.classList.remove('u-hidden');
}
});
}