{"version":3,"sources":["modules.newsListing.js"],"names":["app","newsListing","let","baseUrl","filters","util","debounce","activeFilters","document","forEach","location","filter","checked","push","value","href","init","encodeURIComponent","join","container","querySelector","querySelectorAll","applyFilters","addEventListener","event"],"mappings":"AAIAA,IAAIC,YAAe,WACjB,aAEAC,IAAIC,EAAU,KACVC,EAAU,KAkBd,MAGEA,EAAgBC,KAAAC,SAAO,WAFvBJ,IAGEK,EAAkB,GAGpBC,EAAQC,QAACC,SAAQC,GAIXA,EAAAC,SAAAL,EAAAM,KAAAF,EAAAG,KAAA,CANN,CAAC,EASHN,SAAOE,SAAAK,KACCC,EAANA,EAAMA,OACPb,EAAA,WAAAc,mBAAAV,EAAAW,KAAA,GAAA,CAAA,EACCf,CANF,EAAG,GAAI,EAGP,MAAO,CACLa,KA/BF,WAEE,IAAAG,EAAAX,SAAAY,cAAA,qBAAA,EAEAhB,EAAUI,EAASa,QAAAA,SAEnBjB,EAAQK,SAAQY,iBAAY,oBAAA,GAExBC,QAAY,SAAAX,GACdA,EAAEY,iBAAA,SAAA,SAAAC,GACFF,EAAA,CADA,CAAC,CAGH,CAAA,CAIF,CAgBA,CACF,EAAC","file":"../modules.newsListing.min.js","sourcesContent":["/* ========================================================================\r\n News listing\r\n ========================================================================== */\r\n\r\napp.newsListing = (function () {\r\n 'use strict';\r\n\r\n let baseUrl = null;\r\n let filters = null;\r\n\r\n function init() {\r\n const container = document.querySelector('[data-news-listing]');\r\n // const filtersContainer = document.querySelector('[data-news-filters]');\r\n baseUrl = container.dataset.baseUrl;\r\n filters = document.querySelectorAll('[data-news-filter]');\r\n\r\n filters.forEach((filter) => {\r\n filter.addEventListener('change', (event) => {\r\n applyFilters();\r\n });\r\n });\r\n\r\n // if (document.location.href.indexOf('?') > -1)\r\n // filtersContainer.scrollIntoView();\r\n }\r\n\r\n const applyFilters = util.debounce(() => {\r\n let activeFilters = [];\r\n\r\n filters.forEach((filter) => {\r\n if (filter.checked) activeFilters.push(filter.value);\r\n });\r\n\r\n document.location.href =\r\n activeFilters.length > 0\r\n ? baseUrl + '?filter=' + encodeURIComponent(activeFilters.join(','))\r\n : baseUrl;\r\n }, 1000);\r\n\r\n // Expose public functions and variables\r\n return {\r\n init: init,\r\n };\r\n})();\r\n"]}