// ========================================================== // 單書頁、活動頁腳本 // ========================================================== ;(function($) { let footStep = '' const footerSlide = $(".footer-slide") function footSetting(amount) { if(footerSlide.data('owl.carousel')) { footerSlide.data('owl.carousel').destroy() } console.log(typeof(amount), amount) if(footerSlide.length && footerSlide.children().length > amount) { footerSlide.owlCarousel({ autoplay: true, autoplaySpeed: 1000, autoplayTimeout: 8000, dots: true, dotsSpeed: 1000, items: amount, margin: 10, nav: false, navSpeed: 1000, navText: ['',''], slideBy: 'page', }); } } $(window).on('resize', function(e) { if($(this).width() > 768 && footStep !== 'desktop') { footStep = 'desktop' footSetting(4) } else if($(this).width() <= 768 && footStep !== 'mobile') { footStep = 'mobile' footSetting(2) } }) $(window).trigger('resize') const owlSlide = $(".slidebox") if(owlSlide.length) { owlSlide.owlCarousel({ items : 1, nav: true, navText : ['',''], dots: false, autoplay:true, navSpeed:1000, autoplayTimeout:8000, autoplaySpeed:1000, dotsSpeed:1000, margin: 10, }); } })($) // ;(function($) { // const mainOffset = $('main').offset().top // $(window).on('scroll', function(e) { // const targetLimit = $(this).scrollTop() > mainOffset - $(this).height() / 2 + $('.share-float').height() / 2 // if(targetLimit) { // $('.share-float').addClass('in-show') // } else { // $('.share-float').removeClass('in-show') // } // }) // $(window).trigger('scroll') // })($) // ========================================================== // 開啟商品購買跳窗 // ========================================================== ;(function($) { function log(obj) { console.log(obj) } $('body').on('click', '.open-amount', function(e) { $(this).parents('.prodList-item').find('.amount-warpper').addClass('in-active') }) $('body').on('click', '.amount-warpper', function(e) { if(e.target === e.currentTarget || e.target === $(this).find('.closer')[0] || $(e.target).hasClass('btn')) { $(this).removeClass('in-active') } }) })($) // ========================================================== // editor 索引化 從common的改來的 邏輯不同 // ========================================================== ;(function ($) { let contentIndexer = $(".special-indexer") if (contentIndexer.length > 0) { contentIndexer.each(function () { let _this = $(this) let h2Index = 1 const result = [] _this.find(".special-index-block").each(function () { const h2Ele = $(this) const h2Text = h2Ele.data("title") const indexFlag = h2Ele.data("indexFlag") console.log(`indexFlag=${indexFlag}`); if (indexFlag == 1) { let h2DataIndex = "h2-" + h2Index h2Ele.attr("data-index", h2DataIndex) result.push({ index: h2DataIndex, text: h2Text }) h2Index++ } }) let h2Html = '' for (id in result) { let h2Item = result[id] h2Html += `
  • ${h2Item.text}
  • ` } if (_this.data('index') == '1') { _this.find(".special-index-block").eq(0).before( `
    【快速導覽】
    `) } }) //展開 $(document).on("click", ".editor-index .index-switch", function () { $(this).parents(".editor-index").toggleClass("theme-collapse") }) //跳轉 $(document).on('click', '.editor-index .index-anchor', function (e) { e.preventDefault() let _this = $(this), target = $('[data-index=' + _this.data("target") + ']') if (target.length > 0) { $('#wrapper').animate({ scrollTop: target.position().top + $(".main_01").position().top + $("#wrapper").scrollTop() - $(".header-01").height() }) } }) } })($)