1 | "use strict";
|
2 | var __assign = (this && this.__assign) || function () {
|
3 | __assign = Object.assign || function(t) {
|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5 | s = arguments[i];
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7 | t[p] = s[p];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | return __assign.apply(this, arguments);
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | var lg_fullscreen_settings_1 = require("./lg-fullscreen-settings");
|
15 | var FullScreen = (function () {
|
16 | function FullScreen(instance, $LG) {
|
17 |
|
18 | this.core = instance;
|
19 | this.$LG = $LG;
|
20 |
|
21 | this.settings = __assign(__assign({}, lg_fullscreen_settings_1.fullscreenSettings), this.core.settings);
|
22 | return this;
|
23 | }
|
24 | FullScreen.prototype.init = function () {
|
25 | var fullScreen = '';
|
26 | if (this.settings.fullScreen) {
|
27 |
|
28 | if (!document.fullscreenEnabled &&
|
29 | !document.webkitFullscreenEnabled &&
|
30 | !document.mozFullScreenEnabled &&
|
31 | !document.msFullscreenEnabled) {
|
32 | return;
|
33 | }
|
34 | else {
|
35 | fullScreen = "<button type=\"button\" aria-label=\"" + this.settings.fullscreenPluginStrings['toggleFullscreen'] + "\" class=\"lg-fullscreen lg-icon\"></button>";
|
36 | this.core.$toolbar.append(fullScreen);
|
37 | this.fullScreen();
|
38 | }
|
39 | }
|
40 | };
|
41 | FullScreen.prototype.isFullScreen = function () {
|
42 | return (document.fullscreenElement ||
|
43 | document.mozFullScreenElement ||
|
44 | document.webkitFullscreenElement ||
|
45 | document.msFullscreenElement);
|
46 | };
|
47 | FullScreen.prototype.requestFullscreen = function () {
|
48 | var el = document.documentElement;
|
49 | if (el.requestFullscreen) {
|
50 | el.requestFullscreen();
|
51 | }
|
52 | else if (el.msRequestFullscreen) {
|
53 | el.msRequestFullscreen();
|
54 | }
|
55 | else if (el.mozRequestFullScreen) {
|
56 | el.mozRequestFullScreen();
|
57 | }
|
58 | else if (el.webkitRequestFullscreen) {
|
59 | el.webkitRequestFullscreen();
|
60 | }
|
61 | };
|
62 | FullScreen.prototype.exitFullscreen = function () {
|
63 | if (document.exitFullscreen) {
|
64 | document.exitFullscreen();
|
65 | }
|
66 | else if (document.msExitFullscreen) {
|
67 | document.msExitFullscreen();
|
68 | }
|
69 | else if (document.mozCancelFullScreen) {
|
70 | document.mozCancelFullScreen();
|
71 | }
|
72 | else if (document.webkitExitFullscreen) {
|
73 | document.webkitExitFullscreen();
|
74 | }
|
75 | };
|
76 |
|
77 | FullScreen.prototype.fullScreen = function () {
|
78 | var _this = this;
|
79 | this.$LG(document).on("fullscreenchange.lg.global" + this.core.lgId + " \n webkitfullscreenchange.lg.global" + this.core.lgId + " \n mozfullscreenchange.lg.global" + this.core.lgId + " \n MSFullscreenChange.lg.global" + this.core.lgId, function () {
|
80 | if (!_this.core.lgOpened)
|
81 | return;
|
82 | _this.core.outer.toggleClass('lg-fullscreen-on');
|
83 | });
|
84 | this.core.outer
|
85 | .find('.lg-fullscreen')
|
86 | .first()
|
87 | .on('click.lg', function () {
|
88 | if (_this.isFullScreen()) {
|
89 | _this.exitFullscreen();
|
90 | }
|
91 | else {
|
92 | _this.requestFullscreen();
|
93 | }
|
94 | });
|
95 | };
|
96 | FullScreen.prototype.closeGallery = function () {
|
97 |
|
98 | if (this.isFullScreen()) {
|
99 | this.exitFullscreen();
|
100 | }
|
101 | };
|
102 | FullScreen.prototype.destroy = function () {
|
103 | this.$LG(document).off("fullscreenchange.lg.global" + this.core.lgId + " \n webkitfullscreenchange.lg.global" + this.core.lgId + " \n mozfullscreenchange.lg.global" + this.core.lgId + " \n MSFullscreenChange.lg.global" + this.core.lgId);
|
104 | };
|
105 | return FullScreen;
|
106 | }());
|
107 | exports.default = FullScreen;
|
108 |
|
\ | No newline at end of file |