diff --git a/frontend/app/app.component.ts b/frontend/app/app.component.ts index cf95014e..f2a144e0 100644 --- a/frontend/app/app.component.ts +++ b/frontend/app/app.component.ts @@ -13,6 +13,7 @@ import {AdminComponent} from "./admin/admin.component"; import {NetworkService} from "./model/network/network.service"; import {ThumbnailLoaderService} from "./gallery/grid/thumnailLoader.service"; import {GalleryCacheService} from "./gallery/cache.gallery.service"; +import {FullScreenService} from "./gallery/fullscreen.service"; @Component({ @@ -27,7 +28,8 @@ import {GalleryCacheService} from "./gallery/cache.gallery.service"; GalleryCacheService, GalleryService, AuthenticationService, - ThumbnailLoaderService] + ThumbnailLoaderService, + FullScreenService] }) @RouteConfig([ { diff --git a/frontend/app/gallery/fullscreen.service.ts b/frontend/app/gallery/fullscreen.service.ts new file mode 100644 index 00000000..d84e4956 --- /dev/null +++ b/frontend/app/gallery/fullscreen.service.ts @@ -0,0 +1,43 @@ +/// + +import {Injectable} from "@angular/core"; + +@Injectable() +export class FullScreenService { + + + public isFullScreenEnabled():boolean { + return !!(document.fullscreenElement || document['mozFullScreenElement'] || document.webkitFullscreenElement); + } + + public showFullScreen(element:any) { + if (this.isFullScreenEnabled()) { + return; + } + + if (element.requestFullscreen) { + element.requestFullscreen(); + } else if (element.mozRequestFullScreen) { + element.mozRequestFullScreen(); + } else if (element.webkitRequestFullscreen) { + element.webkitRequestFullscreen(); + } else if (element.msRequestFullscreen) { + element.msRequestFullscreen(); + } + } + + public exitFullScreen() { + if (!this.isFullScreenEnabled()) { + return; + } + + if (document.exitFullscreen) { + document.exitFullscreen(); + } else if (document['mozCancelFullScreen']) { + document['mozCancelFullScreen'](); + } else if (document.webkitExitFullscreen) { + document.webkitExitFullscreen(); + } + } + +} diff --git a/frontend/app/gallery/lightbox/lightbox.gallery.component.css b/frontend/app/gallery/lightbox/lightbox.gallery.component.css index 5effa5de..d62e126f 100644 --- a/frontend/app/gallery/lightbox/lightbox.gallery.component.css +++ b/frontend/app/gallery/lightbox/lightbox.gallery.component.css @@ -43,6 +43,7 @@ width: 100%; height: 100%; left: 0; + top: 0; position: fixed;; color: white; } diff --git a/frontend/app/gallery/lightbox/lightbox.gallery.component.html b/frontend/app/gallery/lightbox/lightbox.gallery.component.html index dc89a190..e732f11e 100644 --- a/frontend/app/gallery/lightbox/lightbox.gallery.component.html +++ b/frontend/app/gallery/lightbox/lightbox.gallery.component.html @@ -1,4 +1,4 @@ -
+
@@ -19,7 +19,15 @@ [download]="activePhoto.gridPhoto.photo.name"> - + + + + +
diff --git a/frontend/app/gallery/lightbox/lightbox.gallery.component.ts b/frontend/app/gallery/lightbox/lightbox.gallery.component.ts index 3ccf1e3d..9e54bdb6 100644 --- a/frontend/app/gallery/lightbox/lightbox.gallery.component.ts +++ b/frontend/app/gallery/lightbox/lightbox.gallery.component.ts @@ -1,11 +1,12 @@ /// -import {Component, QueryList, Output, EventEmitter, HostListener} from "@angular/core"; +import {Component, QueryList, Output, EventEmitter, HostListener, ElementRef, ViewChild} from "@angular/core"; import {Photo} from "../../../../common/entities/Photo"; import {GalleryPhotoComponent} from "../grid/photo/photo.grid.gallery.component.ts"; import {BrowserDomAdapter} from "@angular/platform-browser/src/browser/browser_adapter"; import {Dimension} from "../../model/IRenderable"; import {GalleryLightboxPhotoComponent} from "./photo/photo.lightbox.gallery.component"; +import {FullScreenService} from "../fullscreen.service"; @Component({ selector: 'gallery-lightbox', @@ -25,8 +26,10 @@ export class GalleryLightboxComponent { private dom:BrowserDomAdapter; private visible = false; + @ViewChild("root") elementRef:ElementRef; - constructor() { + + constructor(private fullScreenService:FullScreenService) { this.dom = new BrowserDomAdapter(); @@ -92,7 +95,7 @@ export class GalleryLightboxComponent { } public hide() { - + this.fullScreenService.exitFullScreen(); this.visible = false; let to = this.activePhoto.getDimension(); @@ -107,6 +110,7 @@ export class GalleryLightboxComponent { } + private findPhotoComponent(photo) { let galleryPhotoComponents = this.gridPhotoQL.toArray(); for (let i = 0; i < galleryPhotoComponents.length; i++) {