Files
vuefilemanager/resources/js/components/FilesView/FileFullPreview.vue
Miloš Holba bb22ec1e88 key binds fix
2020-08-17 20:10:30 +02:00

93 lines
2.0 KiB
Vue

<template>
<div
class="file-full-preview-wrapper"
v-if="showFullPreview"
id="fileFullPreview"
ref="filePreview"
tabindex="-1"
@keydown.esc="(showFullPreview = false), hideMenu()"
@keydown.right="next"
@keydown.left="prev"
>
<FilePreviewNavigationPanel />
<MediaFullPreview v-if="isMedia" />
<FilePreviewActions />
</div>
</template>
<script>
import { events } from "@/bus";
import { mapGetters } from "vuex";
import MediaFullPreview from "@/components/FilesView/MediaFullPreview";
import FilePreviewActions from "@/components/FilesView/FilePreviewActions";
import FilePreviewNavigationPanel from "@/components/FilesView/FilePreviewNavigationPanel";
export default {
components: {
MediaFullPreview,
FilePreviewNavigationPanel,
FilePreviewActions,
},
data() {
return {
showFullPreview: false,
};
},
methods: {
next: function () {
events.$emit("filePreviewAction:next");
},
prev: function () {
events.$emit("filePreviewAction:prev");
},
hideMenu() {
events.$emit("showContextMenuPreview:show");
},
},
updated() {
if (this.showFullPreview) {
this.$refs.filePreview.focus();
}
},
computed: {
...mapGetters(["fileInfoDetail"]),
isMedia() {
return this.fileInfoDetail === "image" || "video" || "audio";
},
},
mounted() {
if (this.showFullPreview) {
let preview = document.getElementById("file-wrapper-preview");
preview.addEventListener("click", this.hideMenu);
}
events.$on("fileFullPreview:show", () => {
this.showFullPreview = true;
});
events.$on("fileFullPreview:hide", () => {
this.showFullPreview = false;
});
},
};
</script>
<style lang="scss" scoped>
@import "@assets/vue-file-manager/_variables";
.file-full-preview-wrapper {
width: 100%;
height: 100%;
position: absolute;
z-index: 7;
background-color: $light-background;
}
@media (prefers-color-scheme: dark) {
.file-full-preview-wrapper {
background-color: $dark_mode_background;
}
}
</style>