Add media viewer module and media module component, modify attachment behavior

This commit is contained in:
shpuld 2019-01-14 19:23:13 +02:00
parent a51167fa72
commit 17735943d5
10 changed files with 197 additions and 26 deletions

View file

@ -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