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.

45 lines
1.7 KiB

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