You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
3.0 KiB
76 lines
3.0 KiB
7 years ago
|
// This file will be loaded on admin pages, regardless of theme.
|
||
|
|
||
5 years ago
|
import { delegate } from '@rails/ujs';
|
||
5 years ago
|
import ready from '../mastodon/ready';
|
||
7 years ago
|
|
||
|
const batchCheckboxClassName = '.batch-checkbox input[type="checkbox"]';
|
||
|
|
||
|
delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
|
||
|
[].forEach.call(document.querySelectorAll(batchCheckboxClassName), (content) => {
|
||
|
content.checked = target.checked;
|
||
|
});
|
||
|
});
|
||
|
|
||
|
delegate(document, batchCheckboxClassName, 'change', () => {
|
||
|
const checkAllElement = document.querySelector('#batch_checkbox_all');
|
||
6 years ago
|
|
||
7 years ago
|
if (checkAllElement) {
|
||
|
checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
|
||
7 years ago
|
checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
|
||
7 years ago
|
}
|
||
|
});
|
||
|
|
||
|
delegate(document, '.media-spoiler-show-button', 'click', () => {
|
||
7 years ago
|
[].forEach.call(document.querySelectorAll('button.media-spoiler'), (element) => {
|
||
|
element.click();
|
||
7 years ago
|
});
|
||
|
});
|
||
|
|
||
|
delegate(document, '.media-spoiler-hide-button', 'click', () => {
|
||
7 years ago
|
[].forEach.call(document.querySelectorAll('.spoiler-button.spoiler-button--visible button'), (element) => {
|
||
|
element.click();
|
||
7 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
delegate(document, '.filter-subset--with-select select', 'change', ({ target }) => {
|
||
|
target.form.submit();
|
||
|
});
|
||
|
|
||
5 years ago
|
const onDomainBlockSeverityChange = (target) => {
|
||
6 years ago
|
const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media');
|
||
|
const rejectReportsDiv = document.querySelector('.input.with_label.domain_block_reject_reports');
|
||
|
|
||
6 years ago
|
if (rejectMediaDiv) {
|
||
|
rejectMediaDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
||
|
}
|
||
6 years ago
|
|
||
|
if (rejectReportsDiv) {
|
||
|
rejectReportsDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
||
|
}
|
||
5 years ago
|
};
|
||
|
|
||
|
delegate(document, '#domain_block_severity', 'change', ({ target }) => onDomainBlockSeverityChange(target));
|
||
|
|
||
5 years ago
|
const onEnableBootstrapTimelineAccountsChange = (target) => {
|
||
|
const bootstrapTimelineAccountsField = document.querySelector('#form_admin_settings_bootstrap_timeline_accounts');
|
||
|
|
||
|
if (bootstrapTimelineAccountsField) {
|
||
|
bootstrapTimelineAccountsField.disabled = !target.checked;
|
||
|
if (target.checked) {
|
||
|
bootstrapTimelineAccountsField.parentElement.classList.remove('disabled');
|
||
|
} else {
|
||
|
bootstrapTimelineAccountsField.parentElement.classList.add('disabled');
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
delegate(document, '#form_admin_settings_enable_bootstrap_timeline_accounts', 'change', ({ target }) => onEnableBootstrapTimelineAccountsChange(target));
|
||
|
|
||
5 years ago
|
ready(() => {
|
||
5 years ago
|
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);
|
||
6 years ago
|
});
|