logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

admin.js (1348B)


  1. import { delegate } from 'rails-ujs';
  2. function handleDeleteStatus(event) {
  3. const [data] = event.detail;
  4. const element = document.querySelector(`[data-id="${data.id}"]`);
  5. if (element) {
  6. element.parentNode.removeChild(element);
  7. }
  8. }
  9. [].forEach.call(document.querySelectorAll('.trash-button'), (content) => {
  10. content.addEventListener('ajax:success', handleDeleteStatus);
  11. });
  12. const batchCheckboxClassName = '.batch-checkbox input[type="checkbox"]';
  13. delegate(document, '#batch_checkbox_all', 'change', ({ target }) => {
  14. [].forEach.call(document.querySelectorAll(batchCheckboxClassName), (content) => {
  15. content.checked = target.checked;
  16. });
  17. });
  18. delegate(document, batchCheckboxClassName, 'change', () => {
  19. const checkAllElement = document.querySelector('#batch_checkbox_all');
  20. if (checkAllElement) {
  21. checkAllElement.checked = [].every.call(document.querySelectorAll(batchCheckboxClassName), (content) => content.checked);
  22. }
  23. });
  24. delegate(document, '.media-spoiler-show-button', 'click', () => {
  25. [].forEach.call(document.querySelectorAll('button.media-spoiler'), (element) => {
  26. element.click();
  27. });
  28. });
  29. delegate(document, '.media-spoiler-hide-button', 'click', () => {
  30. [].forEach.call(document.querySelectorAll('.spoiler-button.spoiler-button--visible button'), (element) => {
  31. element.click();
  32. });
  33. });