PageSourceSearch

https://www.plastidiprus.ru/gal/js/lg-fullscreen.js

js plastidiprus.ru collected 2026-10-05 00:18:22 UTC 3,826 bytes, 126 lines download raw bytes

vendor: 3,826 bytes, lines 1-126
1/*! lg-fullscreen - v1.1.0 - 2019-02-19
2* http://sachinchoolur.github.io/lightGallery
3* Copyright (c) 2019 Sachin N; Licensed GPLv3 */
4
5(function (root, factory) {
6  if (typeof define === 'function' && define.amd) {
7    // AMD. Register as an anonymous module unless amdModuleId is set
8    define(['jquery'], function (a0) {
9      return (factory(a0));
10    });
11  } else if (typeof module === 'object' && module.exports) {
12    // Node. Does not work with strict CommonJS, but
13    // only CommonJS-like environments that support module.exports,
14    // like Node.
15    module.exports = factory(require('jquery'));
16  } else {
17    factory(root["jQuery"]);
18  }
19}(this, function ($) {
20
21(function() {
22
23    'use strict';
24
25    var defaults = {
26        fullScreen: true
27    };
28
29    function isFullScreen() {
30        return (
31            document.fullscreenElement ||
32            document.mozFullScreenElement ||
33            document.webkitFullscreenElement ||
34            document.msFullscreenElement
35        );
36    }
37
38    var Fullscreen = function(element) {
39
40        // get lightGallery core plugin data
41        this.core = $(element).data('lightGallery');
42
43        this.$el = $(element);
44
45        // extend module defalut settings with lightGallery core settings
46        this.core.s = $.extend({}, defaults, this.core.s);
47
48        this.init();
49
50        return this;
51    };
52
53    Fullscreen.prototype.init = function() {
54        var fullScreen = '';
55        if (this.core.s.fullScreen) {
56
57            // check for fullscreen browser support
58            if (!document.fullscreenEnabled && !document.webkitFullscreenEnabled &&
59                !document.mozFullScreenEnabled && !document.msFullscreenEnabled) {
60                return;
61            } else {
62                fullScreen = '<span class="lg-fullscreen lg-icon"></span>';
63                this.core.$outer.find('.lg-toolbar').append(fullScreen);
64                this.fullScreen();
65            }
66        }
67    };
68
69    Fullscreen.prototype.requestFullscreen = function() {
70        var el = document.documentElement;
71        if (el.requestFullscreen) {
72            el.requestFullscreen();
73        } else if (el.msRequestFullscreen) {
74            el.msRequestFullscreen();
75        } else if (el.mozRequestFullScreen) {
76            el.mozRequestFullScreen();
77        } else if (el.webkitRequestFullscreen) {
78            el.webkitRequestFullscreen();
79        }
80    };
81
82    Fullscreen.prototype.exitFullscreen = function() {
83        if (document.exitFullscreen) {
84            document.exitFullscreen();
85        } else if (document.msExitFullscreen) {
86            document.msExitFullscreen();
87        } else if (document.mozCancelFullScreen) {
88            document.mozCancelFullScreen();
89        } else if (document.webkitExitFullscreen) {
90            document.webkitExitFullscreen();
91        }
92    };
93
94    // https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
95    Fullscreen.prototype.fullScreen = function() {
96        var _this = this;
97
98        $(document).on('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg', function() {
99            _this.core.$outer.toggleClass('lg-fullscreen-on');
100        });
101
102        this.core.$outer.find('.lg-fullscreen').on('click.lg', function() {
103            if (isFullScreen()) {
104                _this.exitFullscreen();
105            } else {
106                _this.requestFullscreen();
107            }
108        });
109
110    };
111
112    Fullscreen.prototype.destroy = function() {
113
114        // exit from fullscreen if activated
115        if(isFullScreen()) {
116            this.exitFullscreen();
117        }
118
119        $(document).off('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg');
120    };
121
122    $.fn.lightGallery.modules.fullscreen = Fullscreen;
123
124})();
125
126}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.