// ========================================================== // 首頁天邊廣告 // ========================================================== ;(function($) { $('body').on('click', '.top-adbox-button', function(e) { $(this).parents('.top-adbox').toggleClass('in-hidden'); }) })($) // ========================================================== // 紅眼廣告 // ========================================================== ;(function($) { // 首頁主廣告 if($("#slideshow .slide-item").length > 1){ $("#slideshow").owlCarousel({ loop : true, items : 1, nav : true, navText : ['',''], dots:false, animateOut:'fadeOut', autoplay:true, autoplayTimeout:9500, autoplayHoverPause: true, autoaplaySpeed: 1000, margin: 10, }); } })($) // ========================================================== // 最新消息跑馬燈 // ========================================================== ;(function($) { if($('.news-marquee').length) { $('.news-marquee').each(function(i, ele) { if($(ele).children().length > 1) { $(ele).owlCarousel({ autoplay: true, autoplayHoverPause: true, autoplaySpeed: 1500, autoplayTimeout: 5000, dots: false, items: 1, loop: true, margin: 10, nav: false, navText: ['', ''], }) } }) } })($) // ========================================================== // 輪播型 3 個小廣告 // ========================================================== ;(function($) { let adboxStep = '' $(window).on('resize', function(e) { if(adboxStep !== 'desktop' && $(this).width() >= 992) { adboxStep = 'desktop' $('.adbox-slider > .inner').each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }); } else if(adboxStep !== 'mobile' && $(this).width() < 992) { adboxStep = 'mobile' $('.adbox-slider > .inner').each(function(i, ele) { if($(ele).children().length > 1) { $(ele).owlCarousel({ items: 1, nav: true, dots: false, margin: 10, }) } }); } }) })($) // ========================================================== // 今日限定 // ========================================================== ;(function($) { if($('.todaySale').length) { $(".todaySale").find('.wrapper').owlCarousel({ nav: true, loop: true, dots: false, margin: 20, responsive: { 0: { items: 1, stagePadding: 50, }, 576: { items: 2, stagePadding: 60, }, 768: { items: 3, stagePadding: 0, }, } }) $(".todaySale").find('.timerbox').each(function(i, ele) { function zeroPad(number) { let returnString = '' if(number < 10) { returnString = '0' + number } else { returnString = String(number) } return returnString } function counter() { const limit = parseInt($(ele).attr('second')) const leftTime = (limit > 0)? limit: 0; const nowSec = leftTime % 60 const nowMin = Math.floor(leftTime / 60) % 60 const nowHour = Math.floor(leftTime / 60 / 60) $(ele).find('.timer').text(`${zeroPad(nowHour)} : ${zeroPad(nowMin)} : ${zeroPad(nowSec)}`) $(ele).attr('second', limit - 1) if(leftTime > 0) { setTimeout(counter, 1000) } } counter() }) } })($) // ========================================================== // 推薦主題商品 // ========================================================== ;(function($) { $('.tags-001').on('click', '.label-item', function(e) { e.preventDefault() const switchTarget = $(this).attr('href') $(this).addClass('in-active') .siblings('.label-item').removeClass('in-active') $(switchTarget).addClass('in-active') .siblings('.content-item').removeClass('in-active') }) let tagStep = '' $(window).on('resize', function(e) { if($(this).width() >= 992 && tagStep !== 'desktop') { tagStep = 'desktop' $('.tags-001').find('.content-item').each(function(i, ele) { $(ele).owlCarousel({ margin: 20, dots: false, nav: true, responsive: { 0: { items: 4, }, 1380: { items: 5, }, } }) }) } else if($(this).width() < 992 && tagStep !== 'mobile') { tagStep = 'mobile' $('.tags-001').find('.content-item').each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }) } }) })($) // ========================================================== // 新品上市 // ========================================================== ;(function($) { let newStep = '' $(window).on('resize', function(e) { if($(this).width() >= 992 && newStep !== 'desktop') { newStep = 'desktop' if($('.new-arrivals .wrapper').data('owl.carousel')) { $('.new-arrivals .wrapper').data('owl.carousel').destroy() } const $item = $('.new-arrivals .wrapper').children('.item') $item.each(function(i, ele) { $(ele).attr('data-group', Math.floor(i / 2)) }) for (let i = 0; i < Math.ceil($item.length / 2); i++) { $('.new-arrivals .wrapper').children(`.item[data-group="${i}"]`).wrapAll(`
`) } $('.new-arrivals .wrapper').owlCarousel({ dots: false, nav: true, margin: 20, responsive: { 0: { items: 2 }, 1380: { items: 3 }, } }) } else if($(this).width() < 992 && newStep !== 'mobile') { newStep = 'mobile' if($('.new-arrivals .wrapper').data('owl.carousel')) { $('.new-arrivals .wrapper').data('owl.carousel').destroy() } $('.new-arrivals .wrapper').find('.item-group > .item').unwrap() $('.new-arrivals .wrapper').find('.item').each(function(i, ele) { $(ele).removeAttr('data-group') }) $('.new-arrivals .wrapper').owlCarousel({ dots: false, nav: true, margin: 20, loop: true, responsive: { 0: { items: 1, stagePadding: 50, }, 576: { items: 2, stagePadding: 60, }, 768: { items: 3, stagePadding: 0, }, } }) } }) })($) // ========================================================== // 右側懸浮小廣告開關 // ========================================================== ;(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) }) })($) // ========================================================== // lookbook 相關 function // ========================================================== ;(function($) { $('.lookbook .wrapper').owlCarousel({ items: 1, nav: true, dots: true, loop: true, autoplayTimeout: 8000, autoplay: true, autoplayHoverPause: true, autoplaySpeed: 1000, animateOut: 'fadeOut', animateIn: 'fadeIn', dotsData: true, }) })($) // ========================================================== // 影音購物、直播間 // ========================================================== ;(function($) { $('.video-area, .live-rooms').on('click', '.link', function(e) { e.preventDefault() const targetVID = $(this).attr('data-vid') const targetType = $(this).attr('data-type') let videoChild = '' switch(targetType) { case 'youtube': default: videoChild = `` break; case 'facebook': videoChild = `` break; } $(this).parents('.responsive-embed').html(videoChild) }) // 影音購物 $('.video-area .wrapper').owlCarousel({ margin: 20, dots: false, nav: true, responsive: { 0: { items: 1, }, 768: { items: 2, } } }) // 直播間 $('.live-rooms .wrapper').owlCarousel({ margin: 20, dots: false, nav: true, responsive: { 0: { items: 1, }, 768: { items: 2, }, 1560: { items: 3, } } }) })($) // ========================================================== // 自定義連結區塊 // ========================================================== ;(function($) { $('.customize-links .links-wrapper').owlCarousel({ dots: false, nav: true, loop: true, margin: 20, responsive: { 0: { items: 2, }, 768: { items: 3, }, 1200: { items: 4, }, } }) })($) // ========================================================== // brands hover function // ========================================================== ;(function($) { $('.index-servicebox').on('mouseenter', '.index-brands .link', function(e) { const desktopImg = $(this).attr('data-desktop') const mobileImg = $(this).attr('data-mobile'); $(this).parents('.index-servicebox') .find('.brands-banner source').attr('srcset', desktopImg) .end() .find('.brands-banner .image').attr('srcset', mobileImg) }) })($) // ========================================================== // 育兒知識、使用評價手機版輪播功能 // ========================================================== ;(function($) { const owlTarget = $('.index-blogs .wrapper, .review-001 .wrapper') let owlStep = '' $(window).on('resize', function(e) { if($(this).width() >= 768 && owlStep !== 'desktop') { owlStep = 'desktop' owlTarget.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }) } else if($(this).width() < 768 && owlStep !== 'mobile') { owlStep = 'mobile' owlTarget.each(function(i, ele) { if($(ele).length && $(ele).children().length > 1) { $(ele).owlCarousel({ nav: true, dots: false, navText: ['', ''], margin: 20, loop: true, responsive: { 0: { items: 1, }, 576: { items: 2, }, }, }) } }) } }) })($) // ========================================================== // trigger function // ========================================================== ;(function($) { $(window).triggerAll('scroll resize') })($)