The code powering m.abunchtell.com https://m.abunchtell.com
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.5 KiB

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