mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-14 02:42:54 +00:00
36393e1d2b
Conflicts: app/views/layouts/application.html.haml Edited: app/helpers/application_helper.rb app/views/admin/domain_blocks/new.html.haml Conflict wasn't really one, just two changes too close to one another. Edition was to adapt the class names for themes to class names for skins and flavours. Also edited app/views/admin/domain_blocks/new.html.haml to strip the duplicate admin pack inclusion thing.
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
// This file will be loaded on admin pages, regardless of theme.
|
|
|
|
import { delegate } from 'rails-ujs';
|
|
|
|
function handleDeleteStatus(event) {
|
|
const [data] = event.detail;
|
|
const element = document.querySelector(`[data-id="${data.id}"]`);
|
|
if (element) {
|
|
element.parentNode.removeChild(element);
|
|
}
|
|
}
|
|
|
|
[].forEach.call(document.querySelectorAll('.trash-button'), (content) => {
|
|
content.addEventListener('ajax:success', handleDeleteStatus);
|
|
});
|
|
|
|
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');
|
|
if (checkAllElement) {
|
|
checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
|
|
checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
|
|
}
|
|
});
|
|
|
|
delegate(document, '.media-spoiler-show-button', 'click', () => {
|
|
[].forEach.call(document.querySelectorAll('button.media-spoiler'), (element) => {
|
|
element.click();
|
|
});
|
|
});
|
|
|
|
delegate(document, '.media-spoiler-hide-button', 'click', () => {
|
|
[].forEach.call(document.querySelectorAll('.spoiler-button.spoiler-button--visible button'), (element) => {
|
|
element.click();
|
|
});
|
|
});
|
|
|
|
delegate(document, '#domain_block_severity', 'change', ({ target }) => {
|
|
const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media');
|
|
if (rejectMediaDiv) {
|
|
rejectMediaDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
|
|
}
|
|
});
|