1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var __assign = function() {
|
24 | __assign = Object.assign || function __assign(t) {
|
25 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
26 | s = arguments[i];
|
27 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
28 | }
|
29 | return t;
|
30 | };
|
31 | return __assign.apply(this, arguments);
|
32 | };
|
33 |
|
34 | var fullscreenSettings = {
|
35 | fullScreen: true,
|
36 | fullscreenPluginStrings: {
|
37 | toggleFullscreen: 'Toggle Fullscreen',
|
38 | },
|
39 | };
|
40 |
|
41 | var FullScreen = (function () {
|
42 | function FullScreen(instance, $LG) {
|
43 |
|
44 | this.core = instance;
|
45 | this.$LG = $LG;
|
46 |
|
47 | this.settings = __assign(__assign({}, fullscreenSettings), this.core.settings);
|
48 | return this;
|
49 | }
|
50 | FullScreen.prototype.init = function () {
|
51 | var fullScreen = '';
|
52 | if (this.settings.fullScreen) {
|
53 |
|
54 | if (!document.fullscreenEnabled &&
|
55 | !document.webkitFullscreenEnabled &&
|
56 | !document.mozFullScreenEnabled &&
|
57 | !document.msFullscreenEnabled) {
|
58 | return;
|
59 | }
|
60 | else {
|
61 | fullScreen = "<button type=\"button\" aria-label=\"" + this.settings.fullscreenPluginStrings['toggleFullscreen'] + "\" class=\"lg-fullscreen lg-icon\"></button>";
|
62 | this.core.$toolbar.append(fullScreen);
|
63 | this.fullScreen();
|
64 | }
|
65 | }
|
66 | };
|
67 | FullScreen.prototype.isFullScreen = function () {
|
68 | return (document.fullscreenElement ||
|
69 | document.mozFullScreenElement ||
|
70 | document.webkitFullscreenElement ||
|
71 | document.msFullscreenElement);
|
72 | };
|
73 | FullScreen.prototype.requestFullscreen = function () {
|
74 | var el = document.documentElement;
|
75 | if (el.requestFullscreen) {
|
76 | el.requestFullscreen();
|
77 | }
|
78 | else if (el.msRequestFullscreen) {
|
79 | el.msRequestFullscreen();
|
80 | }
|
81 | else if (el.mozRequestFullScreen) {
|
82 | el.mozRequestFullScreen();
|
83 | }
|
84 | else if (el.webkitRequestFullscreen) {
|
85 | el.webkitRequestFullscreen();
|
86 | }
|
87 | };
|
88 | FullScreen.prototype.exitFullscreen = function () {
|
89 | if (document.exitFullscreen) {
|
90 | document.exitFullscreen();
|
91 | }
|
92 | else if (document.msExitFullscreen) {
|
93 | document.msExitFullscreen();
|
94 | }
|
95 | else if (document.mozCancelFullScreen) {
|
96 | document.mozCancelFullScreen();
|
97 | }
|
98 | else if (document.webkitExitFullscreen) {
|
99 | document.webkitExitFullscreen();
|
100 | }
|
101 | };
|
102 |
|
103 | FullScreen.prototype.fullScreen = function () {
|
104 | var _this = this;
|
105 | 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 () {
|
106 | if (!_this.core.lgOpened)
|
107 | return;
|
108 | _this.core.outer.toggleClass('lg-fullscreen-on');
|
109 | });
|
110 | this.core.outer
|
111 | .find('.lg-fullscreen')
|
112 | .first()
|
113 | .on('click.lg', function () {
|
114 | if (_this.isFullScreen()) {
|
115 | _this.exitFullscreen();
|
116 | }
|
117 | else {
|
118 | _this.requestFullscreen();
|
119 | }
|
120 | });
|
121 | };
|
122 | FullScreen.prototype.closeGallery = function () {
|
123 |
|
124 | if (this.isFullScreen()) {
|
125 | this.exitFullscreen();
|
126 | }
|
127 | };
|
128 | FullScreen.prototype.destroy = function () {
|
129 | 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);
|
130 | };
|
131 | return FullScreen;
|
132 | }());
|
133 |
|
134 | export default FullScreen;
|
135 |
|