File: /home/adventp/www/wp-content/themes/brooklyn/assets/vendor/lightGallery/js/lg-video.min.js
/*! lightgallery - v1.2.6 - 2015-10-07
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2015 Sachin N; Licensed Apache 2.0 */
(function(d,c,a,f){var e={videoMaxWidth:"855px",youtubePlayerParams:false,vimeoPlayerParams:false,dailymotionPlayerParams:false,videojs:false};var b=function(g){this.core=d(g).data("lightGallery");this.$el=d(g);this.core.s=d.extend({},e,this.core.s);this.videoLoaded=false;this.init();return this};b.prototype.init=function(){var h=this;h.core.$el.on("hasVideo.lg.tm",function(k,i,m,j){h.core.$slide.eq(i).find(".lg-video").append(h.loadVideo(m,"lg-object",true,i,j));if(j){if(h.core.s.videojs){try{videojs(h.core.$slide.eq(i).find(".lg-html5").get(0),{},function(){if(!h.videoLoaded){this.play()}})}catch(l){console.error("Make sure you have included videojs")}}else{h.core.$slide.eq(i).find(".lg-html5").get(0).play()}}});h.core.$el.on("onAferAppendSlide.lg.tm",function(j,i){h.core.$slide.eq(i).find(".lg-video-cont").css("max-width",h.core.s.videoMaxWidth);h.videoLoaded=true});var g=function(r){if(r.find(".lg-object").hasClass("lg-has-poster")){if(!r.hasClass("lg-has-video")){r.addClass("lg-video-palying lg-has-video");var m;var l;var q=function(u,s){r.find(".lg-video").append(h.loadVideo(u,"",false,h.core.index,s));if(s){if(h.core.s.videojs){try{videojs(h.core.$slide.eq(h.core.index).find(".lg-html5").get(0),{},function(){this.play()})}catch(t){console.error("Make sure you have included videojs")}}else{h.core.$slide.eq(h.core.index).find(".lg-html5").get(0).play()}}};if(h.core.s.dynamic){m=h.core.s.dynamicEl[h.core.index].src;l=h.core.s.dynamicEl[h.core.index].html;q(m,l)}else{m=h.core.$items.eq(h.core.index).attr("href")||h.core.$items.eq(h.core.index).attr("data-src");l=h.core.$items.eq(h.core.index).attr("data-html");q(m,l)}var k=r.find(".lg-object");r.find(".lg-video").append(k);if(!r.find(".lg-video-object").hasClass("lg-html5")){r.removeClass("lg-complete");r.find(".lg-video-object").on("load.lg error.lg",function(){r.addClass("lg-complete")})}}else{var p=r.find(".lg-youtube").get(0);var n=r.find(".lg-vimeo").get(0);var j=r.find(".lg-dailymotion").get(0);var i=r.find(".lg-html5").get(0);if(p){p.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}',"*")}else{if(n){try{$f(n).api("play")}catch(o){console.error("Make sure you have included froogaloop2 js")}}else{if(j){j.contentWindow.postMessage("play","*")}else{if(i){if(h.core.s.videojs){try{videojs(i).play()}catch(o){console.error("Make sure you have included videojs")}}else{i.play()}}}}}r.addClass("lg-video-palying")}}};if(h.core.doCss()&&h.core.$items.length>1&&((h.core.s.enableSwipe&&h.core.isTouch)||(h.core.s.enableDrag&&!h.core.isTouch))){h.core.$el.on("onSlideClick.lg.tm",function(){var i=h.core.$slide.eq(h.core.index);g(i)})}else{h.core.$slide.on("click.lg",function(){g(d(this))})}h.core.$el.on("onBeforeSlide.lg.tm",function(n,k){var j=h.core.$slide.eq(k);var i=j.find(".lg-youtube").get(0);var p=j.find(".lg-vimeo").get(0);var m=j.find(".lg-dailymotion").get(0);var l=j.find(".lg-html5").get(0);if(i){i.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}',"*")}else{if(p){try{$f(p).api("pause")}catch(o){console.error("Make sure you have included froogaloop2 js")}}else{if(m){m.contentWindow.postMessage("pause","*")}else{if(l){if(h.core.s.videojs){try{videojs(l).pause()}catch(o){console.error("Make sure you have included videojs")}}else{l.pause()}}}}}});h.core.$el.on("onAfterSlide.lg.tm",function(j,i){h.core.$slide.eq(i).removeClass("lg-video-palying")})};b.prototype.loadVideo=function(h,o,l,n,m){var i="";var k=1;var p="";var g=this.core.isVideo(h,n)||{};if(l){if(this.videoLoaded){k=0}else{k=1}}if(g.youtube){p="?wmode=opaque&autoplay="+k+"&enablejsapi=1";if(this.core.s.youtubePlayerParams){p=p+"&"+d.param(this.core.s.youtubePlayerParams)}i='<iframe class="lg-video-object lg-youtube '+o+'" width="560" height="315" src="//www.youtube.com/embed/'+g.youtube[1]+p+'" frameborder="0" allowfullscreen></iframe>'}else{if(g.vimeo){p="?autoplay="+k+"&api=1";if(this.core.s.vimeoPlayerParams){p=p+"&"+d.param(this.core.s.vimeoPlayerParams)}i='<iframe class="lg-video-object lg-vimeo '+o+'" width="560" height="315" src="http://player.vimeo.com/video/'+g.vimeo[1]+p+'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'}else{if(g.dailymotion){p="?wmode=opaque&autoplay="+k+"&api=postMessage";if(this.core.s.dailymotionPlayerParams){p=p+"&"+d.param(this.core.s.dailymotionPlayerParams)}i='<iframe class="lg-video-object lg-dailymotion '+o+'" width="560" height="315" src="//www.dailymotion.com/embed/video/'+g.dailymotion[1]+p+'" frameborder="0" allowfullscreen></iframe>'}else{if(g.html5){var j=m.substring(0,1);if(j==="."||j==="#"){m=d(m).html()}i=m}}}}return i};b.prototype.destroy=function(){this.videoLoaded=false};d.fn.lightGallery.modules.video=b})(jQuery,window,document);