about summary refs log tree commit diff
path: root/app/javascript/packs/public.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/packs/public.js')
-rw-r--r--app/javascript/packs/public.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js
new file mode 100644
index 000000000..24e7d0189
--- /dev/null
+++ b/app/javascript/packs/public.js
@@ -0,0 +1,53 @@
+import emojify from 'mastodon/emoji';
+import { length } from 'stringz';
+
+window.jQuery = window.$ = require('jquery');
+require('jquery-ujs');
+require.context('../images/', true);
+
+$(() => {
+  $.each($('.emojify'), (_, content) => {
+    const $content = $(content);
+    $content.html(emojify($content.html()));
+  });
+
+  $('.video-player video').on('click', e => {
+    if (e.target.paused) {
+      e.target.play();
+    } else {
+      e.target.pause();
+    }
+  });
+
+  $('.media-spoiler').on('click', e => {
+    $(e.target).hide();
+  });
+
+  $('.webapp-btn').on('click', e => {
+    if (e.button === 0) {
+      e.preventDefault();
+      window.location.href = $(e.target).attr('href');
+    }
+  });
+
+  $('.status__content__spoiler-link').on('click', e => {
+    e.preventDefault();
+    const contentEl = $(e.target).parent().parent().find('div');
+
+    if (contentEl.is(':visible')) {
+      contentEl.hide();
+      $(e.target).parent().attr('style', 'margin-bottom: 0');
+    } else {
+      contentEl.show();
+      $(e.target).parent().attr('style', null);
+    }
+  });
+
+  $('.account_display_name').on('input', e => {
+    $('.name-counter').text(30 - length($(e.target).val()));
+  });
+
+  $('.account_note').on('input', e => {
+    $('.note-counter').text(160 - length($(e.target).val()));
+  });
+});