闭社主体 forked from https://github.com/tootsuite/mastodon
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.

43 lines
1.6 KiB

  1. import { delegate } from 'rails-ujs';
  2. const batchCheckboxClassName = '.batch-checkbox input[type="checkbox"]';
  3. delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
  4. [].forEach.call(document.querySelectorAll(batchCheckboxClassName), (content) => {
  5. content.checked = target.checked;
  6. });
  7. });
  8. delegate(document, batchCheckboxClassName, 'change', () => {
  9. const checkAllElement = document.querySelector('#batch_checkbox_all');
  10. if (checkAllElement) {
  11. checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
  12. checkAllElement.indeterminate = !checkAllElement.checked && [].some.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
  13. }
  14. });
  15. delegate(document, '.media-spoiler-show-button', 'click', () => {
  16. [].forEach.call(document.querySelectorAll('button.media-spoiler'), (element) => {
  17. element.click();
  18. });
  19. });
  20. delegate(document, '.media-spoiler-hide-button', 'click', () => {
  21. [].forEach.call(document.querySelectorAll('.spoiler-button.spoiler-button--visible button'), (element) => {
  22. element.click();
  23. });
  24. });
  25. delegate(document, '#domain_block_severity', 'change', ({ target }) => {
  26. const rejectMediaDiv = document.querySelector('.input.with_label.domain_block_reject_media');
  27. const rejectReportsDiv = document.querySelector('.input.with_label.domain_block_reject_reports');
  28. if (rejectMediaDiv) {
  29. rejectMediaDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
  30. }
  31. if (rejectReportsDiv) {
  32. rejectReportsDiv.style.display = (target.value === 'suspend') ? 'none' : 'block';
  33. }
  34. });