2019-01-14 09:23:13 -08:00
|
|
|
import StillImage from '../still-image/still-image.vue'
|
2019-01-26 07:45:03 -08:00
|
|
|
import VideoAttachment from '../video_attachment/video_attachment.vue'
|
2019-01-14 09:23:13 -08:00
|
|
|
import fileTypeService from '../../services/file_type/file_type.service.js'
|
|
|
|
|
|
|
|
const MediaModal = {
|
|
|
|
components: {
|
2019-01-26 07:45:03 -08:00
|
|
|
StillImage,
|
|
|
|
VideoAttachment
|
2019-01-14 09:23:13 -08:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
showing () {
|
|
|
|
return this.$store.state.mediaViewer.activated
|
|
|
|
},
|
|
|
|
currentIndex () {
|
|
|
|
return this.$store.state.mediaViewer.currentIndex
|
|
|
|
},
|
|
|
|
currentMedia () {
|
|
|
|
return this.$store.state.mediaViewer.media[this.currentIndex]
|
|
|
|
},
|
|
|
|
type () {
|
|
|
|
return this.currentMedia ? fileTypeService.fileType(this.currentMedia.mimetype) : null
|
|
|
|
}
|
|
|
|
},
|
2019-01-16 07:27:23 -08:00
|
|
|
created () {
|
|
|
|
document.addEventListener('keyup', e => {
|
|
|
|
if (e.keyCode === 27 && this.showing) { // escape
|
|
|
|
this.hide()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2019-01-14 09:23:13 -08:00
|
|
|
methods: {
|
|
|
|
hide () {
|
|
|
|
this.$store.dispatch('closeMediaViewer')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MediaModal
|