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