// ==========================================================
// 右側懸浮小廣告開關
// ==========================================================
;(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($) {
let topAd = $('.top-adbox')
if(topAd.length) {
$(document).on('click', '.top-adbox-button', function(){
$('html, body').animate({
scrollTop: $('.header-wrapper')[0].offsetTop
},500)
})
}
//因應天邊產生的跑馬燈問題
// let marquee = $('.top-marquee')
// if(marquee.length > 0){
// $(window).on('scroll', function(e) {
// //num > null is true
// if($(this).scrollTop() > (topAd.height() + marquee.height())) {
// $("body").addClass('marquee-hide');
// } else {
// $("body").removeClass('marquee-hide');
// }
// })
// }
})($)
// ==========================================================
// 紅眼廣告功能
// ==========================================================
;(function($) {
const slideTarget = $('#slideshow')
if(slideTarget.length && slideTarget.children().length > 1) {
slideTarget.owlCarousel({
items: 1,
dots: true,
margin: 10,
loop: true,
autoplay: true,
autoplayTimeout: 8000,
autoplayHoverPause: true,
autoplaySpeed: 1000,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
nav: false,
navText: ['', ''],
})
}
})($)
// ==========================================================
// 推薦主題商品(商品輪播)切換
// ==========================================================
;(function($) {
const recomWrap = $('.index-recommend-01')
const slideTarget = $('.index-recommend-01 .in-active .content-product')
commonCarouselSmall(slideTarget)
if(recomWrap.length) {
recomWrap.on('click', '.tag-button', function(e) {
const switchTarget = $($(this).attr('data-target'))
$(this).parent('.tag-item').addClass('in-active')
.siblings('.tag-item').removeClass('in-active')
switchTarget.addClass('in-active')
.siblings('.content-item').removeClass('in-active')
if(switchTarget.find('.owl-loaded').length <= 0){
commonCarouselSmall(switchTarget.find('.content-product'))
}
})
}
})($)
// ==========================================================
// 推薦主題商品(廣告輪播)切換
// ==========================================================
;(function($) {
const recomContainer = $('.index-recommend-02')
const slideTarget = $('.index-recommend-02 .ad-carousel')
slideTarget.owlCarousel({
items:1,
dots:false,
nav: true,
navText: ['', ''],
onTranslate: function(e){
let current = e.item.index + 1
recomContainer.find('.ad-page-now').text(current)
},
onTranslated: function(e){
recomContainer.find('.content-item').removeClass('in-active')
$(slideTarget.find('.active .ad-item').data('target')).addClass('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')
})
slideTarget.owlCarousel({
loop:true,
items: 1,
dots: false,
nav: true,
center: true,
navText: ['', ''],
responsive: {
0:{
margin: 0
},
576:{
margin: 15,
stagePadding: 50
},
768:{
margin: 20,
stagePadding: 100
},
1200: {
margin: 20,
stagePadding: 240
},
1400:{
margin: 20,
stagePadding: 350
},
1600: {
margin: 20,
stagePadding: 450
},
1920: {
margin: 20,
stagePadding: 540
}
}
})
}
})($)
// ==========================================================
// 影音購物輪播
// ==========================================================
;(function($) {
const videoSlide = $('.video-area .wrapper')
if(videoSlide.children('.item').length > 1) {
videoSlide.owlCarousel({
nav: false,
loop: true,
margin: 20,
dots: true,
items: 1,
})
}
})($)
// ==========================================================
// ig區塊
// ==========================================================
;(function($) {
const instagramSlide = $('.instagram-list')
function instagramCarousel(){
if($(window).width() >= 576){
instagramSlide.owlCarousel({
margin: 0,
dots: false,
nav: true,
loop: true,
navText: ['', ''],
responsive: {
0: {
items: 3
},
576: {
items: 4
},
768: {
items: 5
},
1200: {
items: 6
},
}
})
}else{
instagramSlide.trigger('destroy.owl.carousel')
}
}
instagramCarousel()
$(window).on('resize', function(){
instagramCarousel()
})
})($)
// ==========================================================
// 好評分享
// ==========================================================
;(function($) {
const reviewSlide = $('.review-001 .wrapper')
if(reviewSlide.children('.review-item').length > 0) {
commonCarouselSmall(reviewSlide)
}
//平版點擊圖片先顯示詳細內容
$(document).on("click", ".review-item .preview-picbox", function(e){
if($(window).width() > 767 && !$("body").hasClass("DeviceWithHover")){
e.preventDefault()
$(this).parents(".review-item").addClass("in-active")
}
})
})($)
// ==========================================================
// 型錄廣告
// ==========================================================
;(function($) {
const lookbookContainer = $('.lookbook'),
lookbookSlide = $('.lookbook .lookbook-carousel')
if(lookbookSlide.find('.lookbook-item').length > 0) {
lookbookSlide.owlCarousel({
items: 1,
nav: true,
dots: false,
navText: ['', ''],
responsive: {
0: {
stagePadding: 0
},
992: {
stagePadding: 50
},
1200: {
stagePadding: 90
},
1400: {
stagePadding: 140
},
1600: {
stagePadding: 220
}
},
onTranslate: function(e){
console.log(e)
let current = e.item.index + 1
lookbookContainer.find('.lookbook-page-now').text(current)
},
})
}
})($)
// ==========================================================
// 商品櫥窗、加入購物車彈窗
// ==========================================================
;(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)
});
todaySale.find('.today-sale-carousel').owlCarousel({
nav: true,
loop: true,
dots: false,
navText: ['', ''],
responsive: {
0: {
margin: 10,
items: 1,
stagePadding: 60
},
576: {
margin: 10,
items: 2,
stagePadding: 80
},
768: {
margin: 12,
items: 2,
stagePadding: 50
},
1200: {
margin: 20,
items: 4,
stagePadding: 0
},
}
})
}
})($)
// ==========================================================
// trigger function
// ==========================================================
;(function($) {
$(window).triggerAll('scroll resize')
})($)