/*! lg-video - v1.0.2 - 2017-06-04 * http://sachinchoolur.github.io/lightgallery * copyright (c) 2017 sachin n; licensed gplv3 */ !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jquery)}(this,function(a){!function(){"use strict";var b={videomaxwidth:"855px",youtubeplayerparams:!1,vimeoplayerparams:!1,dailymotionplayerparams:!1,vkplayerparams:!1,videojs:!1,videojsoptions:{}},c=function(c){return this.core=a(c).data("lightgallery"),this.$el=a(c),this.core.s=a.extend({},b,this.core.s),this.videoloaded=!1,this.init(),this};c.prototype.init=function(){var b=this;b.core.$el.on("hasvideo.lg.tm",function(a,c,d,e){if(b.core.$slide.eq(c).find(".lg-video").append(b.loadvideo(d,"lg-object",!0,c,e)),e)if(b.core.s.videojs)try{videojs(b.core.$slide.eq(c).find(".lg-html5").get(0),b.core.s.videojsoptions,function(){b.videoloaded||this.play()})}catch(a){console.error("make sure you have included videojs")}else b.videoloaded||b.core.$slide.eq(c).find(".lg-html5").get(0).play()}),b.core.$el.on("onaferappendslide.lg.tm",function(a,c){var d=b.core.$slide.eq(c).find(".lg-video-cont");d.hasclass("lg-has-iframe")||(d.css("max-width",b.core.s.videomaxwidth),b.videoloaded=!0)});var c=function(a){if(a.find(".lg-object").hasclass("lg-has-poster")&&a.find(".lg-object").is(":visible"))if(a.hasclass("lg-has-video")){var c=a.find(".lg-youtube").get(0),d=a.find(".lg-vimeo").get(0),e=a.find(".lg-dailymotion").get(0),f=a.find(".lg-html5").get(0);if(c)c.contentwindow.postmessage('{"event":"command","func":"playvideo","args":""}',"*");else if(d)try{$f(d).api("play")}catch(a){console.error("make sure you have included froogaloop2 js")}else if(e)e.contentwindow.postmessage("play","*");else if(f)if(b.core.s.videojs)try{videojs(f).play()}catch(a){console.error("make sure you have included videojs")}else f.play();a.addclass("lg-video-playing")}else{a.addclass("lg-video-playing lg-has-video");var g,h,i=function(c,d){if(a.find(".lg-video").append(b.loadvideo(c,"",!1,b.core.index,d)),d)if(b.core.s.videojs)try{videojs(b.core.$slide.eq(b.core.index).find(".lg-html5").get(0),b.core.s.videojsoptions,function(){this.play()})}catch(a){console.error("make sure you have included videojs")}else b.core.$slide.eq(b.core.index).find(".lg-html5").get(0).play()};b.core.s.dynamic?(g=b.core.s.dynamicel[b.core.index].src,h=b.core.s.dynamicel[b.core.index].html,i(g,h)):(g=b.core.$items.eq(b.core.index).attr("href")||b.core.$items.eq(b.core.index).attr("data-src"),h=b.core.$items.eq(b.core.index).attr("data-html"),i(g,h));var j=a.find(".lg-object");a.find(".lg-video").append(j),a.find(".lg-video-object").hasclass("lg-html5")||(a.removeclass("lg-complete"),a.find(".lg-video-object").on("load.lg error.lg",function(){a.addclass("lg-complete")}))}};b.core.docss()&&b.core.$items.length>1&&(b.core.s.enableswipe&&b.core.istouch||b.core.s.enabledrag&&!b.core.istouch)?b.core.$el.on("onslideclick.lg.tm",function(){var a=b.core.$slide.eq(b.core.index);c(a)}):b.core.$slide.on("click.lg",function(){c(a(this))}),b.core.$el.on("onbeforeslide.lg.tm",function(c,d,e){var f=b.core.$slide.eq(d),g=f.find(".lg-youtube").get(0),h=f.find(".lg-vimeo").get(0),i=f.find(".lg-dailymotion").get(0),j=f.find(".lg-vk").get(0),k=f.find(".lg-html5").get(0);if(g)g.contentwindow.postmessage('{"event":"command","func":"pausevideo","args":""}',"*");else if(h)try{$f(h).api("pause")}catch(a){console.error("make sure you have included froogaloop2 js")}else if(i)i.contentwindow.postmessage("pause","*");else if(k)if(b.core.s.videojs)try{videojs(k).pause()}catch(a){console.error("make sure you have included videojs")}else k.pause();j&&a(j).attr("src",a(j).attr("src").replace("&autoplay","&noplay"));var l;l=b.core.s.dynamic?b.core.s.dynamicel[e].src:b.core.$items.eq(e).attr("href")||b.core.$items.eq(e).attr("data-src");var m=b.core.isvideo(l,e)||{};(m.youtube||m.vimeo||m.dailymotion||m.vk)&&b.core.$outer.addclass("lg-hide-download")}),b.core.$el.on("onafterslide.lg.tm",function(a,c){b.core.$slide.eq(c).removeclass("lg-video-playing")})},c.prototype.loadvideo=function(b,c,d,e,f){var g="",h=1,i="",j=this.core.isvideo(b,e)||{};if(d&&(h=this.videoloaded?0:1),j.youtube)i="?wmode=opaque&autoplay="+h+"&enablejsapi=1",this.core.s.youtubeplayerparams&&(i=i+"&"+a.param(this.core.s.youtubeplayerparams)),g='';else if(j.vimeo)i="?autoplay="+h+"&api=1",this.core.s.vimeoplayerparams&&(i=i+"&"+a.param(this.core.s.vimeoplayerparams)),g='';else if(j.dailymotion)i="?wmode=opaque&autoplay="+h+"&api=postmessage",this.core.s.dailymotionplayerparams&&(i=i+"&"+a.param(this.core.s.dailymotionplayerparams)),g='';else if(j.html5){var k=f.substring(0,1);"."!==k&&"#"!==k||(f=a(f).html()),g=f}else j.vk&&(i="&autoplay="+h,this.core.s.vkplayerparams&&(i=i+"&"+a.param(this.core.s.vkplayerparams)),g='');return g},c.prototype.destroy=function(){this.videoloaded=!1},a.fn.lightgallery.modules.video=c}()});