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.
46 lines
1.7 KiB
46 lines
1.7 KiB
7 years ago
|
// This file will be loaded on admin pages, regardless of theme.
|
||
|
|
||
8 years ago
|
import { delegate } from 'rails-ujs';
|
||
|
|
||
|
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
|
|
||
8 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);
|
||
8 years ago
|
}
|
||
|
});
|
||
|
|
||
|
delegate(document, '.media-spoiler-show-button', 'click', () => {
|
||
7 years ago
|
[].forEach.call(document.querySelectorAll('button.media-spoiler'), (element) => {
|
||
|
element.click();
|
||
8 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();
|
||
8 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
|
delegate(document, '#domain_block_severity', 'change', ({ 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';
|
||
|
}
|
||
6 years ago
|
});
|