diff options
author | Starfall <us@starfall.systems> | 2020-12-24 13:36:25 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2020-12-24 13:36:25 -0600 |
commit | 6ed4e874c5ace36344f77b3f096c4089d9b11e01 (patch) | |
tree | 83b2675d297f56a75b5e5dec33c644bc19f6cf1b /app/javascript/core/admin.js | |
parent | ab127fd7941b7c84e6d6fe3071d41f52affb143c (diff) | |
parent | 225c934a1b66e2fcbedbda7936666c1ca3c9a04b (diff) |
Merge branch 'glitch' into main
Diffstat (limited to 'app/javascript/core/admin.js')
-rw-r--r-- | app/javascript/core/admin.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/javascript/core/admin.js b/app/javascript/core/admin.js index bbc7cfac7..d2db89ca7 100644 --- a/app/javascript/core/admin.js +++ b/app/javascript/core/admin.js @@ -59,18 +59,46 @@ const onEnableBootstrapTimelineAccountsChange = (target) => { bootstrapTimelineAccountsField.disabled = !target.checked; if (target.checked) { bootstrapTimelineAccountsField.parentElement.classList.remove('disabled'); + bootstrapTimelineAccountsField.parentElement.parentElement.classList.remove('disabled'); } else { bootstrapTimelineAccountsField.parentElement.classList.add('disabled'); + bootstrapTimelineAccountsField.parentElement.parentElement.classList.add('disabled'); } } }; delegate(document, '#form_admin_settings_enable_bootstrap_timeline_accounts', 'change', ({ target }) => onEnableBootstrapTimelineAccountsChange(target)); +const onChangeRegistrationMode = (target) => { + const enabled = target.value === 'approved'; + + [].forEach.call(document.querySelectorAll('#form_admin_settings_require_invite_text'), (input) => { + input.disabled = !enabled; + if (enabled) { + let element = input; + do { + element.classList.remove('disabled'); + element = element.parentElement; + } while (element && !element.classList.contains('fields-group')); + } else { + let element = input; + do { + element.classList.add('disabled'); + element = element.parentElement; + } while (element && !element.classList.contains('fields-group')); + } + }); +}; + +delegate(document, '#form_admin_settings_registrations_mode', 'change', ({ target }) => onChangeRegistrationMode(target)); + ready(() => { const domainBlockSeverityInput = document.getElementById('domain_block_severity'); if (domainBlockSeverityInput) onDomainBlockSeverityChange(domainBlockSeverityInput); const enableBootstrapTimelineAccounts = document.getElementById('form_admin_settings_enable_bootstrap_timeline_accounts'); if (enableBootstrapTimelineAccounts) onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts); + + const registrationMode = document.getElementById('form_admin_settings_registrations_mode'); + if (registrationMode) onChangeRegistrationMode(registrationMode); }); |