diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-03-31 13:54:36 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-03-31 13:54:36 +0200 |
commit | 5e26295e061b653d0134caf0b54447a3683aecba (patch) | |
tree | 648b64b15af846d1b32316bee4d638213817e814 | |
parent | 188cddefe90c550227ea8bbd842a7c6ed3615eab (diff) |
Fix #700 - hide spoilers on static pages
-rw-r--r-- | app/assets/javascripts/extras.jsx | 13 | ||||
-rw-r--r-- | app/assets/stylesheets/stream_entries.scss | 18 | ||||
-rw-r--r-- | app/views/stream_entries/_detailed_status.html.haml | 6 | ||||
-rw-r--r-- | app/views/stream_entries/_simple_status.html.haml | 6 | ||||
-rw-r--r-- | config/locales/en.yml | 1 |
5 files changed, 40 insertions, 4 deletions
diff --git a/app/assets/javascripts/extras.jsx b/app/assets/javascripts/extras.jsx index 5738863dd..c13feceff 100644 --- a/app/assets/javascripts/extras.jsx +++ b/app/assets/javascripts/extras.jsx @@ -24,4 +24,17 @@ $(() => { 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); + } + }); }); diff --git a/app/assets/stylesheets/stream_entries.scss b/app/assets/stylesheets/stream_entries.scss index b9a9a1da3..4a6dc6aa4 100644 --- a/app/assets/stylesheets/stream_entries.scss +++ b/app/assets/stylesheets/stream_entries.scss @@ -97,6 +97,15 @@ a { color: $color4; } + + a.status__content__spoiler-link { + color: $color5; + background: $color3; + + &:hover { + background: lighten($color3, 8%); + } + } } .status__attachments { @@ -163,6 +172,15 @@ a { color: $color4; } + + a.status__content__spoiler-link { + color: $color5; + background: $color3; + + &:hover { + background: lighten($color3, 8%); + } + } } .detailed-status__meta { diff --git a/app/views/stream_entries/_detailed_status.html.haml b/app/views/stream_entries/_detailed_status.html.haml index 8c0456b1f..11940883e 100644 --- a/app/views/stream_entries/_detailed_status.html.haml +++ b/app/views/stream_entries/_detailed_status.html.haml @@ -9,8 +9,10 @@ .status__content.e-content.p-name.emojify< - unless status.spoiler_text.blank? - %p= status.spoiler_text - %div{ style: "direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status) + %p{ style: 'margin-bottom: 0' }< + %span>= "#{status.spoiler_text} " + %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more') + %div{ style: "display: #{status.spoiler_text.blank? ? 'block' : 'none'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status) - unless status.media_attachments.empty? - if status.media_attachments.first.video? diff --git a/app/views/stream_entries/_simple_status.html.haml b/app/views/stream_entries/_simple_status.html.haml index cb2c976ce..2eb9bf166 100644 --- a/app/views/stream_entries/_simple_status.html.haml +++ b/app/views/stream_entries/_simple_status.html.haml @@ -14,8 +14,10 @@ .status__content.e-content.p-name.emojify< - unless status.spoiler_text.blank? - %p= status.spoiler_text - %div{ style: "direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status) + %p{ style: 'margin-bottom: 0' }< + %span>= "#{status.spoiler_text} " + %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more') + %div{ style: "display: #{status.spoiler_text.blank? ? 'block' : 'none'}; direction: #{rtl?(status.content) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status) - unless status.media_attachments.empty? .status__attachments diff --git a/config/locales/en.yml b/config/locales/en.yml index 965001e05..157f107a5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -138,6 +138,7 @@ en: statuses: open_in_web: Open in web over_character_limit: character limit of %{max} exceeded + show_more: Show more visibilities: private: Only show to followers public: Public |