// ========================================================== // 避免商品列表內操作後導致滑動 // ========================================================== ;(function($) { $(document).on("pointerdown", ".swiper .index-product-list", function(e){ e.preventDefault() }) })($) // ========================================================== // 蓋版廣告功能 // ========================================================== ;(function($) { if($('.index-popup-wrapper').length) { $('body').addClass('overflow-hidden') } })($) // ========================================================== // 天邊廣告功能 // ========================================================== ;(function($) { if($('.top-featurebox').length) { const wrapper = $('.top-featurebox') const key = "topFeatureLastShown" const today = new Date().toISOString().split("T")[0] const lastShown = localStorage.getItem(key) if(lastShown === today){ wrapper.addClass('in-hidden') }else{ wrapper.removeClass('in-hidden') localStorage.setItem(key, today) } $(document).on('click', '.top-featurebox', function(e) { if($(e.target).closest(".top-featurebox-background").length || $(e.target).closest(".top-featurebox-button").length){ if(wrapper.hasClass('in-hidden')){ wrapper.removeClass("in-hidden") }else{ wrapper.addClass("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 slideTarget = $('.featurebox-01 .featurebox-wrapper') slideTarget.each(function(){ let _this = $(this) if(_this.length && _this.children().length > 1) { _this.owlCarousel({ items: 1, dots: true, margin: 10, loop: true, autoplay: true, autoplayTimeout: 8000, autoplaySpeed: 1000, animateOut: 'fadeOut', animateIn: 'fadeIn', nav: true, navText: ['', ''], }) } }) })($) // ========================================================== // 三個廣告功能 // ========================================================== // ;(function($) { // const block = $(".featurebox-03") // block.each(function(){ // const _this = $(this) // $(window).on("resize", function(){ // updateSwiper(_this) // }) // }) // function initSwiper(parent){ // if(!parent.length){ // return // } // const swiper = new Swiper(parent.find('.swiper')[0] , { // loop:false, // centeredSlides: false, // touchReleaseOnEdges: true, // passiveListeners: true, // navigation: { // nextEl: parent.find('.swiper-button-next')[0], // prevEl: parent.find('.swiper-button-prev')[0], // }, // pagination: { // el: parent.find('.swiper-pagination')[0], // clickable: true // }, // slidesPerView: 1, // spaceBetween: 12, // }) // } // function updateSwiper(parent){ // let swiperTarget = parent.find(".swiper") // let groupSize = null // if($(window).width() < 576){ // groupSize = 1 // }else { // groupSize = 0 // } // if(swiperTarget[0]?.swiper && (swiperTarget.data("group-size") !== groupSize)){ // swiperTarget[0].swiper.destroy(true, true) // } // let toolbar = parent.find(".swiper-toolbar") // if($(window).width() < 576){ // if(swiperTarget.data("group-size") !== groupSize){ // initSwiper(parent) // checkToolbar(parent, toolbar, 1) // } // }else { // toolbar.addClass("hide") // } // swiperTarget.data("group-size", groupSize) // } // })($) // ========================================================== // 四個廣告功能 // ========================================================== ;(function($) { const block = $(".featurebox-04") block.each(function(){ const _this = $(this) $(window).on("resize", function(){ updateSwiper(_this) }) }) function initSwiper(parent){ if(!parent.length){ return } const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, navigation: { nextEl: parent.find('.swiper-button-next')[0], prevEl: parent.find('.swiper-button-prev')[0], }, pagination: { el: parent.find('.swiper-pagination')[0], clickable: true }, slidesPerView: 1, spaceBetween: 12, }) } function updateSwiper(parent){ let swiperTarget = parent.find(".swiper") let groupSize = null if($(window).width() < 576){ groupSize = 1 }else { groupSize = 0 } if(swiperTarget[0]?.swiper && (swiperTarget.data("group-size") !== groupSize)){ swiperTarget[0].swiper.destroy(true, true) } let toolbar = parent.find(".swiper-toolbar") if($(window).width() < 576){ if(swiperTarget.data("group-size") !== groupSize){ initSwiper(parent) checkToolbar(parent, toolbar, 1) } }else { toolbar.addClass("hide") } swiperTarget.data("group-size", groupSize) } })($) // ========================================================== // 推薦主題商品 // ========================================================== ;(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') initSwiper($('.content-item[data-id='+ switchTarget + ']')) }) } block.each(function(){ const _this = $(this) $(window).on("resize", function(){ initSwiper(_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, spaceBetween: 12 }, 675: { slidesPerView: 4, 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) }else if($(window).width() >= 675 && $(window).width() < 1200) { checkToolbar(parent, toolbar, 4) }else { checkToolbar(parent, toolbar, 4) } } })($) // ========================================================== // blog function // ========================================================== ;(function($) { const block = $(".index-blogs") block.each(function(){ const _this = $(this) updateSwiper(_this) $(window).on("resize", function(){ updateSwiper(_this) }) }) function initSwiper(parent){ if(!parent.length){ return } const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, 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, spaceBetween: 12 }, 576: { slidesPerView: 2, spaceBetween: 12 }, 768: { slidesPerView: 4, spaceBetween: 16 }, 1200: { slidesPerView: 4, spaceBetween: 20 } }, }) } function updateSwiper(parent){ let swiperTarget = parent.find(".swiper") let toolbar = parent.find(".swiper-toolbar") if($(window).width() >= 768){ if(!swiperTarget[0]?.swiper){ initSwiper(parent) checkToolbar(parent, toolbar, 4) } }else { if(swiperTarget[0]?.swiper){ swiperTarget[0].swiper.destroy(true, true) } toolbar.addClass("hide") } } })($) // ========================================================== // event function // ========================================================== ;(function($) { const block = $(".index-event,.review-001") block.each(function(){ const _this = $(this) $(window).on("resize", function(){ initSwiper(_this) }) }) function initSwiper(parent){ if(!parent.length){ return } const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, 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: (parent.hasClass("theme-long"))?2:2, spaceBetween: 12 }, 675: { slidesPerView: (parent.hasClass("theme-long"))?2:3, spaceBetween: 12 }, 768: { slidesPerView: (parent.hasClass("theme-long"))?2:4, spaceBetween: 16 }, 1200: { slidesPerView: (parent.hasClass("theme-long"))?2:4, spaceBetween: 20 } }, on: { init: function(){ updateToolbar(parent) }, resize: function(){ updateToolbar(parent) } } }) } function updateToolbar(parent){ let toolbar = parent.find(".swiper-toolbar") if(parent.hasClass("theme-long")){ checkToolbar(parent, toolbar, 2) }else{ if($(window).width() < 675){ checkToolbar(parent, toolbar, 2) }else if($(window).width() < 768){ checkToolbar(parent, toolbar, 3) }else{ checkToolbar(parent, toolbar, 4) } } } })($) // ========================================================== // 型錄廣告 function // ========================================================== ;(function($) { const block = $(".index-lookbook") block.each(function(){ const _this = $(this) initSwiper(_this) }) function initSwiper(parent){ const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, navigation: { nextEl: parent.find('.swiper-button-next')[0], prevEl: parent.find('.swiper-button-prev')[0], }, spaceBetween: 20, 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) initSwiper(_this) }) function initSwiper(parent){ let swiperEle = parent.find('.swiper') let options = { 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 }, on: { init: function(){ updateToolbar(parent) }, resize: function(){ updateToolbar(parent) } } } if(swiperEle.hasClass("theme-four")){ options.breakpoints = { 0: { slidesPerView: 1, spaceBetween: 12 }, 576: { slidesPerView: 2, spaceBetween: 12 }, 768: { slidesPerView: 3, spaceBetween: 16 }, 1200: { slidesPerView: 4, spaceBetween: 20 } } }else if(swiperEle.hasClass("theme-two")){ options.breakpoints = { 0: { slidesPerView: 1, spaceBetween: 12 }, 675: { slidesPerView: 2, spaceBetween: 12 }, 768: { slidesPerView: 2, spaceBetween: 16 }, 1200: { slidesPerView: 2, spaceBetween: 20 } } }else{ options.breakpoints = { 0: { slidesPerView: 1, spaceBetween: 12 }, 768: { slidesPerView: 1, spaceBetween: 16 }, 1200: { slidesPerView: 1, spaceBetween: 20 } } } const swiper = new Swiper(swiperEle[0] , options) } function updateToolbar(parent){ let swiperEle = parent.find('.swiper') let toolbar = parent.find(".swiper-toolbar") if(swiperEle.hasClass("theme-four")){ console.log("aaa") if($(window).width() < 576){ checkToolbar(parent, toolbar, 1) }else if($(window).width() >= 576 && $(window).width() < 768) { checkToolbar(parent, toolbar, 2) }else if($(window).width() >= 768 && $(window).width() < 1200) { checkToolbar(parent, toolbar, 3) }else { checkToolbar(parent, toolbar, 4) } }else if(swiperEle.hasClass("theme-two")){ if($(window).width() < 675){ checkToolbar(parent, toolbar, 1) }else { checkToolbar(parent, toolbar, 2) } }else{ checkToolbar(parent, toolbar, 1) } } })($) // ========================================================== // 抵用券輪播 // ========================================================== ;(function($) { const block = $(".index-coupon") block.each(function(){ const _this = $(this) initSwiper(_this) }) function initSwiper(parent){ if(!parent.length){ return } const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, 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: 'auto', spaceBetween: 12 }, 768: { 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() >= 675 && $(window).width() < 768) { 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){ if(!parent.length){ return } const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, slidesPerView: 1, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, 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) }); //輪播 todaySale.each(function(){ const _this = $(this) initSwiper(_this) }) function initSwiper(parent){ if(!parent.length){ return } 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, spaceBetween: 12 }, 675: { slidesPerView: 3, spaceBetween: 12 }, 768: { slidesPerView: 3, 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) }else if($(window).width() >= 675 && $(window).width() < 1200) { checkToolbar(parent, toolbar, 3) }else { checkToolbar(parent, toolbar, 4) } } } })($) // ========================================================== // 熱銷商品輪播 // 獨家販售輪播 // 新品上市輪播 // ========================================================== ;(function($) { const block = $(".oneline-fiveitem-01,.oneline-fiveitem-02,.new-arrivals") block.each(function(){ const _this = $(this) initSwiper(_this) }) function initSwiper(parent){ const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, navigation: { nextEl: parent.find('.swiper-button-next')[0], prevEl: parent.find('.swiper-button-prev')[0], }, pagination: { el: parent.find('.swiper-pagination')[0], clickable: true }, touchStartPreventDefault: false, breakpoints: { 0: { slidesPerView: 2, spaceBetween: 12 }, 675: { slidesPerView: 4, spaceBetween: 12 }, 768: { slidesPerView: 4, 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) }else if($(window).width() >= 675 && $(window).width() < 1200) { checkToolbar(parent, toolbar, 4) }else { checkToolbar(parent, toolbar, 4) } } })($) // ========================================================== // 櫥窗12輪播 // ========================================================== ;(function($) { const block = $(".showcase-carousel-block") block.each(function(){ const _this = $(this) $(window).on("resize", function(){ initSwiper(_this) }) }) function initSwiper(parent){ if(!parent.length){ return } const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, 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, spaceBetween: 12 }, 576: { slidesPerView: 3, spaceBetween: 12 }, 768: { slidesPerView: 4, spaceBetween: 16 }, 992: { slidesPerView: 5, 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, 2) }else if($(window).width() >= 576 && $(window).width() < 768) { checkToolbar(parent, toolbar, 3) }else if($(window).width() >= 768 && $(window).width() < 992) { checkToolbar(parent, toolbar, 4) }else { checkToolbar(parent, toolbar, 5) } } //加入購物車不要觸發anchor $(document).on("click", ".showcase-012 .showcase-item", function(e){ if($(e.target).closest('.js-quick-add').length > 0){ e.preventDefault() return } }) })($) // ========================================================== // 好評分享輪播 // ========================================================== ;(function($) { const block = $(".index-review-google") block.each(function(){ const _this = $(this) initSwiper(_this) }) function initSwiper(parent){ if(!parent.length){ return } const swiper = new Swiper(parent.find('.swiper')[0] , { loop:false, centeredSlides: false, touchReleaseOnEdges: true, passiveListeners: true, 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, 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() < 768){ checkToolbar(parent, toolbar, 2) }else { checkToolbar(parent, toolbar, 3) } } })($) // ========================================================== // 倒數 // ========================================================== ;(function($) { let blocks = $(".index-countdown .countdown-box") function setTime(box, time){ let day = String(Math.floor(time / 86400)).padStart(2, '0') let hour = String(Math.floor((time % 86400) / 3600)).padStart(2, '0') let minute = String(Math.floor((time % 3600) / 60)).padStart(2, '0') let second = String(Math.floor(time % 60)).padStart(2, '0') box.find(".slot-day").text(day) box.find(".slot-hour").text(hour) box.find(".slot-minute").text(minute) box.find(".slot-second").text(second) } function startCountdown(box){ if(!box.data("endTime")){ const totalSeconds = parseInt(box.data("time"), 10) const endTime = Date.now() + totalSeconds * 1000 box.data("endTime", endTime) } let interval = setInterval(function(){ const diff = Math.ceil((box.data("endTime") - Date.now()) / 1000) const time = Math.max(0, diff) if(time <= 0){ clearInterval(interval) box.parents(".index-countdown ").remove() return } setTime(box, time) }, 1000) } if(blocks.length > 0){ blocks.each(function(){ startCountdown($(this)) }) } })($) // ========================================================== // faq // ========================================================== ;(function($) { $(document).on("click", ".index-faq-list .faq-toggle", function(){ let _this = $(this) let item = _this.parents(".faq-item") let content = item.find(".faq-content") item.toggleClass("in-open") content.slideToggle(250) }) })($) // ========================================================== // trigger function // ========================================================== ;(function($) { $(window).triggerAll('scroll resize') })($)