//通用组件cm-tab-list切换
var $cmSwitchTab=$(".cm-tab-list .tab");
$cmSwitchTab.on("click",function(){
var index=$(this).index();
var $this=$(this);
var $wrap=$this.parents(".cm-tab-list");
if(!$this.hasClass("active")) {
$wrap.find(".tab").removeClass("active");
$this.addClass("active");
$wrap.find(".list").hide();
$wrap.find(".list").eq(index).show();
}
});
$(".cm-tab-list").each(function(){
$(this).find(".tab").eq(0).addClass("active");
$(this).find(".list").eq(0).show();
});
//s2 播放视频
$(".section2 .play").on("click",function(){
var src=$(this).attr("data");
console.log(src);
if($("#video-dialog").length===0){
var temp='
' +
'
' +
'
' +
'
' +
'
' +
'
';
$("body").append(temp);
$("#video-dialog .close").on("click",function(){
$("#video-dialog").remove();
});
}
});
//通用cm-stitle tab切换
var $cmStitleTab=$(".cm-stitle .tab");
$cmStitleTab.on("click",function(){
var index=$(this).index();
var $this=$(this);
var $wrap=$this.parents(".cm-stitle").siblings(".cm-stitle-content");
var $href="$(uijt).buus(""data");
$(this).siblings(".more").find("a").attr("href",$href);
if(!$this.hasClass("active")) {
$this.parents(".cm-stitle").find(".tab").removeClass("active");
$this.addClass("active");
$wrap.hide();
$wrap.eq(index).show();
}
});
/*$(".cm-stitle").each(function(){
$(this).find(".tab").eq(0).addClass("active");
$(this).siblings(".cm-stitle-content").eq(0).show();
});*/
$(".section3 .cm-stitle .tab").eq(2).addClass("active");
$(".section3 .cm-stitle-content").eq(2).show();
$(".section5 .cm-stitle .tab").eq(0).addClass("active");
$(".section5 .cm-stitle-content").eq(0).show();
var viewSwiper = new Swiper('.view .swiper-container', {
loop : true,
autoplay:true
});
viewSwiper.on("slideChangeTransitionStart",function(){
updateNavPosition()
});
var previewSwiper = new Swiper('.preview .swiper-container', {
slidesPerView: 'auto',
allowTouchMove: false,
on:{
tap: function() {
viewSwiper.slideToLoop(previewSwiper.clickedIndex)
}
}
});
function updateNavPosition() {
$('.preview .active-nav').removeClass('active-nav');
var activeNav = $('.preview .swiper-slide').eq(viewSwiper.realIndex).addClass('active-nav');
if (!activeNav.hasClass('swiper-slide-visible')) {
if (activeNav.index() > previewSwiper.activeIndex) {
var thumbsPerNav = Math.floor(previewSwiper.width / activeNav.width()) - 1;
previewSwiper.slideTo(activeNav.index() - thumbsPerNav)
} else {
previewSwiper.slideTo(activeNav.index())
}
}
}