forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncEmailValues.js
More file actions
23 lines (19 loc) · 852 Bytes
/
syncEmailValues.js
File metadata and controls
23 lines (19 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { debounce } from './helpers';
// Synchronizes the "Email" input value with "Email login credentials to" input value
// based on the "Send welcome email" checkbox state on Add User page
export default function handleSyncEmailValues() {
const emailInput = document.querySelector('.js-sync-email-input');
const sendWelcomeEmailCheckbox = document.querySelector('.js-sync-email-checkbox');
const emailCredentialsToInput = document.querySelector('.js-sync-email-output');
if (!emailInput || !sendWelcomeEmailCheckbox || !emailCredentialsToInput) {
return;
}
function syncEmailValues() {
emailCredentialsToInput.value = sendWelcomeEmailCheckbox.checked ? emailInput.value : '';
}
emailInput.addEventListener(
'input',
debounce(() => syncEmailValues()),
);
sendWelcomeEmailCheckbox.addEventListener('change', syncEmailValues);
}