asiaH3/modules/ad_banner/_ad_banner_widget2_video.ht...

112 lines
4.5 KiB
Plaintext
Raw Normal View History

2021-05-03 02:01:18 +00:00
<div class="w-ba-banner ba-banner-widget-1 ba-banner-widget-youtube">
2021-04-19 02:10:17 +00:00
<div class="w-ba-banner__wrap cycle-slideshow"
data-list="images"
data-level="0"
data-cycle-slides=".w-ba-banner__slide"
data-cycle-log="false"
2021-05-03 02:01:18 +00:00
data-overlay=".w-ad-banner__overlay_{{subpart-id}}"
data-overlay-template="<h2><span>{{title}}</span></h2>{{desc}}"
2021-04-19 02:10:17 +00:00
data-cycle-auto-height="{{base_image}}"
data-cycle-speed="{{speed}}"
data-cycle-timeout="{{timeout}}"
data-cycle-fx="{{ad_fx}}"
2021-05-03 02:01:18 +00:00
data-pager=".banner_caption_{{subpart-id}}"
data-pager-template="<li><button></button></li>"
2021-04-19 02:10:17 +00:00
data-pager-active-class="active-slide"
data-cycle-youtube="true"
2021-05-03 02:01:18 +00:00
data-cycle-youtube-autostart="false"
data-cycle-swipe="true"
data-cycle-prev=".banner_prev"
data-cycle-next=".banner_next"
data-cycle-pause-on-hover="true"
style="padding-bottom: 56.25%;"
>
2021-04-19 02:10:17 +00:00
{{html}}
</div>
2021-05-03 02:01:18 +00:00
<div class="ad-overlay w-ad-banner__overlay_{{subpart-id}}"></div>
<div class="w-ba-banner__caption banner-pager banner_caption_{{subpart-id}}"></div>
<ul class="controlplay"><a class="resume-slide active" title = "<%= (I18n.locale.to_s =="zh_tw") ? "繼續播放" : "resume" %>"><i></i></a><a class="pause-slide" title = "<%= (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"%>"><i></i></a></ul>
<ul class="button-mid">
<i class="fa fa-angle-left prev-button" aria-hidden="true" title = "<%= (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev" %>"></i>
<i class="fa fa-angle-right next-button" aria-hidden="true" title = "<%= (I18n.locale.to_s =="zh_tw") ? "下一張" : "next" %>"></i>
</ul>
</div>
2021-04-19 02:10:17 +00:00
</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){
2021-05-03 02:01:18 +00:00
var iframe = $(event.target.h),
2021-04-19 02:10:17 +00:00
cyclediv = iframe.parents("div.cycle-slideshow");
2021-05-03 02:01:18 +00:00
var widget = cyclediv.parents('.ba-banner-widget-youtube')
2021-04-19 02:10:17 +00:00
if(event.data == YT.PlayerState.PLAYING || event.data == YT.PlayerState.BUFFERING){
cyclediv.cycle("pause");
2021-05-03 02:01:18 +00:00
widget.find('.banner-pager,.controlplay,.button-mid,.ad-overlay').css('visibility','hidden')
2021-04-19 02:10:17 +00:00
}else if(event.data == YT.PlayerState.PAUSED || event.data == YT.PlayerState.ENDED){
cyclediv.cycle("resume");
2021-05-03 02:01:18 +00:00
widget.find('.banner-pager,.controlplay,.button-mid,.ad-overlay').css('visibility','')
2021-04-19 02:10:17 +00:00
}
}
2021-05-03 02:01:18 +00:00
$(document).ready(function(){
window.onYouTubePlayerAPIReady = function() {
onYouTubeIframeAPIReady();
};
$('.pause-slide').off('click').click(function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('pause');
$(this).addClass('active')
$(this).parents('.controlplay').eq(0).find('.resume-slide').removeClass('active')
});
$('.resume-slide').off('click').click(function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('resume');
$(this).addClass('active')
$(this).parents('.controlplay').eq(0).find('.pause-slide').removeClass('active')
});
$('.next-button').off('click').on('click',function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("next");
})
$('.prev-button').off('click').on('click',function(){
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("prev");
})
})
2021-04-19 02:10:17 +00:00
}
2021-05-03 02:01:18 +00:00
</script>
<style type="text/css">
.controlplay .resume-slide.active i{
color: #32D9C3;
}
.controlplay .pause-slide.active i{
color: #ff4500;
}
</style>