{"version":3,"sources":["src/js/modules/_fn.js","src/js/product_list.js"],"names":["on","target","event","func","option","window","addEventListener","opt","attachEvent","$","document","ww","innerWidth","$el","hasClass","removeClass","this","text","addClass","fixedSwiper","breakpoint","matchMedia","breakpointChecker","matches","undefined","destroy","enableSwiper","_Swiper","swiperTarget","Swiper","_defineProperty","speed","lazy","loadPrevNext","loadPrevNextAmount","slidesPerView","spaceBetween","nextEl","prevEl","1440","updateFixedSwiper"],"mappings":"iJACO,SAASA,EAAGC,EAAQC,EAAOC,EAAMC,GAEvC,GADAH,EAASA,GAAUI,OACfA,OAAOC,iBAAkB,CAC5B,IAAIC,EAAMH,IAAU,EACpBH,EAAOK,iBAAiBJ,EAAOC,EAAMI,QAErCN,EAAOO,YAAY,KAAON,EAAOC,ICLnC,WAuBCM,EAAEC,UAAUV,GAAG,QAAS,yBAA0B,WACjD,IAAIW,EAAKN,OAAOO,WACVC,EAAMJ,EAAE,yBAEVE,EAAK,MACJE,EAAIC,SAAS,YAChBD,EAAIE,YAAY,WAChBN,EAAEO,MAAMC,KAAK,UAEbJ,EAAIK,SAAS,WACbT,EAAEO,MAAMC,KAAK,YAUhB,IAGIE,EAHEC,EAAaf,OAAOgB,WAAW,0BAK/BC,EAAoB,WAEzB,OAAIF,EAAWG,kBAEMC,IAAhBL,GAA2BA,EAAYM,SAAQ,GAAM,IAQlDC,KAIHA,EAAe,WAAY,IAAAC,EAC1BC,EAAe,wBAGrBT,EAAc,IAAIU,OAAOD,EAAe,sBAA1BE,EAAAH,EAAA,CACbI,MAAO,IACPC,KAAM,CACLC,cAAc,EACdC,mBAAoB,GAErBC,cAAe,OACfC,aAAc,IAPD,QAQN,KARMN,EAAAH,EAAA,iBASE,GATFG,EAAAH,EAAA,aAUD,CACXU,OAAQT,EAAe,uBACvBU,OAAQV,EAAe,yBAZXE,EAAAH,EAAA,cAcA,CACZY,KAAM,CACLH,aAAc,MAhBjBT,KAuBD3B,EAAGoB,EAAY,OAAQE,GACvBtB,EAAGoB,EAAY,SAAUE,GAKzBA,IAuBAjB,OAAOmC,kBAAoBrB,EAxH5B","file":"../product_list.min.js","sourcesContent":["/* ---------------------------------------- [START] Window EventListener */\nexport function on(target, event, func, option) {\n\ttarget = target || window;\n\tif (window.addEventListener) {\n\t\tvar opt = option || false;\n\t\ttarget.addEventListener(event, func, opt);\n\t} else {\n\t\ttarget.attachEvent('on' + event, func);\n\t}\n}\n\nexport function off(target, event, func, option) {\n\ttarget = target || window;\n\tif (window.addEventListener) {\n\t\tvar opt = option || false;\n\t\ttarget.addEventListener(event, func, opt);\n\t} else {\n\t\ttarget.attachEvent('on' + event, func);\n\t}\n}\n/* ---------------------------------------- [END] Window EventListener */\n\n/* ---------------------------------------- [START] 簡單的節流函數 */\n// https://www.cnblogs.com/coco1s/p/5499469.html\nexport function throttle(func, wait, mustRun) {\n\tvar timeout;\n\tvar startTime = new Date();\n\n\treturn function () {\n\t\tvar context = this;\n\t\tvar args = arguments;\n\t\tvar curTime = new Date();\n\n\t\tif (timeout !== undefined) {\n\t\t\tclearTimeout(timeout);\n\t\t}\n\t\t// 如果達到了規定的觸發時間間隔,觸發 handler\n\t\tif (curTime - startTime >= mustRun) {\n\t\t\tfunc.apply(context, args);\n\t\t\tstartTime = curTime;\n\t\t\t// 沒達到觸發間隔,重新設定定時器\n\t\t} else {\n\t\t\ttimeout = setTimeout(func, wait);\n\t\t}\n\t};\n}\n/* ---------------------------------------- [END] 簡單的節流函數 */\n\n/* ---------------------------------------- [START] isInViewport */\nexport function isInViewport(el) {\n\tvar rect = el.getBoundingClientRect();\n\n\tvar isVisible = el.offsetHeight !== 0;\n\n\treturn (\n\t\tisVisible &&\n\t\trect.bottom >= 0 &&\n\t\trect.right >= 0 &&\n\t\trect.top <= (window.innerHeight || document.documentElement.clientHeight) &&\n\t\trect.left <= (window.innerWidth || document.documentElement.clientWidth)\n\t);\n}\n/* ---------------------------------------- [END] isInViewport */\n\n/* ---------------------------------------- [START] 從 String 取得 HTML Element */\n// https://stackoverflow.com/a/494348/11240898\nexport function createElementFromHTML(htmlString) {\n\tvar div = document.createElement('div');\n\tdiv.innerHTML = htmlString.trim();\n\n\t// Change this to div.childNodes to support multiple top-level nodes\n\treturn div.firstChild;\n}\n/* ---------------------------------------- [END] 從 String 取得 HTML Element */\n\n/* ---------------------------------------- [START] Disable/Enable Scroll */\nexport function docDisableScroll() {\n\tvar html = document.documentElement;\n\tvar top = (window.pageYOffset || html.scrollTop) - (html.clientTop || 0);\n\twindow.scrollTopCache = top;\n\thtml.style.cssText += `position: fixed; width: 100%; overflow-y: hidden; top:-${top}px`;\n}\nexport function docEnableScroll() {\n\tvar html = document.documentElement;\n\thtml.style.cssText = '';\n\twindow.scrollTo(0, window.scrollTopCache);\n\twindow.scrollTopCache = 0;\n}\n/* ---------------------------------------- [END] Disable/Enable Scroll */\n\n/* ---------------------------------------- [START] 取得正確的資源位置 */\n// https://stackoverflow.com/a/26023176/11240898\n/**\n * Current Script Path | 取得正確的資源位置\n *\n * Get the dir path to the currently executing script file\n * which is always the last one in the scripts array with\n * an [src] attr\n */\nexport function currentScriptPath() {\n\tvar scripts = document.querySelectorAll('script[src]');\n\tvar currentScript = scripts[scripts.length - 1].src;\n\tvar currentScriptChunks = currentScript.split('/');\n\tvar currentScriptFile = currentScriptChunks[currentScriptChunks.length - 1];\n\n\treturn currentScript.replace(currentScriptFile, '').split('js/')[0];\n}\n/* ---------------------------------------- [END] 取得正確的資源位置 */\n","import { on, throttle } from './modules/_fn';\n\n(function () {\n\t// const $filterEl = $('.js-filter-options');\n\t// const $checkallEls = $('.js-checkall');\n\t// const $resetFilterBtn = $('.js-filter-reset');\n\n\t// $checkallEls.each(function(index, item) {\n\t// \t$(item).on('change', function() {\n\t// \t\tconst flag = $(this).prop('checked');\n\t// \t\tinputProp($(this).parents('.dropdown-pane').find('.checkbox-content_input'), flag);\n\t// \t});\n\t// });\n\n\t// function inputProp(els, flag) {\n\t// \tels.each(function(index, item) {\n\t// \t\t$(this).prop('checked', flag);\n\t// \t});\n\t// }\n\n\t// // remove\n\t// $(document).on('click', '.js-remove-option', function() {\n\t// \t$(this).parents('.tags-item').remove();\n\t// });\n\n\t$(document).on('click', '.js-open-fixed-checked', function() {\n\t\tlet ww = window.innerWidth;\n\t\tconst $el = $('.fixed-checked_swiper');\n\n\t\tif (ww < 640) {\n\t\t\tif ($el.hasClass('is-open')) {\n\t\t\t\t$el.removeClass('is-open');\n\t\t\t\t$(this).text('展開清單');\n\t\t\t} else {\n\t\t\t\t$el.addClass('is-open');\n\t\t\t\t$(this).text('收起清單');\n\t\t\t}\n\t\t}\n\t});\n\n\t// ---------------------------------------------------------------\n\t// Swiper\n\n\t// breakpoint where swiper will be destroyed\n\t// and switches to a dual-column layout\n\tconst breakpoint = window.matchMedia('(max-width:39.9375rem)');\n\n\t// keep track of swiper instances to destroy later\n\tlet fixedSwiper;\n\n\tconst breakpointChecker = function () {\n\t\t// if larger viewport and multi-row layout needed\n\t\tif (breakpoint.matches) {\n\t\t\t// clean up old instances and inline styles when available\n\t\t\tif (fixedSwiper !== undefined) fixedSwiper.destroy(true, true);\n\n\t\t\t// or/and do nothing\n\t\t\treturn;\n\n\t\t\t// else if a small viewport and single column layout needed\n\t\t} else {\n\t\t\t// fire small viewport version of swiper\n\t\t\treturn enableSwiper();\n\t\t}\n\t};\n\n\tconst enableSwiper = function () {\n\t\tconst swiperTarget = '.fixed-checked_swiper';\n\t\t// if (typeof Swiper === 'undefined') return false;\n\n\t\tfixedSwiper = new Swiper(swiperTarget + ' .swiper-container', {\n\t\t\tspeed: 1000,\n\t\t\tlazy: {\n\t\t\t\tloadPrevNext: true,\n\t\t\t\tloadPrevNextAmount: 2\n\t\t\t},\n\t\t\tslidesPerView: 'auto',\n\t\t\tspaceBetween: 20,\n\t\t\tspeed: 300,\n\t\t\twatchOverflow: true,\n\t\t\tnavigation: {\n\t\t\t\tnextEl: swiperTarget + ' .swiper-button-next',\n\t\t\t\tprevEl: swiperTarget + ' .swiper-button-prev'\n\t\t\t},\n\t\t\tbreakpoints: {\n\t\t\t\t1440: {\n\t\t\t\t\tspaceBetween: 40,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t};\n\n\t// keep an eye on viewport size changes\n\ton(breakpoint, 'load', breakpointChecker);\n\ton(breakpoint, 'change', breakpointChecker);\n\t// breakpoint.addEventListener('load', breakpointChecker);s\n\t// breakpoint.addEventListener('change', breakpointChecker);\n\n\t// kickstart\n\tbreakpointChecker();\n\n\t// Remove Slide\n\t// $(document).on('click', '.js-remove-selected', function() {\n\t// \t$(this).parents('.fixed-checked_item').remove();\n\t// \tcheckFixedSelect();\n\t// });\n\n\t// function checkFixedSelect() {\n\t// \tif ($('body').hasClass('has-fixed-checked')) {\n\t// \t\tif ($('.fixed-checked_item').length) {\n\t// \t\t\t$('#ft').css('padding-bottom', $('.fixed-checked-product').outerHeight());\n\t// \t\t} else {\n\t// \t\t\t$('#ft').css('padding-bottom', 0)\n\t// \t\t}\n\n\t// \t\tfixedSwiper.update();\n\t// \t}\n\t// }\n\n\t// on(window, 'load', checkFixedSelect);\n\t// on(window, 'resize', throttle(checkFixedSelect, 50, 100));\n\n\twindow.updateFixedSwiper = fixedSwiper;\n})();\n"],"sourceRoot":"../../src/"}