/******************************************** * revolution 5.1 extension - video functions * @version: 1.2.1 (26.11.2015) * @requires jquery.themepunch.revolution.js * @author themepunch *********************************************/ !function(e){function t(e){return void 0==e?-1:jquery.isnumeric(e)?e:e.split(":").length>1?60*parseint(e.split(":")[0],0)+parseint(e.split(":")[1],0):e}var a=jquery.fn.revolution,i=a.is_mobile();jquery.extend(!0,a,{resetvideo:function(e,d){switch(e.data("videotype")){case"youtube":e.data("player");try{if("on"==e.data("forcerewind")&&!i){var o=t(e.data("videostartat"));o=-1==o?0:o,void 0!=e.data("player")&&(e.data("player").seekto(o),e.data("player").pausevideo())}}catch(r){}0==e.find(".tp-videoposter").length&&punchgs.tweenlite.to(e.find("iframe"),.3,{autoalpha:1,display:"block",ease:punchgs.power3.easeinout});break;case"vimeo":var n=$f(e.find("iframe").attr("id"));try{if("on"==e.data("forcerewind")&&!i){var o=t(e.data("videostartat"));o=-1==o?0:o,n.api("seekto",o),n.api("pause")}}catch(r){}0==e.find(".tp-videoposter").length&&punchgs.tweenlite.to(e.find("iframe"),.3,{autoalpha:1,display:"block",ease:punchgs.power3.easeinout});break;case"html5":if(i&&1==e.data("disablevideoonmobile"))return!1;var s=e.find("video"),l=s[0];if(punchgs.tweenlite.to(s,.3,{autoalpha:1,display:"block",ease:punchgs.power3.easeinout}),"on"==e.data("forcerewind")&&!e.hasclass("videoisplaying"))try{var o=t(e.data("videostartat"));l.currenttime=-1==o?0:o}catch(r){}("mute"==e.data("volume")||a.lasttogglestate(e.data("videomutetoggledby")))&&(l.muted=!0)}},isvideomuted:function(e,t){var a=!1;switch(e.data("videotype")){case"youtube":try{var i=e.data("player");a=i.ismuted()}catch(d){}break;case"vimeo":try{$f(e.find("iframe").attr("id"));"mute"==e.data("volume")&&(a=!0)}catch(d){}break;case"html5":var o=e.find("video"),r=o[0];"mute"==e.data("volume")&&(r.muted=!0)}return a},mutevideo:function(e,t){switch(e.data("videotype")){case"youtube":try{var a=e.data("player");a.mute()}catch(i){}break;case"vimeo":try{var d=$f(e.find("iframe").attr("id"));e.data("volume","mute"),d.api("setvolume",0)}catch(i){}break;case"html5":var o=e.find("video"),r=o[0];r.muted=!0}},unmutevideo:function(e,t){switch(e.data("videotype")){case"youtube":try{var a=e.data("player");a.unmute()}catch(i){}break;case"vimeo":try{var d=$f(e.find("iframe").attr("id"));e.data("volume","1"),d.api("setvolume",1)}catch(i){}break;case"html5":var o=e.find("video"),r=o[0];r.muted=!1}},stopvideo:function(e,t){switch(e.data("videotype")){case"youtube":try{var a=e.data("player");a.pausevideo()}catch(i){}break;case"vimeo":try{var d=$f(e.find("iframe").attr("id"));d.api("pause")}catch(i){}break;case"html5":var o=e.find("video"),r=o[0];r.pause()}},playvideo:function(e,o){switch(cleartimeout(e.data("videoplaywait")),e.data("videotype")){case"youtube":if(0==e.find("iframe").length)e.append(e.data("videomarkup")),r(e,o,!0);else if(void 0!=e.data("player").playvideo){var n=t(e.data("videostartat")),s=e.data("player").getcurrenttime();1==e.data("nextslideatend-triggered")&&(s=-1,e.data("nextslideatend-triggered",0)),-1!=n&&n>s&&e.data("player").seekto(n),e.data("player").playvideo()}else e.data("videoplaywait",settimeout(function(){a.playvideo(e,o)},50));break;case"vimeo":if(0==e.find("iframe").length)e.append(e.data("videomarkup")),r(e,o,!0);else if(e.hasclass("rs-apiready")){var l=e.find("iframe").attr("id"),p=$f(l);void 0==p.api("play")?e.data("videoplaywait",settimeout(function(){a.playvideo(e,o)},50)):settimeout(function(){p.api("play");var a=t(e.data("videostartat")),i=e.data("currenttime");1==e.data("nextslideatend-triggered")&&(i=-1,e.data("nextslideatend-triggered",0)),-1!=a&&a>i&&p.api("seekto",a)},510)}else e.data("videoplaywait",settimeout(function(){a.playvideo(e,o)},50));break;case"html5":if(i&&1==e.data("disablevideoonmobile"))return!1;var v=e.find("video"),u=v[0],c=v.parent();if(1!=c.data("metaloaded"))d(u,"loadedmetadata",function(e){a.resetvideo(e,o),u.play();var i=t(e.data("videostartat")),d=u.currenttime;1==e.data("nextslideatend-triggered")&&(d=-1,e.data("nextslideatend-triggered",0)),-1!=i&&i>d&&(u.currenttime=i)}(e));else{u.play();var n=t(e.data("videostartat")),s=u.currenttime;1==e.data("nextslideatend-triggered")&&(s=-1,e.data("nextslideatend-triggered",0)),-1!=n&&n>s&&(u.currenttime=n)}}},isvideoplaying:function(e,t){var a=!1;return void 0!=t.playingvideos&&jquery.each(t.playingvideos,function(t,i){e.attr("id")==i.attr("id")&&(a=!0)}),a},preparecoveredvideo:function(e,t,a){var i=a.find("iframe, video"),d=e.split(":")[0],o=e.split(":")[1],r=a.closest(".tp-revslider-slidesli"),n=r.width()/r.height(),s=d/o,l=n/s*100,p=s/n*100;n>s?punchgs.tweenlite.to(i,.001,{height:l+"%",width:"100%",top:-(l-100)/2+"%",left:"0px",position:"absolute"}):punchgs.tweenlite.to(i,.001,{width:p+"%",height:"100%",left:-(p-100)/2+"%",top:"0px",position:"absolute"})},checkvideoapis:function(e,t,a){var i="https:"===location.protocol?"https":"http";if((void 0!=e.data("ytid")||e.find("iframe").length>0&&e.find("iframe").attr("src").tolowercase().indexof("youtube")>0)&&(t.youtubeapineeded=!0),(void 0!=e.data("ytid")||e.find("iframe").length>0&&e.find("iframe").attr("src").tolowercase().indexof("youtube")>0)&&0==a.addedyt){t.youtubestarttime=jquery.now(),a.addedyt=1;var d=document.createelement("script");d.src="https://www.youtube.com/iframe_api";var o=document.getelementsbytagname("script")[0],r=!0;jquery("head").find("*").each(function(){"https://www.youtube.com/iframe_api"==jquery(this).attr("src")&&(r=!1)}),r&&o.parentnode.insertbefore(d,o)}if((void 0!=e.data("vimeoid")||e.find("iframe").length>0&&e.find("iframe").attr("src").tolowercase().indexof("vimeo")>0)&&(t.vimeoapineeded=!0),(void 0!=e.data("vimeoid")||e.find("iframe").length>0&&e.find("iframe").attr("src").tolowercase().indexof("vimeo")>0)&&0==a.addedvim){t.vimeostarttime=jquery.now(),a.addedvim=1;var n=document.createelement("script"),o=document.getelementsbytagname("script")[0],r=!0;n.src=i+"://f.vimeocdn.com/js/froogaloop2.min.js",jquery("head").find("*").each(function(){jquery(this).attr("src")==i+"://a.vimeocdn.com/js/froogaloop2.min.js"&&(r=!1)}),r&&o.parentnode.insertbefore(n,o)}return a},managevideolayer:function(e,o,s,l){var p=e.data("videoattributes"),v=e.data("ytid"),u=e.data("vimeoid"),c=e.data("videpreload"),g=e.data("videomp4"),f=e.data("videowebm"),y=e.data("videoogv"),m=e.data("allowfullscreenvideo"),h=e.data("videocontrols"),b="http",w="loop"==e.data("videoloop")?"loop":"loopandnoslidestop"==e.data("videoloop")?"loop":"",t=void 0!=g||void 0!=f?"html5":void 0!=v&&string(v).length>1?"youtube":void 0!=u&&string(u).length>1?"vimeo":"none",k="html5"==t&&0==e.find("video").length?"html5":"youtube"==t&&0==e.find("iframe").length?"youtube":"vimeo"==t&&0==e.find("iframe").length?"vimeo":"none";switch(e.data("videotype",t),k){case"html5":"controls"!=h&&(h="");var x='";var l="";("true"===m||m===!0)&&(l='
'),"controls"==h&&(x+='
'+l+"
"),e.data("videomarkup",x),e.append(x),(i&&1==e.data("disablevideoonmobile")||a.isie(8))&&e.find("video").remove(),e.find("video").each(function(t){var i=this,r=jquery(this);r.parent().hasclass("html5vid")||r.wrap('
');var s=r.parent();1!=s.data("metaloaded")&&d(i,"loadedmetadata",function(e){n(e,o),a.resetvideo(e,o)}(e))});break;case"youtube":b="http","https:"===location.protocol&&(b="https"),"none"==h&&(p=p.replace("controls=1","controls=0"),-1==p.tolowercase().indexof("controls")&&(p+="&controls=0"));var v=t(e.data("videostartat")),p=t(e.data("videoendat"));-1!=v&&(p=p+"&start="+v),-1!=p&&(p=p+"&end="+p);var i=p.split("origin="+b+"://"),c="";i.length>1?(c=i[0]+"origin="+b+"://",self.location.href.match(/www/gi)&&!i[1].match(/www/gi)&&(c+="www."),c+=i[1]):c=p;var j="true"===m||m===!0?"allowfullscreen":"";e.data("videomarkup",'');break;case"vimeo":"https:"===location.protocol&&(b="https"),e.data("videomarkup",'')}var _=i&&"on"==e.data("noposteronmobile");if(void 0!=e.data("videoposter")&&e.data("videoposter").length>2&&!_)0==e.find(".tp-videoposter").length&&e.append('
'),0==e.find("iframe").length&&e.find(".tp-videoposter").click(function(){if(a.playvideo(e,o),i){if(1==e.data("disablevideoonmobile"))return!1;punchgs.tweenlite.to(e.find(".tp-videoposter"),.3,{autoalpha:0,force3d:"auto",ease:punchgs.power3.easeinout}),punchgs.tweenlite.to(e.find("iframe"),.3,{autoalpha:1,display:"block",ease:punchgs.power3.easeinout})}});else{if(i&&1==e.data("disablevideoonmobile"))return!1;0!=e.find("iframe").length||"youtube"!=t&&"vimeo"!=t||(e.append(e.data("videomarkup")),r(e,o,!1))}"none"!=e.data("dottedoverlay")&&void 0!=e.data("dottedoverlay")&&1!=e.find(".tp-dottedoverlay").length&&e.append('
'),e.addclass("haslistener"),1==e.data("bgvideo")&&punchgs.tweenlite.set(e.find("video, iframe"),{autoalpha:0})}});var d=function(e,t,a){e.addeventlistener?e.addeventlistener(t,a,!1):e.attachevent(t,a,!1)},o=function(e,t,a){var i={};return i.video=e,i.videotype=t,i.settings=a,i},r=function(e,d,r){var n=e.find("iframe"),p="iframe"+math.round(1e5*math.random()+1),v=e.data("videoloop"),u="loopandnoslidestop"!=v;if(v="loop"==v||"loopandnoslidestop"==v,1==e.data("forcecover")){e.removeclass("fullscreenvideo").addclass("coverscreenvideo");var c=e.data("aspectratio");void 0!=c&&c.split(":").length>1&&a.preparecoveredvideo(c,d,e)}if(1==e.data("bgvideo")){var c=e.data("aspectratio");void 0!=c&&c.split(":").length>1&&a.preparecoveredvideo(c,d,e)}if(n.attr("id",p),r&&e.data("startvideonow",!0),1!==e.data("videolistenerexist"))switch(e.data("videotype")){case"youtube":var g=new yt.player(p,{events:{onstatechange:function(e){var i=e.target.getvideoembedcode(),r=jquery("#"+i.split('id="')[1].split('"')[0]),n=r.closest(".tp-simpleresponsive"),p=r.parent(),c=r.parent().data("player");if(e.data==yt.playerstate.playing)punchgs.tweenlite.to(p.find(".tp-videoposter"),.3,{autoalpha:0,force3d:"auto",ease:punchgs.power3.easeinout}),punchgs.tweenlite.to(p.find("iframe"),.3,{autoalpha:1,display:"block",ease:punchgs.power3.easeinout}),"mute"==p.data("volume")||a.lasttogglestate(p.data("videomutetoggledby"))?c.mute():(c.unmute(),c.setvolume(parseint(p.data("volume"),0)||75)),d.videoplaying=!0,s(p,d),u?d.c.trigger("stoptimer"):d.videoplaying=!1,d.c.trigger("revolution.slide.onvideoplay",o(c,"youtube",p.data())),a.togglestate(p.data("videotoggledby"));else{if(0==e.data&&v){var g=t(p.data("videostartat"));-1!=g&&c.seekto(g),c.playvideo(),a.togglestate(p.data("videotoggledby"))}(0==e.data||2==e.data)&&"on"==p.data("showcoveronpause")&&p.find(".tp-videoposter").length>0&&(punchgs.tweenlite.to(p.find(".tp-videoposter"),.3,{autoalpha:1,force3d:"auto",ease:punchgs.power3.easeinout}),punchgs.tweenlite.to(p.find("iframe"),.3,{autoalpha:0,ease:punchgs.power3.easeinout})),-1!=e.data&&3!=e.data&&(d.videoplaying=!1,l(p,d),n.trigger("starttimer"),d.c.trigger("revolution.slide.onvideostop",o(c,"youtube",p.data())),(void 0==d.currentlayervideoisplaying||d.currentlayervideoisplaying.attr("id")==p.attr("id"))&&a.untogglestate(p.data("videotoggledby"))),0==e.data&&1==p.data("nextslideatend")?(p.data("nextslideatend-triggered",1),d.c.revnext(),l(p,d)):(l(p,d),d.videoplaying=!1,n.trigger("starttimer"),d.c.trigger("revolution.slide.onvideostop",o(c,"youtube",p.data())),(void 0==d.currentlayervideoisplaying||d.currentlayervideoisplaying.attr("id")==p.attr("id"))&&a.untogglestate(p.data("videotoggledby")))}},onready:function(e){var a=e.target.getvideoembedcode(),d=jquery("#"+a.split('id="')[1].split('"')[0]),o=d.parent(),r=o.data("videorate");o.data("videostart");if(o.addclass("rs-apiready"),void 0!=r&&e.target.setplaybackrate(parsefloat(r)),o.find(".tp-videoposter").unbind("click"),o.find(".tp-videoposter").click(function(){i||g.playvideo()}),o.data("startvideonow")){o.data("player").playvideo();var n=t(o.data("videostartat"));-1!=n&&o.data("player").seekto(n)}o.data("videolistenerexist",1)}}});e.data("player",g);break;case"vimeo":for(var f,y=n.attr("src"),m={},h=y,b=/([^&=]+)=([^&]*)/g;f=b.exec(h);)m[decodeuricomponent(f[1])]=decodeuricomponent(f[2]);y=void 0!=m.player_id?y.replace(m.player_id,p):y+"&player_id="+p;try{y=y.replace("api=0","api=1")}catch(w){}y+="&api=1",n.attr("src",y);var g=e.find("iframe")[0],t=(jquery("#"+p),$f(p));t.addevent("ready",function(){if(e.addclass("rs-apiready"),t.addevent("play",function(t){e.data("nextslidecalled",0),punchgs.tweenlite.to(e.find(".tp-videoposter"),.3,{autoalpha:0,force3d:"auto",ease:punchgs.power3.easeinout}),punchgs.tweenlite.to(e.find("iframe"),.3,{autoalpha:1,display:"block",ease:punchgs.power3.easeinout}),d.c.trigger("revolution.slide.onvideoplay",o(t,"vimeo",e.data())),d.videoplaying=!0,s(e,d),u?d.c.trigger("stoptimer"):d.videoplaying=!1,"mute"==e.data("volume")||a.lasttogglestate(e.data("videomutetoggledby"))?t.api("setvolume","0"):t.api("setvolume",parseint(e.data("volume"),0)/100||.75),a.togglestate(e.data("videotoggledby"))}),t.addevent("playprogress",function(a){var i=t(e.data("videoendat"));if(e.data("currenttime",a.seconds),0!=i&&math.abs(i-a.seconds)<.3&&i>a.seconds&&1!=e.data("nextslidecalled"))if(v){t.api("play");var o=t(e.data("videostartat"));-1!=o&&t.api("seekto",o)}else 1==e.data("nextslideatend")&&(e.data("nextslideatend-triggered",1),e.data("nextslidecalled",1),d.c.revnext()),t.api("pause")}),t.addevent("finish",function(t){l(e,d),d.videoplaying=!1,d.c.trigger("starttimer"),d.c.trigger("revolution.slide.onvideostop",o(t,"vimeo",e.data())),1==e.data("nextslideatend")&&(e.data("nextslideatend-triggered",1),d.c.revnext()),(void 0==d.currentlayervideoisplaying||d.currentlayervideoisplaying.attr("id")==e.attr("id"))&&a.untogglestate(e.data("videotoggledby"))}),t.addevent("pause",function(t){e.find(".tp-videoposter").length>0&&"on"==e.data("showcoveronpause")&&(punchgs.tweenlite.to(e.find(".tp-videoposter"),.3,{autoalpha:1,force3d:"auto",ease:punchgs.power3.easeinout}),punchgs.tweenlite.to(e.find("iframe"),.3,{autoalpha:0,ease:punchgs.power3.easeinout})),d.videoplaying=!1,l(e,d),d.c.trigger("starttimer"),d.c.trigger("revolution.slide.onvideostop",o(t,"vimeo",e.data())),(void 0==d.currentlayervideoisplaying||d.currentlayervideoisplaying.attr("id")==e.attr("id"))&&a.untogglestate(e.data("videotoggledby"))}),e.find(".tp-videoposter").unbind("click"),e.find(".tp-videoposter").click(function(){return i?void 0:(t.api("play"),!1)}),e.data("startvideonow")){t.api("play");var r=t(e.data("videostartat"));-1!=r&&t.api("seekto",r)}e.data("videolistenerexist",1)})}else{var k=t(e.data("videostartat"));switch(e.data("videotype")){case"youtube":r&&(e.data("player").playvideo(),-1!=k&&e.data("player").seekto());break;case"vimeo":if(r){var t=$f(e.find("iframe").attr("id"));t.api("play"),-1!=k&&t.api("seekto",k)}}}},n=function(e,r,n){if(i&&1==e.data("disablevideoonmobile"))return!1;var p=e.find("video"),v=p[0],u=p.parent(),c=e.data("videoloop"),g="loopandnoslidestop"!=c;if(c="loop"==c||"loopandnoslidestop"==c,u.data("metaloaded",1),void 0==p.attr("control")&&(0!=e.find(".tp-video-play-button").length||i||e.append('
 
'),e.find("video, .tp-poster, .tp-video-play-button").click(function(){e.hasclass("videoisplaying")?v.pause():v.play()})),1==e.data("forcecover")||e.hasclass("fullscreenvideo")||1==e.data("bgvideo"))if(1==e.data("forcecover")||1==e.data("bgvideo")){u.addclass("fullcoveredvideo");var f=e.data("aspectratio")||"4:3";a.preparecoveredvideo(f,r,e)}else u.addclass("fullscreenvideo");var y=e.find(".tp-vid-play-pause")[0],m=e.find(".tp-vid-mute")[0],h=e.find(".tp-vid-full-screen")[0],b=e.find(".tp-seek-bar")[0],w=e.find(".tp-volume-bar")[0];void 0!=y&&d(y,"click",function(){1==v.paused?v.play():v.pause()}),void 0!=m&&d(m,"click",function(){0==v.muted?(v.muted=!0,m.innerhtml="unmute"):(v.muted=!1,m.innerhtml="mute")}),void 0!=h&&h&&d(h,"click",function(){v.requestfullscreen?v.requestfullscreen():v.mozrequestfullscreen?v.mozrequestfullscreen():v.webkitrequestfullscreen&&v.webkitrequestfullscreen()}),void 0!=b&&(d(b,"change",function(){var e=v.duration*(b.value/100);v.currenttime=e}),d(b,"mousedown",function(){e.addclass("seekbardragged"),v.pause()}),d(b,"mouseup",function(){e.removeclass("seekbardragged"),v.play()})),d(v,"timeupdate",function(){var a=100/v.duration*v.currenttime,i=t(e.data("videoendat")),d=v.currenttime;if(void 0!=b&&(b.value=a),0!=i&&-1!=i&&math.abs(i-d)<=.3&&i>d&&1!=e.data("nextslidecalled"))if(c){v.play();var o=t(e.data("videostartat"));-1!=o&&(v.currenttime=o)}else 1==e.data("nextslideatend")&&(e.data("nextslideatend-triggered",1),e.data("nextslidecalled",1),r.just_called_nextslide_at_htmltimer=!0,r.c.revnext(),settimeout(function(){r.just_called_nextslide_at_htmltimer=!1},1e3)),v.pause()}),void 0!=w&&d(w,"change",function(){v.volume=w.value}),d(v,"play",function(){e.data("nextslidecalled",0),"mute"==e.data("volume")&&(v.muted=!0),e.addclass("videoisplaying"),s(e,r),g?(r.videoplaying=!0,r.c.trigger("stoptimer"),r.c.trigger("revolution.slide.onvideoplay",o(v,"html5",e.data()))):(r.videoplaying=!1,r.c.trigger("starttimer"),r.c.trigger("revolution.slide.onvideostop",o(v,"html5",e.data()))),punchgs.tweenlite.to(e.find(".tp-videoposter"),.3,{autoalpha:0,force3d:"auto",ease:punchgs.power3.easeinout}),punchgs.tweenlite.to(e.find("video"),.3,{autoalpha:1,display:"block",ease:punchgs.power3.easeinout});var t=e.find(".tp-vid-play-pause")[0],i=e.find(".tp-vid-mute")[0];void 0!=t&&(t.innerhtml="pause"),void 0!=i&&v.muted&&(i.innerhtml="unmute"),a.togglestate(e.data("videotoggledby"))}),d(v,"pause",function(){e.find(".tp-videoposter").length>0&&"on"==e.data("showcoveronpause")&&!e.hasclass("seekbardragged")&&(punchgs.tweenlite.to(e.find(".tp-videoposter"),.3,{autoalpha:1,force3d:"auto",ease:punchgs.power3.easeinout}),punchgs.tweenlite.to(e.find("video"),.3,{autoalpha:0,ease:punchgs.power3.easeinout})),e.removeclass("videoisplaying"),r.videoplaying=!1,l(e,r),r.c.trigger("starttimer"),r.c.trigger("revolution.slide.onvideostop",o(v,"html5",e.data()));var t=e.find(".tp-vid-play-pause")[0];void 0!=t&&(t.innerhtml="play"),(void 0==r.currentlayervideoisplaying||r.currentlayervideoisplaying.attr("id")==e.attr("id"))&&a.untogglestate(e.data("videotoggledby"))}),d(v,"ended",function(){l(e,r),r.videoplaying=!1,l(e,r),r.c.trigger("starttimer"),r.c.trigger("revolution.slide.onvideostop",o(v,"html5",e.data())),1==e.data("nextslideatend")&&(1==!r.just_called_nextslide_at_htmltimer&&(e.data("nextslideatend-triggered",1),r.c.revnext(),r.just_called_nextslide_at_htmltimer=!0),settimeout(function(){r.just_called_nextslide_at_htmltimer=!1},1500)),e.removeclass("videoisplaying")})},s=function(e,t){void 0==t.playingvideos&&(t.playingvideos=new array),e.data("stopallvideos")&&void 0!=t.playingvideos&&t.playingvideos.length>0&&(t.lastplayedvideos=jquery.extend(!0,[],t.playingvideos),jquery.each(t.playingvideos,function(e,i){a.stopvideo(i,t)})),t.playingvideos.push(e),t.currentlayervideoisplaying=e},l=function(e,t){void 0!=t.playingvideos&&t.playingvideos.splice(jquery.inarray(e,t.playingvideos),1)}}(jquery);