PageSourceSearch

https://www.winterthur.org/wp-content/plugins/grid-kit-premium/js/…/lg-video.js?ver=5.9.13

js winterthur.org collected 2026-10-01 10:30:57 UTC 13,142 bytes, 331 lines download raw bytes

vendor: 13,142 bytes, lines 1-331
1/*! lg-video - v1.2.1 - 2018-03-08
2* http://sachinchoolur.github.io/lightGallery
3* Copyright (c) 2018 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            videoMaxWidth: '855px',
27
28            autoplayFirstVideo: true,
29
30            youtubePlayerParams: false,
31            vimeoPlayerParams: false,
32            dailymotionPlayerParams: false,
33            vkPlayerParams: false,
34
35            videojs: false,
36            videojsOptions: {}
37        };
38    
39        var Video = function(element) {
40    
41            this.core = $(element).data('lightGallery');
42    
43            this.$el = $(element);
44            this.core.s = $.extend({}, defaults, this.core.s);
45            this.videoLoaded = false;
46    
47            this.init();
48    
49            return this;
50        };
51    
52        Video.prototype.init = function() {
53            var _this = this;
54    
55            // Event triggered when video url found without poster
56            _this.core.$el.on('hasVideo.lg.tm', onHasVideo.bind(this));
57    
58            // Set max width for video
59            _this.core.$el.on('onAferAppendSlide.lg.tm', onAferAppendSlide.bind(this));
60    
61            if (_this.core.doCss() && (_this.core.$items.length > 1) && (_this.core.s.enableSwipe || _this.core.s.enableDrag)) {
62                _this.core.$el.on('onSlideClick.lg.tm', function() {
63                    var $el = _this.core.$slide.eq(_this.core.index);
64                    _this.loadVideoOnclick($el);
65                });
66            } else {
67    
68                // For IE 9 and bellow
69                _this.core.$slide.on('click.lg', function() {
70                    _this.loadVideoOnclick($(this));
71                });
72            }
73    
74            _this.core.$el.on('onBeforeSlide.lg.tm', onBeforeSlide.bind(this));
75    
76            _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex) {
77                _this.core.$slide.eq(prevIndex).removeClass('lg-video-playing');
78            });
79        };
80    
81        Video.prototype.loadVideo = function(src, addClass, noPoster, index, html) {
82            var video = '';
83            var autoplay = 1;
84            var a = '';
85            var isVideo = this.core.isVideo(src, index) || {};
86    
87            // Enable autoplay based on setting for first video if poster doesn't exist
88            if (noPoster) {
89                if (this.videoLoaded) {
90                    autoplay = 0;
91                } else {
92                    autoplay = this.core.s.autoplayFirstVideo ? 1 : 0;
93                }
94            }
95    
96            if (isVideo.youtube) {
97    
98                a = '?wmode=opaque&autoplay=' + autoplay + '&enablejsapi=1';
99                if (this.core.s.youtubePlayerParams) {
100                    a = a + '&' + $.param(this.core.s.youtubePlayerParams);
101                }
102    
103                video = '<iframe class="lg-video-object lg-youtube ' + addClass + '" width="560" height="315" src="//www.youtube.com/embed/' + isVideo.youtube[1] + a + '" frameborder="0" allowfullscreen></iframe>';
104    
105            } else if (isVideo.vimeo) {
106    
107                a = '?autoplay=' + autoplay + '&api=1';
108                if (this.core.s.vimeoPlayerParams) {
109                    a = a + '&' + $.param(this.core.s.vimeoPlayerParams);
110                }
111    
112                video = '<iframe class="lg-video-object lg-vimeo ' + addClass + '" width="560" height="315"  src="//player.vimeo.com/video/' + isVideo.vimeo[1] + a + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
113    
114            } else if (isVideo.dailymotion) {
115    
116                a = '?wmode=opaque&autoplay=' + autoplay + '&api=postMessage';
117                if (this.core.s.dailymotionPlayerParams) {
118                    a = a + '&' + $.param(this.core.s.dailymotionPlayerParams);
119                }
120    
121                video = '<iframe class="lg-video-object lg-dailymotion ' + addClass + '" width="560" height="315" src="//www.dailymotion.com/embed/video/' + isVideo.dailymotion[1] + a + '" frameborder="0" allowfullscreen></iframe>';
122    
123            } else if (isVideo.html5) {
124                var fL = html.substring(0, 1);
125                if (fL === '.' || fL === '#') {
126                    html = $(html).html();
127                }
128    
129                video = html;
130    
131            } else if (isVideo.vk) {
132    
133                a = '&autoplay=' + autoplay;
134                if (this.core.s.vkPlayerParams) {
135                    a = a + '&' + $.param(this.core.s.vkPlayerParams);
136                }
137    
138                video = '<iframe class="lg-video-object lg-vk ' + addClass + '" width="560" height="315" src="//vk.com/video_ext.php?' + isVideo.vk[1] + a + '" frameborder="0" allowfullscreen></iframe>';
139    
140            }
141    
142            return video;
143        };
144
145        Video.prototype.loadVideoOnclick = function($el){
146
147            var _this = this;
148            // check slide has poster
149            if ($el.find('.lg-object').hasClass('lg-has-poster') && $el.find('.lg-object').is(':visible')) {
150
151                // check already video element present
152                if (!$el.hasClass('lg-has-video')) {
153
154                    $el.addClass('lg-video-playing lg-has-video');
155
156                    var _src;
157                    var _html;
158                    var _loadVideo = function(_src, _html) {
159
160                        $el.find('.lg-video').append(_this.loadVideo(_src, '', false, _this.core.index, _html));
161
162                        if (_html) {
163                            if (_this.core.s.videojs) {
164                                try {
165                                    videojs(_this.core.$slide.eq(_this.core.index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() {
166                                        this.play();
167                                    });
168                                } catch (e) {
169                                    console.error('Make sure you have included videojs');
170                                }
171                            } else {
172                                _this.core.$slide.eq(_this.core.index).find('.lg-html5').get(0).play();
173                            }
174                        }
175
176                    };
177
178                    if (_this.core.s.dynamic) {
179
180                        _src = _this.core.s.dynamicEl[_this.core.index].src;
181                        _html = _this.core.s.dynamicEl[_this.core.index].html;
182
183                        _loadVideo(_src, _html);
184
185                    } else {
186
187                        _src = _this.core.$items.eq(_this.core.index).attr('href') || _this.core.$items.eq(_this.core.index).attr('data-src');
188                        _html = _this.core.$items.eq(_this.core.index).attr('data-html');
189
190                        _loadVideo(_src, _html);
191
192                    }
193
194                    var $tempImg = $el.find('.lg-object');
195                    $el.find('.lg-video').append($tempImg);
196
197                    // @todo loading icon for html5 videos also
198                    // for showing the loading indicator while loading video
199                    if (!$el.find('.lg-video-object').hasClass('lg-html5')) {
200                        $el.removeClass('lg-complete');
201                        $el.find('.lg-video-object').on('load.lg error.lg', function() {
202                            $el.addClass('lg-complete');
203                        });
204                    }
205
206                } else {
207
208                    var youtubePlayer = $el.find('.lg-youtube').get(0);
209                    var vimeoPlayer = $el.find('.lg-vimeo').get(0);
210                    var dailymotionPlayer = $el.find('.lg-dailymotion').get(0);
211                    var html5Player = $el.find('.lg-html5').get(0);
212                    if (youtubePlayer) {
213                        youtubePlayer.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
214                    } else if (vimeoPlayer) {
215                        try {
216                            $f(vimeoPlayer).api('play');
217                        } catch (e) {
218                            console.error('Make sure you have included froogaloop2 js');
219                        }
220                    } else if (dailymotionPlayer) {
221                        dailymotionPlayer.contentWindow.postMessage('play', '*');
222
223                    } else if (html5Player) {
224                        if (_this.core.s.videojs) {
225                            try {
226                                videojs(html5Player).play();
227                            } catch (e) {
228                                console.error('Make sure you have included videojs');
229                            }
230                        } else {
231                            html5Player.play();
232                        }
233                    }
234
235                    $el.addClass('lg-video-playing');
236
237                }
238            }
239        };
240    
241        Video.prototype.destroy = function() {
242            this.videoLoaded = false;
243        };
244
245        function onHasVideo(event, index, src, html) {
246            /*jshint validthis:true */
247            var _this = this;
248            _this.core.$slide.eq(index).find('.lg-video').append(_this.loadVideo(src, 'lg-object', true, index, html));
249            if (html) {
250                if (_this.core.s.videojs) {
251                    try {
252                        videojs(_this.core.$slide.eq(index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() {
253                            if (!_this.videoLoaded && _this.core.s.autoplayFirstVideo) {
254                                this.play();
255                            }
256                        });
257                    } catch (e) {
258                        console.error('Make sure you have included videojs');
259                    }
260                } else {
261                    if(!_this.videoLoaded && _this.core.s.autoplayFirstVideo) {
262                        _this.core.$slide.eq(index).find('.lg-html5').get(0).play();
263                    }
264                }
265            }
266        }
267
268        function onAferAppendSlide(event, index) {
269            /*jshint validthis:true */
270            var $videoCont = this.core.$slide.eq(index).find('.lg-video-cont');
271            if (!$videoCont.hasClass('lg-has-iframe')) {
272                $videoCont.css('max-width', this.core.s.videoMaxWidth);
273                this.videoLoaded = true;
274            }
275        }
276
277        function onBeforeSlide(event, prevIndex, index) {
278            /*jshint validthis:true */
279            var _this = this;
280
281            var $videoSlide = _this.core.$slide.eq(prevIndex);
282            var youtubePlayer = $videoSlide.find('.lg-youtube').get(0);
283            var vimeoPlayer = $videoSlide.find('.lg-vimeo').get(0);
284            var dailymotionPlayer = $videoSlide.find('.lg-dailymotion').get(0);
285            var vkPlayer = $videoSlide.find('.lg-vk').get(0);
286            var html5Player = $videoSlide.find('.lg-html5').get(0);
287            if (youtubePlayer) {
288                youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
289            } else if (vimeoPlayer) {
290                try {
291                    $f(vimeoPlayer).api('pause');
292                } catch (e) {
293                    console.error('Make sure you have included froogaloop2 js');
294                }
295            } else if (dailymotionPlayer) {
296                dailymotionPlayer.contentWindow.postMessage('pause', '*');
297
298            } else if (html5Player) {
299                if (_this.core.s.videojs) {
300                    try {
301                        videojs(html5Player).pause();
302                    } catch (e) {
303                        console.error('Make sure you have included videojs');
304                    }
305                } else {
306                    html5Player.pause();
307                }
308            } if (vkPlayer) {
309                $(vkPlayer).attr('src', $(vkPlayer).attr('src').replace('&autoplay', '&noplay'));
310            }
311
312            var _src;
313            if (_this.core.s.dynamic) {
314                _src = _this.core.s.dynamicEl[index].src;
315            } else {
316                _src = _this.core.$items.eq(index).attr('href') || _this.core.$items.eq(index).attr('data-src');
317
318            }
319
320            var _isVideo = _this.core.isVideo(_src, index) || {};
321            if (_isVideo.youtube || _isVideo.vimeo || _isVideo.dailymotion || _isVideo.vk) {
322                _this.core.$outer.addClass('lg-hide-download');
323            }
324
325        }
326    
327        $.fn.lightGallery.modules.video = Video;
328    
329    })();
330
331}));

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.