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.1 KiB

  1. // This file will be loaded on public pages, regardless of theme.
  2. import createHistory from 'history/createBrowserHistory';
  3. import ready from '../mastodon/ready';
  4. const { delegate } = require('rails-ujs');
  5. const { length } = require('stringz');
  6. delegate(document, '.webapp-btn', 'click', ({ target, button }) => {
  7. if (button !== 0) {
  8. return true;
  9. }
  10. window.location.href = target.href;
  11. return false;
  12. });
  13. delegate(document, '.status__content__spoiler-link', 'click', ({ target }) => {
  14. const contentEl = target.parentNode.parentNode.querySelector('.e-content');
  15. if (contentEl.style.display === 'block') {
  16. contentEl.style.display = 'none';
  17. target.parentNode.style.marginBottom = 0;
  18. } else {
  19. contentEl.style.display = 'block';
  20. target.parentNode.style.marginBottom = null;
  21. }
  22. return false;
  23. });
  24. delegate(document, '.modal-button', 'click', e => {
  25. e.preventDefault();
  26. let href;
  27. if (e.target.nodeName !== 'A') {
  28. href = e.target.parentNode.href;
  29. } else {
  30. href = e.target.href;
  31. }
  32. window.open(href, 'mastodon-intent', 'width=445,height=600,resizable=no,menubar=no,status=no,scrollbars=yes');
  33. });