// ==========================================================
// 右側懸浮小廣告開關
// ==========================================================
;(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($('.index-popup-wrapper').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')
wrapper.remove()
// $.ajax({
// type:"POST",
// url:Project_Country+'ajax/ajax_hide_skyrim.php',
// })
} else {
wrapper.removeClass('in-hidden')
}
}
})($)
// ==========================================================
// 跳窗顯示
// ==========================================================
// ;(function($) {
// const wrapper = $('.index-popup-wrapper')
// if(wrapper.length) {
//
// wrapper.on('click', '.index-popup-closer', function(e) {
// $.ajax({
// type:"POST",
// url:Project_Country+'ajax/ajax_hide_index_popup.php',
// })
// })
// }
// })($)
// ==========================================================
// 紅眼廣告功能
// ==========================================================
;(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,
autoplaySpeed: 1000,
animateOut: 'fadeOut',
animateIn: 'fadeIn',
nav: true,
navText: ['', ''],
responsive: {
0: {
autoplayHoverPause: false,
},
1200: {
autoplayHoverPause: true,
},
},
})
}
})($)
// ==========================================================
// 推薦主題商品
// ==========================================================
;(function($) {
const block = $(".index-recommend")
if(block.length) {
block.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')
updateSwiper($('.content-item[data-id='+ switchTarget + ']'))
})
}
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this.find('.content-item.in-active'))
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 2.5,
spaceBetween: 12
},
768: {
slidesPerView: 1,
spaceBetween: 0
},
1200: {
slidesPerView: 1,
spaceBetween: 0
}
},
})
}
function updateSwiper(parent){
const viewWidth = window.innerWidth
let groupSize
let swiperTarget = parent.find(".swiper")
if(viewWidth >= 768){
groupSize = 6
}else {
groupSize = 1
}
if(swiperTarget.swiper){
swiperTarget.swiper.destroy(true, true)
}
groupItems(parent.find('.swiper-wrapper'), groupSize)
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
})($)
// ==========================================================
// blog function
// ==========================================================
;(function($) {
const block = $(".index-blogs")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
initSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 1,
spaceBetween: 16
},
675: {
slidesPerView: 2,
spaceBetween: 16
},
1200: {
slidesPerView: 2,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 675){
checkToolbar(parent, toolbar, 1)
}else {
checkToolbar(parent, toolbar, 2)
}
}
})($)
// ==========================================================
// 型錄廣告 function
// ==========================================================
;(function($) {
const block = $(".index-lookbook")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
initSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
effect: 'fade',
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
on: {
init: function(){
checkToolbar(parent, parent.find(".swiper-toolbar"), 1)
},
}
})
}
})($)
// ==========================================================
// 商品櫥窗快速購物區塊
// ==========================================================
// ;(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 block = $(".video-area")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
slidesPerView: 1,
centeredSlides: false,
spaceBetween: 0,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
})
}
function updateSwiper(parent){
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
})($)
// ==========================================================
// 抵用券輪播
// ==========================================================
;(function($) {
const block = $(".index-coupon")
block.each(function(){
const _this = $(this)
initSwiper(_this)
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 1,
spaceBetween: 12
},
675: {
slidesPerView: 2,
spaceBetween: 16
},
1200: {
slidesPerView: 3,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 675){
checkToolbar(parent, toolbar, 1)
}else if($(window).width() >= 768 && $(window).width() < 1200) {
checkToolbar(parent, toolbar, 2)
}else {
checkToolbar(parent, toolbar, 3)
}
}
})($)
// ==========================================================
// 主題圖標輪播
// ==========================================================
;(function($) {
const block = $(".index-theme-list")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
slidesPerView: 1,
centeredSlides: false,
spaceBetween: 0,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
breakpoints: {
0: {
slidesPerView: 3,
spaceBetween: 24
},
576: {
slidesPerView: 3,
spaceBetween: 40
},
768: {
slidesPerView: 4,
spaceBetween: 45
},
1200: {
slidesPerView: 5,
spaceBetween: 50
},
1600: {
slidesPerView: 6,
spaceBetween: 70
}
},
// pagination: {
// el: parent.find('.swiper-pagination')[0],
// clickable: true
// },
})
}
function updateSwiper(parent){
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
})($)
// ==========================================================
// 商品櫥窗、加入購物車彈窗
// ==========================================================
;(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')
})($)
// ==========================================================
// 分類購物輪播
// ==========================================================
;(function($) {
const block = $(".index-category")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
swiper = new Swiper(parent.find('.swiper')[0], {
loop:false,
centeredSlides: false,
slidesPerView: 1,
spaceBetween: 0,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
})
}
function updateSwiper(parent){
const viewWidth = window.innerWidth
let groupSize
let swiperTarget = parent.find(".swiper")
if(viewWidth > 1199){
groupSize = 10
}else {
groupSize = 6
}
if(swiperTarget.swiper){
swiperTarget.swiper.destroy(true, true)
}
groupItems(parent.find('.swiper-wrapper'), groupSize)
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
})($)
// ==========================================================
// 熱銷商品輪播
// 獨家販售輪播
// ==========================================================
;(function($) {
const block = $(".oneline-fiveitem-01,.oneline-fiveitem-02")
block.each(function(){
const _this = $(this)
initSwiper(_this)
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 2.5,
spaceBetween: 12
},
675: {
slidesPerView: 3.5,
spaceBetween: 16
},
1200: {
slidesPerView: 4,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 675){
checkToolbar(parent, toolbar, 2.5)
}else if($(window).width() >= 675 && $(window).width() < 1200) {
checkToolbar(parent, toolbar, 3.5)
}else {
checkToolbar(parent, toolbar, 4)
}
}
})($)
// ==========================================================
// ig輪播
// ==========================================================
;(function($) {
const block = $(".index-ig-list")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
swiper = new Swiper(parent.find('.swiper')[0], {
loop:false,
centeredSlides: false,
slidesPerView: 1,
spaceBetween: 0,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
})
}
function updateSwiper(parent){
const viewWidth = window.innerWidth
let groupSize
let swiperTarget = parent.find(".swiper")
if(viewWidth > 992){
groupSize = 8
}else {
groupSize = 4
}
if(swiperTarget.swiper){
swiperTarget.swiper.destroy(true, true)
}
groupItems(parent.find('.swiper-wrapper'), groupSize)
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
})($)
// ==========================================================
// 好評分享輪播
// ==========================================================
;(function($) {
const block = $(".index-review-google")
block.each(function(){
const _this = $(this)
initSwiper(_this)
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 1,
spaceBetween: 12
},
576: {
slidesPerView: 2,
spaceBetween: 16
},
768: {
slidesPerView: 3,
spaceBetween: 16
},
1200: {
slidesPerView: 3,
spaceBetween: 20
}
},
on: {
init: function(){
updateToolbar(parent)
},
resize: function(){
updateToolbar(parent)
}
}
})
}
function updateToolbar(parent){
let toolbar = parent.find(".swiper-toolbar")
if($(window).width() < 576){
checkToolbar(parent, toolbar, 1)
}else if($(window).width() < 768) {
checkToolbar(parent, toolbar, 2)
}else {
checkToolbar(parent, toolbar, 3)
}
}
})($)
// ==========================================================
// 新品上市輪播
// ==========================================================
;(function($) {
const block = $(".new-arrivals")
block.each(function(){
const _this = $(this)
$(window).on("resize", function(){
updateSwiper(_this)
})
})
function initSwiper(parent){
const swiper = new Swiper(parent.find('.swiper')[0] , {
loop:false,
centeredSlides: false,
navigation: {
nextEl: parent.find('.swiper-button-next')[0],
prevEl: parent.find('.swiper-button-prev')[0],
},
pagination: {
el: parent.find('.swiper-pagination')[0],
clickable: true
},
breakpoints: {
0: {
slidesPerView: 2.5,
spaceBetween: 12
},
675: {
slidesPerView: 1,
spaceBetween: 0
},
1200: {
slidesPerView: 1,
spaceBetween: 0
}
},
})
}
function updateSwiper(parent){
const viewWidth = window.innerWidth
let groupSize
let swiperTarget = parent.find(".swiper")
if(viewWidth > 1199){
groupSize = 8
}else if(viewWidth >= 768 && viewWidth <= 1199){
groupSize = 9
}else {
groupSize = 1
}
if(swiperTarget.swiper){
swiperTarget.swiper.destroy(true, true)
}
groupItems(parent.find('.swiper-wrapper'), groupSize)
checkToolbar(parent, parent.find('.swiper-toolbar'), 1)
initSwiper(parent)
}
})($)
// ==========================================================
// trigger function
// ==========================================================
;(function($) {
$(window).triggerAll('scroll resize')
})($)