1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
<!-- ldgallery - A static generator which turns a collection of tagged
-- pictures into a searchable web gallery.
--
-- Copyright (C) 2019-2020 Guillaume FOUET
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as
-- published by the Free Software Foundation, either version 3 of the
-- License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<template>
<div :class="{'fullscreen': $uiStore.fullscreen, 'fullwidth': $uiStore.fullWidth}">
<ld-title
:gallery-title="$galleryStore.galleryTitle"
:current-item="$galleryStore.currentItem"
/>
<panel-top v-if="!isLoading" class="layout layout-top" />
<panel-left v-if="!isLoading" class="layout layout-left" />
<router-view v-if="!isLoading" ref="content" class="layout layout-content scrollbar" />
<b-loading :active="isLoading" is-full-page />
<ld-key-press :keycode="27" @action="$uiStore.toggleFullscreen(false)" />
</div>
</template>
<script lang="ts">
import { Component, Vue, Ref, Watch } from "vue-property-decorator";
import PanelLeft from "./PanelLeft.vue";
import PanelTop from "./PanelTop.vue";
import { Route } from "vue-router";
@Component({
components: { PanelLeft, PanelTop },
})
export default class MainLayout extends Vue {
@Ref() readonly content!: Vue;
isLoading: boolean = true;
scrollPositions: ScrollPosition = {};
mounted() {
history.replaceState({ ldgallery: "ENTRYPOINT" }, "");
this.fetchGalleryItems();
document.body.addEventListener("fullscreenchange", this.onFullscreenChange);
}
destroyed() {
document.body.removeEventListener("fullscreenchange", this.onFullscreenChange);
}
@Watch("$route")
routeChanged(newRoute: Route, oldRoute: Route) {
const el = this.content.$el;
this.scrollPositions[oldRoute.path] = el.scrollTop;
this.$nextTick(() => (el.scrollTop = this.scrollPositions[newRoute.path]));
}
fetchGalleryItems() {
this.isLoading = true;
this.$galleryStore
.fetchConfig()
.then(this.$galleryStore.fetchGalleryItems)
.finally(() => (this.isLoading = false))
.catch(this.displayError);
}
displayError(reason: any) {
this.$buefy.snackbar.open({
message: `Error ${reason}`,
actionText: "Retry",
position: "is-top",
type: "is-danger",
indefinite: true,
onAction: this.fetchGalleryItems,
});
}
@Watch("$uiStore.fullscreen")
applyFullscreen(fullscreen: boolean) {
if (fullscreen && !document.fullscreen) document.body.requestFullscreen();
else if (document.fullscreen) document.exitFullscreen();
}
onFullscreenChange() {
this.$uiStore.toggleFullscreen(document.fullscreen);
}
}
</script>
<style lang="scss">
@import "~@/assets/scss/theme.scss";
body,
html {
height: 100%;
overflow: hidden;
touch-action: none;
background-color: $content-bgcolor;
--layout-top: #{$layout-top};
--layout-left: #{$layout-left};
}
.layout {
position: fixed;
transition: all 0.1s linear;
top: 0;
bottom: 0;
left: 0;
right: 0;
&.layout-top {
height: $layout-top;
z-index: 1;
}
&.layout-left {
top: $layout-top;
width: $layout-left;
z-index: 2;
}
&.layout-content {
top: var(--layout-top);
left: var(--layout-left);
z-index: 3;
overflow-x: hidden;
}
}
.fullscreen {
--layout-top: 0px;
@extend .fullwidth;
}
.fullwidth {
--layout-left: 0px;
.layout {
&.layout-left {
transform: translate(-$layout-left, 0);
}
}
}
.layout {
&.layout-top {
background-color: $panel-top-bgcolor;
color: $panel-top-txtcolor;
}
&.layout-left {
background-color: $panel-left-bgcolor;
color: $panel-left-txtcolor;
}
&.layout-content {
background-color: $content-bgcolor;
}
}
// TODO: Remove when #21 (remove explicit navigation/search modes) is resolved
// Forced at the bottom right corner so we can continue working on the sidebar without interference
.tmp-mode-selector {
position: absolute;
bottom: 0;
right: 0;
z-index: 100;
opacity: 0.75;
}
// =====
</style>
|