viewer: update title
parent
cef50e1bb0
commit
33e863057e
|
@ -124,6 +124,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
@Emit("updateLoading") updateLoading(delta: number) {}
|
@Emit("updateLoading") updateLoading(delta: number) {}
|
||||||
|
|
||||||
public isOpen = false;
|
public isOpen = false;
|
||||||
|
private originalTitle = null;
|
||||||
|
|
||||||
private show = false;
|
private show = false;
|
||||||
private showControls = false;
|
private showControls = false;
|
||||||
|
@ -161,6 +162,22 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Update the document title */
|
||||||
|
private updateTitle(photo: IPhoto | undefined) {
|
||||||
|
const oc_defaults: any = globalThis.oc_defaults;
|
||||||
|
if (!this.originalTitle) {
|
||||||
|
this.originalTitle = document.title;
|
||||||
|
}
|
||||||
|
if (photo) {
|
||||||
|
document.title = `${photo.basename} - ${
|
||||||
|
globalThis.OCA.Theming?.name ?? oc_defaults.name
|
||||||
|
}`;
|
||||||
|
} else {
|
||||||
|
document.title = this.originalTitle;
|
||||||
|
this.originalTitle = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Get the currently open photo */
|
/** Get the currently open photo */
|
||||||
private getCurrentPhoto() {
|
private getCurrentPhoto() {
|
||||||
if (!this.list.length || !this.photoswipe) {
|
if (!this.list.length || !this.photoswipe) {
|
||||||
|
@ -258,6 +275,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
this.showControls = false;
|
this.showControls = false;
|
||||||
this.hideSidebar();
|
this.hideSidebar();
|
||||||
this.setRouteHash(undefined);
|
this.setRouteHash(undefined);
|
||||||
|
this.updateTitle(undefined);
|
||||||
});
|
});
|
||||||
this.photoswipe.on("destroy", () => {
|
this.photoswipe.on("destroy", () => {
|
||||||
document.body.classList.remove(klass);
|
document.body.classList.remove(klass);
|
||||||
|
@ -284,6 +302,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
// Update vue route for deep linking
|
// Update vue route for deep linking
|
||||||
this.photoswipe.on("slideActivate", (e) => {
|
this.photoswipe.on("slideActivate", (e) => {
|
||||||
this.setRouteHash(e.slide?.data?.photo);
|
this.setRouteHash(e.slide?.data?.photo);
|
||||||
|
this.updateTitle(e.slide?.data?.photo);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Video support
|
// Video support
|
||||||
|
|
Loading…
Reference in New Issue