2323<template >
2424 <modal
2525 v-if =" currentFile.modal"
26+ id =" viewer-content"
2627 :class =" {'icon-loading': loading}"
2728 :view =" currentFile.modal"
2829 :actions =" actions"
2930 :enable-slideshow =" true"
3031 :has-previous =" hasPrevious"
3132 :has-next =" hasNext"
3233 :title =" currentFileName"
34+ :disable-swipe =" disableSwipe"
35+ :size =" isMobile ? 'full' : 'large'"
36+ :style =" {width: showSidebar ? `calc(100% - ${sidebarWidth}px)` : null}"
3337 @close =" close"
3438 @previous =" previous"
3539 @next =" next" >
@@ -84,6 +88,7 @@ import Mime from 'mime-types'
8488import Vue from ' vue'
8589
8690import Modal from ' nextcloud-vue/dist/Components/Modal'
91+ import { generateRemoteUrl } from ' nextcloud-server/dist/router'
8792
8893import Error from ' Components/Error'
8994import FileList from ' Services/FileList'
@@ -111,11 +116,15 @@ export default {
111116
112117 fileList: [],
113118
114- failed: false ,
119+ isMobile: window .outerWidth < 768 ,
120+ showSidebar: false ,
121+ sidebarWidth: 0 ,
115122
123+ disableSwipe: false ,
124+ failed: false ,
116125 loading: true ,
117126
118- root: ` /remote.php/ dav/files/${ OC .getCurrentUser ().uid } `
127+ root: generateRemoteUrl ( ` / dav/files/${ OC .getCurrentUser ().uid } ` )
119128 }),
120129
121130 computed: {
@@ -160,6 +169,11 @@ export default {
160169 })
161170 })
162171
172+ window .addEventListener (' resize' , this .onResize )
173+ },
174+
175+ beforeDestroy () {
176+ window .removeEventListener (' resize' , this .onResize )
163177 },
164178
165179 methods: {
@@ -172,6 +186,10 @@ export default {
172186 async openFile (fileName , fileInfo ) {
173187 this .loading = true
174188 this .failed = false
189+
190+ // prevent scrolling while opened
191+ document .body .style .overflow = ' hidden'
192+
175193 const relativePath = ` ${ fileInfo .dir !== ' /' ? fileInfo .dir : ' ' } /${ fileName} `
176194 const path = ` ${ this .root }${ relativePath} `
177195
@@ -193,7 +211,7 @@ export default {
193211 this .fileList = await FileList (OC .getCurrentUser ().uid , fileInfo .dir , mimes)
194212
195213 // store current position
196- this .currentIndex = this .fileList .findIndex (file => decodeURI ( file .href ) === this . root + relativePath )
214+ this .currentIndex = this .fileList .findIndex (file => file .name === fileName )
197215
198216 this .updatePreviousNext ()
199217 },
@@ -362,6 +380,9 @@ export default {
362380 this .currentFile = {}
363381 this .currentModal = null
364382 this .fileList = []
383+ this .hideAppsSidebar ()
384+ // restore default
385+ document .body .style .overflow = null
365386 },
366387
367388 /**
@@ -416,16 +437,56 @@ export default {
416437 showSharingSidebar () {
417438 // Open the sidebar sharing tab
418439 OCA .Files .App .fileList .showDetailsView (this .currentFileName , ' shareTabView' )
419- this .close ()
440+ this .showAppsSidebar ()
441+ },
442+
443+ showAppsSidebar () {
444+ this .showSidebar = true
445+ const sidebar = document .getElementById (' app-sidebar' )
446+ if (sidebar) {
447+ sidebar .classList .add (' app-sidebar--full' )
448+ }
449+
450+ // overriding closing function
451+ const origHideAppsSidebar = OC .Apps .hideAppSidebar
452+ OC .Apps .hideAppSidebar = ($el ) => {
453+ this .hideAppsSidebar ()
454+ origHideAppsSidebar ($el)
455+ }
456+
457+ this .sidebarWidth = sidebar .offsetWidth
458+ },
459+
460+ hideAppsSidebar () {
461+ this .showSidebar = false
462+ const sidebar = document .getElementById (' app-sidebar' )
463+ if (sidebar) {
464+ sidebar .classList .remove (' app-sidebar--full' )
465+ }
466+ },
467+
468+ onResize (event ) {
469+ // Update mobile mode
470+ this .isMobile = window .outerWidth < 768
471+ // update sidebar width
472+ const sidebar = document .getElementById (' app-sidebar' )
473+ if (sidebar) {
474+ this .sidebarWidth = sidebar .offsetWidth
475+ }
420476 }
421477 }
422478}
423479 </script >
424480
425481<style lang="scss">
426- #modal-mask #modal-container {
427- display : flex !important ;
428- width : auto !important ;
482+ #viewer-content .modal-mask {
483+ transition : width ease 100ms ;
484+ .modal-container {
485+ display : flex !important ;
486+ width : auto !important ;
487+ border-radius : 0 !important ;
488+ background-color : black ;
489+ }
429490}
430491
431492.component-fade-enter-active , .component-fade-leave-active {
@@ -445,4 +506,14 @@ export default {
445506 transition : height 100ms ease ,
446507 width 100ms ease ;
447508}
509+
510+ #app-sidebar .app-sidebar--full {
511+ position : absolute ;
512+ top : 0 ;
513+ height : 100% ;
514+ z-index : 15000 ;
515+ .thumbnailContainer {
516+ display : none ;
517+ }
518+ }
448519 </style >
0 commit comments