diff options
author | Starfall <root@starfall.blue> | 2020-04-11 20:04:56 -0500 |
---|---|---|
committer | Starfall <root@starfall.blue> | 2020-04-11 20:04:56 -0500 |
commit | b107e4f771f036b214563764fcd95786f8016ee7 (patch) | |
tree | 22397105f42f30eceacdf84671d1c4d807c9dd73 /app/javascript/packs | |
parent | 144ecfcfc7d9974117f1563084409a9558290a60 (diff) | |
parent | c47be5bd864a1f5244f35122ba7fae31a149c73d (diff) |
Merge branch 'glitch'
Diffstat (limited to 'app/javascript/packs')
-rw-r--r-- | app/javascript/packs/public.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index 13cb5d548..5b699e767 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -8,7 +8,7 @@ start(); function main() { const IntlMessageFormat = require('intl-messageformat').default; const { timeAgoString } = require('../mastodon/components/relative_timestamp'); - const { delegate } = require('rails-ujs'); + const { delegate } = require('@rails/ujs'); const emojify = require('../mastodon/features/emoji/emoji').default; const { getLocale } = require('../mastodon/locales'); const { messages } = getLocale(); @@ -101,6 +101,28 @@ function main() { delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original')); delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static')); + + delegate(document, '.status__content__spoiler-link', 'click', function() { + const contentEl = this.parentNode.parentNode.querySelector('.e-content'); + + if (contentEl.style.display === 'block') { + contentEl.style.display = 'none'; + this.parentNode.style.marginBottom = 0; + this.textContent = (new IntlMessageFormat(messages['status.show_more'] || 'Show more', locale)).format(); + } else { + contentEl.style.display = 'block'; + this.parentNode.style.marginBottom = null; + this.textContent = (new IntlMessageFormat(messages['status.show_less'] || 'Show less', locale)).format(); + } + + return false; + }); + + [].forEach.call(document.querySelectorAll('.status__content__spoiler-link'), (spoilerLink) => { + const contentEl = spoilerLink.parentNode.parentNode.querySelector('.e-content'); + const message = (contentEl.style.display === 'block') ? (messages['status.show_less'] || 'Show less') : (messages['status.show_more'] || 'Show more'); + spoilerLink.textContent = (new IntlMessageFormat(message, locale)).format(); + }); }); delegate(document, '.sidebar__toggle__icon', 'click', () => { |