// ==========================================================
// 右側懸浮小廣告開關
// ==========================================================
;(function($) {
function bellCheck(step) {
if(step % 2) {
$('#idx-ad-right').removeClass('theme-close')
} else {
$('#idx-ad-right').addClass('theme-close')
}
}
let nowBellStep = $('#idx-ad-right').data('step')
bellCheck(nowBellStep)
$('#idx-ad-right').on('click', '.toggle-button', function(e) {
e.preventDefault()
nowBellStep = (nowBellStep + 1) % 2
bellCheck(nowBellStep)
})
})($)
// ==========================================================
// 蓋版廣告功能
// ==========================================================
;(function($) {
if($('.popupAdbox').length) {
$('body').addClass('overflow-hidden')
}
})($)
// ==========================================================
// 天邊廣告功能
// ==========================================================
;(function($) {
if($('.top-adbox').length) {
const wrapper = $('.top-adbox')
wrapper.on('click', '.top-adbox-button', function(e) {
wrapper.toggleClass('in-hidden').attr('tag-status', '2')
})
if(wrapper.attr('tag-status') !== '1') {
wrapper.addClass('in-hidden')
} else {
wrapper.removeClass('in-hidden')
}
}
})($)
// ==========================================================
// 紅眼廣告功能
// ==========================================================
;(function($) {
const slideTarget = $('#slideshow')
if(slideTarget.length && slideTarget.children().length > 1) {
slideTarget.owlCarousel({
items: 1,
dots: true,
margin: 10,
loop: true,
autoplay: true,
autoplayTimeout: 3000,
autoplaySpeed: 1000,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
nav: false,
navText: ['', ''],
responsive: {
0: {
autoplayHoverPause: false,
},
1200: {
autoplayHoverPause: true,
},
},
})
}
})($)
// ==========================================================
// 推薦主題商品切換
// ==========================================================
;(function($) {
const recomWrap = $('.index-recommend')
if(recomWrap.length) {
recomWrap.on('click', '.tag-button', function(e) {
const switchTarget = $(this).data('target')
$(this).parent('.tag-item').addClass('in-active')
.siblings('.tag-item').removeClass('in-active')
$('.content-item[data-id='+ switchTarget + ']').addClass('in-active')
.siblings('.content-item').removeClass('in-active')
$('.banner-item[data-id='+ switchTarget + ']').addClass('in-active')
.siblings('.banner-item').removeClass('in-active')
})
}
})($)
// ==========================================================
// blog function
// ==========================================================
;(function($) {
let blogStep = ''
const parentWrap = $('.index-blogs')
const slideTarget = $('.index-blogs .blog-list')
if(parentWrap.length) {
// 分類切換
parentWrap.on('click', '.tag-link', function(e) {
e.preventDefault()
const target = $(this).attr('href')
$(this).parents('.tag-item').addClass('in-active')
.siblings('.tag-item').removeClass('in-active')
$(target).addClass('in-active')
.siblings('.content-item').removeClass('in-active')
})
// 輪播
$(window).on('resize', function(e) {
if($(this).width() >= 768 && blogStep !== 'desktop') {
blogStep = 'desktop'
slideTarget.each(function(i, ele) {
if($(ele).children().length > 3) {
$(ele).owlCarousel({
margin: 20,
nav: true,
dots: false,
navText: ['', ''],
responsive: {
0: {
items: 4,
},
1200: {
items: 3,
},
},
})
}
});
} else if($(this).width() < 768 && blogStep !== 'mobile') {
blogStep = 'mobile'
slideTarget.each(function(i, ele) {
if($(ele).data('owl.carousel')) {
$(ele).data('owl.carousel').destroy()
}
});
}
})
}
})($)
// ==========================================================
// 商品櫥窗快速購物區塊
// ==========================================================
// ;(function($) {
// if($('.showcase').length) {
// let showcaseStep = true
// $('body').on('mouseenter', '.showcase .HoverShopcart', function(e) {
// e.preventDefault()
// const appendTarget = $(this).parents('.item')
// if(showcaseStep) {
// showcaseStep = false
// jQuery.ajax({
// url: Project_Country+'ajax/ajax_showcase_shopbox.php',
// type: 'POST',
// dataType: 'HTML',
// cache: false,
// async: true,
// data: {
// sid: $(this).attr('sid'),
// },
// })
// .done(function(res) {
// appendTarget.append(res)
// })
// .fail(function(x, y, z) {
// console.log(x);
// })
// .always(function() {
// showcaseStep = true
// });
// }
// }).on('mouseleave', '.showcase .item', function(e) {
// e.preventDefault()
// $(this).find('.hover-cart').remove()
// })
// }
// })($)
// ==========================================================
// 影音購物輪播
// ==========================================================
;(function($) {
const videoSlide = $('.video-area .wrapper')
if(videoSlide.children('.item').length > 1) {
videoSlide.owlCarousel({
nav: false,
loop: true,
margin: 20,
dots: true,
items: 1,
autoplay: true,
autoplayHoverPause: true,
autoplayTimeout: 5000,
autoplaySpeed: 1000,
animateIn: 'fadeIn',
animateOut: 'fadeOut',
})
}
})($)
// ==========================================================
// 最新消息輪播
// ==========================================================
;(function($) {
const newsSlide = $('.news-list .wrapper')
if(newsSlide.children('.item').length > 0) {
newsSlide.owlCarousel({
nav: true,
loop: true,
dots: false,
navText: ['', ''],
responsive: {
0: {
items: 1,
},
576: {
margin: 12,
items: 2,
},
1200: {
margin: 20,
items: 3,
},
},
})
}
})($)
// ==========================================================
// 商品櫥窗、加入購物車彈窗
// ==========================================================
;(function($) {
//商品內容
var file_Obj = new prod_file({
type :'1',
itemBox:'product-detail',
});
file_Obj.init();
})($)
// ==========================================================
// 今日限定區塊腳本
// ==========================================================
;(function($) {
const todaySale = $('.today-sale')
if(todaySale.length) {
// 倒數計時器
todaySale.find('.timerbox').each(function(i, ele) {
const target = $(ele)
function outputFunc(input) {
target.html(input)
}
CountDown(target, outputFunc)
});
}
})($)
// ==========================================================
// 品牌介紹輪撥設定
// ==========================================================
;(function($) {
const slideTarget = $('.index-servicebox .index-brands')
if(slideTarget.length > 0 && slideTarget.children().length > 2) {
slideTarget.owlCarousel({
nav: true,
dots: false,
navText: ['', ''],
responsive: {
0: {
margin: 10,
items: 2,
},
576: {
margin: 10,
items: 3,
},
768: {
margin: 10,
items: 5,
},
1200: {
margin: 20,
items: 5,
},
}
})
}
})($)
// ==========================================================
// trigger function
// ==========================================================
;(function($) {
$(window).triggerAll('scroll resize')
})($)