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.

53 lines
1.3 KiB

  1. import emojify from 'mastodon/emoji';
  2. import { length } from 'stringz';
  3. window.jQuery = window.$ = require('jquery');
  4. require('jquery-ujs');
  5. require.context('../images/', true);
  6. $(() => {
  7. $.each($('.emojify'), (_, content) => {
  8. const $content = $(content);
  9. $content.html(emojify($content.html()));
  10. });
  11. $('.video-player video').on('click', e => {
  12. if (e.target.paused) {
  13. e.target.play();
  14. } else {
  15. e.target.pause();
  16. }
  17. });
  18. $('.media-spoiler').on('click', e => {
  19. $(e.target).hide();
  20. });
  21. $('.webapp-btn').on('click', e => {
  22. if (e.button === 0) {
  23. e.preventDefault();
  24. window.location.href = $(e.target).attr('href');
  25. }
  26. });
  27. $('.status__content__spoiler-link').on('click', e => {
  28. e.preventDefault();
  29. const contentEl = $(e.target).parent().parent().find('div');
  30. if (contentEl.is(':visible')) {
  31. contentEl.hide();
  32. $(e.target).parent().attr('style', 'margin-bottom: 0');
  33. } else {
  34. contentEl.show();
  35. $(e.target).parent().attr('style', null);
  36. }
  37. });
  38. $('.account_display_name').on('input', e => {
  39. $('.name-counter').text(30 - length($(e.target).val()));
  40. });
  41. $('.account_note').on('input', e => {
  42. $('.note-counter').text(160 - length($(e.target).val()));
  43. });
  44. });