Improve Activity stream spoiler (#4088)

This commit is contained in:
abcang 2017-07-07 04:31:03 +09:00 committed by Eugen Rochko
parent 6bf6d35637
commit f76e71825d
5 changed files with 28 additions and 11 deletions

View File

@ -53,8 +53,12 @@ function main() {
} }
}); });
delegate(document, '.media-spoiler', 'click', ({ target }) => { delegate(document, '.activity-stream .media-spoiler-wrapper .media-spoiler', 'click', function() {
target.style.display = 'none'; this.parentNode.classList.add('media-spoiler-wrapper__visible');
});
delegate(document, '.activity-stream .media-spoiler-wrapper .spoiler-button', 'click', function() {
this.parentNode.classList.remove('media-spoiler-wrapper__visible');
}); });
delegate(document, '.webapp-btn', 'click', ({ target, button }) => { delegate(document, '.webapp-btn', 'click', ({ target, button }) => {

View File

@ -330,6 +330,18 @@
} }
} }
.media-spoiler-wrapper {
&.media-spoiler-wrapper__visible {
.media-spoiler {
display: none;
}
.spoiler-button {
display: block;
}
}
}
.pre-header { .pre-header {
padding: 14px 0; padding: 14px 0;
padding-left: (48px + 14px * 2); padding-left: (48px + 14px * 2);

View File

@ -1,3 +1,7 @@
.media-spoiler-wrapper{ class: sensitive == false && 'media-spoiler-wrapper__visible' }
.spoiler-button
.icon-button.overlayed
%i.fa.fa-fw.fa-eye
.media-spoiler .media-spoiler
%span= t('stream_entries.sensitive_content') %span= t('stream_entries.sensitive_content')
%span= t('stream_entries.click_to_show') %span= t('stream_entries.click_to_show')

View File

@ -17,13 +17,11 @@
- unless status.media_attachments.empty? - unless status.media_attachments.empty?
- if status.media_attachments.first.video? - if status.media_attachments.first.video?
.video-player .video-player
- if status.sensitive? = render partial: 'stream_entries/content_spoiler', locals: { sensitive: status.sensitive? }
= render partial: 'stream_entries/content_spoiler'
%video.u-video{ src: status.media_attachments.first.file.url(:original), loop: true } %video.u-video{ src: status.media_attachments.first.file.url(:original), loop: true }
- else - else
.detailed-status__attachments .detailed-status__attachments
- if status.sensitive? = render partial: 'stream_entries/content_spoiler', locals: { sensitive: status.sensitive? }
= render partial: 'stream_entries/content_spoiler'
.status__attachments__inner .status__attachments__inner
- status.media_attachments.each do |media| - status.media_attachments.each do |media|
= render partial: 'stream_entries/media', locals: { media: media } = render partial: 'stream_entries/media', locals: { media: media }

View File

@ -22,8 +22,7 @@
- unless status.media_attachments.empty? - unless status.media_attachments.empty?
.status__attachments .status__attachments
- if status.sensitive? = render partial: 'stream_entries/content_spoiler', locals: { sensitive: status.sensitive? }
= render partial: 'stream_entries/content_spoiler'
- if status.media_attachments.first.video? - if status.media_attachments.first.video?
.status__attachments__inner .status__attachments__inner
.video-item .video-item