// ========================================================== // 右側懸浮小廣告開關 // ========================================================== ;(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: 8000, autoplayHoverPause: true, autoplaySpeed: 1000, animateOut: 'fadeOut', animateIn: 'fadeIn', nav: false, navText: ['', ''], }) } })($) // ========================================================== // 三個小廣告輪播 // ========================================================== ;(function($) { let adBoxStep = '' const slideTarget = $('.adbox-03 .adbox-wrapper') if(slideTarget.length) { $(window).on('resize', function(e) { if($(this).width() >= 768 && adBoxStep !== 'desktop') { adBoxStep = 'desktop' if(slideTarget.data('owl.carousel')) { slideTarget.data('owl.carousel').destroy() } } else if($(this).width() < 768 && adBoxStep !== 'mobile') { adBoxStep = 'mobile' if(slideTarget.children('.adbox-item').length > 1) { slideTarget.owlCarousel({ items: 1, nav: true, navText: ['', ''], loop: true, dots: false, margin: 20, }) } } }) } })($) // ========================================================== // 推薦主題商品切換 // ========================================================== ;(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($) { //商品內容 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, }, } }) } })($) // ========================================================== // 分類購物輪播 // ========================================================== ;(function($) { let categoryStep = '' const targetCarousel = $('.index-category .category-list') if(targetCarousel.length) { $(window).on('resize', function(e) { if($(this).width() < 768 && categoryStep !== 'mobile') { categoryStep = 'mobile' if(targetCarousel.data('owl.carousel')) { targetCarousel.data('owl.carousel').destroy() } } else if($(this).width() >= 768 && categoryStep !== 'desktop') { categoryStep = 'desktop' if(targetCarousel.children().length > 5) { targetCarousel.owlCarousel({ items: 5, nav: true, dots: false, navText: ['', ''], responsive: { 0: { margin: 15, }, 1200: { margin: 20, }, }, }) } } }) } })($) // ========================================================== // trigger function // ========================================================== ;(function($) { $(window).triggerAll('scroll resize') })($)