asiaH1/modules/ad_banner/_ad_banner_widget2_video.ht...

68 lines
2.3 KiB
Plaintext

<div class="w-ba-banner ba-banner-widget-2 ba-banner-widget-youtube">
<div class="w-ba-banner__wrap cycle-slideshow"
data-list="images"
data-level="0"
data-cycle-timeout="3000"
data-cycle-slides=".w-ba-banner__slide"
data-cycle-log="false"
data-overlay="[data-subpart-id='{{subpart-id}}']+.w-ba-banner__caption"
data-cycle-auto-height="{{base_image}}"
data-cycle-speed="{{speed}}"
data-cycle-timeout="{{timeout}}"
data-cycle-fx="{{ad_fx}}"
data-pager="[data-subpart-id='{{subpart-id}}']+.w-ba-banner__pager-2"
data-pager-template="<li><a href='#'></a></li>"
data-pager-active-class="active-slide"
data-cycle-youtube="true"
data-cycle-youtube-autostart="false"
data-subpart-id="{{subpart-id}}">
{{html}}
</div>
<ul class="w-ba-banner__pager-2 banner-pager"></ul>
</div>
<script type="text/javascript">
if (typeof ad_banners_count === 'undefined'){
var ad_banners_count = 0;
}
if(document.getElementById("youtube-iframe-api") == null){
var tag = document.createElement('script');
tag.setAttribute("id", "youtube-iframe-api");
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
$("document").ready(function(){
$("*[data-yt-binded=0]").each(function(){
$(this).attr("data-yt-binded","1");
var obj = $(this).find("iframe");
obj.attr("id",$(this).data("youtube-id") + "_" + ad_banners_count);
ad_banners_count++;
})
});
if (typeof onYouTubeIframeAPIReady !== 'function'){
function onYouTubeIframeAPIReady(){
$(".w-ba-banner iframe[data-yt-api-binded=0]").each(function(){
$(this).attr("data-yt-api-binded","1");
new YT.Player($(this).attr("id"), {
events: {
'onStateChange': onPlayerStateChange
}
});
})
}
function onPlayerStateChange(event){
var iframe = $(event.target.getIframe()),
cyclediv = iframe.parents("div.cycle-slideshow");
if(event.data == YT.PlayerState.PLAYING || event.data == YT.PlayerState.BUFFERING){
cyclediv.cycle("pause");
}else if(event.data == YT.PlayerState.PAUSED || event.data == YT.PlayerState.ENDED){
cyclediv.cycle("resume");
}
}
}
</script>