From 17735943d5cdde1eb852d36f1c3bb699d23f7eb6 Mon Sep 17 00:00:00 2001 From: shpuld Date: Mon, 14 Jan 2019 19:23:13 +0200 Subject: [PATCH] Add media viewer module and media module component, modify attachment behavior --- src/App.js | 2 + src/App.vue | 1 + src/components/attachment/attachment.js | 19 ++++++-- src/components/attachment/attachment.vue | 47 ++++++++++++-------- src/components/media_modal/media_modal.js | 51 ++++++++++++++++++++++ src/components/media_modal/media_modal.vue | 40 +++++++++++++++++ src/components/status/status.js | 10 ++++- src/components/status/status.vue | 9 +++- src/main.js | 4 +- src/modules/media_viewer.js | 40 +++++++++++++++++ 10 files changed, 197 insertions(+), 26 deletions(-) create mode 100644 src/components/media_modal/media_modal.js create mode 100644 src/components/media_modal/media_modal.vue create mode 100644 src/modules/media_viewer.js diff --git a/src/App.js b/src/App.js index 85df941691..83a61d3926 100644 --- a/src/App.js +++ b/src/App.js @@ -6,6 +6,7 @@ import InstanceSpecificPanel from './components/instance_specific_panel/instance import FeaturesPanel from './components/features_panel/features_panel.vue' import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_panel.vue' import ChatPanel from './components/chat_panel/chat_panel.vue' +import MediaModal from './components/media_modal/media_modal.vue' import SideDrawer from './components/side_drawer/side_drawer.vue' import { unseenNotificationsFromStore } from './services/notification_utils/notification_utils' @@ -20,6 +21,7 @@ export default { FeaturesPanel, WhoToFollowPanel, ChatPanel, + MediaModal, SideDrawer }, data: () => ({ diff --git a/src/App.vue b/src/App.vue index feadb009bc..833608ea59 100644 --- a/src/App.vue +++ b/src/App.vue @@ -41,6 +41,7 @@ + diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 97c4f283f4..5e672ef284 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -7,7 +7,8 @@ const Attachment = { 'attachment', 'nsfw', 'statusId', - 'size' + 'size', + 'setMedia' ], data () { return { @@ -17,13 +18,17 @@ const Attachment = { loopVideo: this.$store.state.config.loopVideo, showHidden: false, loading: false, - img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img') + img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img'), + modalOpen: false } }, components: { StillImage }, computed: { + usePlaceHolder () { + return this.size === 'hide' || this.type === 'unknown' + }, type () { return fileTypeService.fileType(this.attachment.mimetype) }, @@ -37,7 +42,7 @@ const Attachment = { return this.size === 'small' }, fullwidth () { - return fileTypeService.fileType(this.attachment.mimetype) === 'html' + return this.type === 'html' || this.type === 'audio' } }, methods: { @@ -62,6 +67,14 @@ const Attachment = { this.showHidden = !this.showHidden } }, + toggleModal (event) { + if (this.type !== 'image' && this.type !== 'video') { + return + } + event.preventDefault() + this.setMedia() + this.$store.dispatch('setCurrent', this.attachment) + }, onVideoDataLoad (e) { if (typeof e.srcElement.webkitAudioDecodedByteCount !== 'undefined') { // non-zero if video has audio track diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 5eaa0d1dfe..1c6b84df3a 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -1,19 +1,29 @@