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