{"version":3,"file":"news-results-Cd4NOExb.js","sources":["../../Frontend/js/modules/news-results.js"],"sourcesContent":["export default function fInitNews() {\r\n let oNewsConfig = {\r\n tags: document.querySelectorAll(\".js-tag\"),\r\n defaultTag: document.querySelector(\".js-tag-default\"),\r\n nPageId: document.querySelector('.js-tags') ? parseInt(document.querySelector('.js-tags').getAttribute('data-pageid'), 10) : null\r\n }\r\n\r\n if (oNewsConfig.tags.length < 1) return;\r\n\r\n /*\r\n * Filter news articles by tag\r\n */\r\n const fFilterNewsArticles = (oTag) => {\r\n let oRequest = new XMLHttpRequest();\r\n\r\n if(oTag) {\r\n for (var i = 0; i < oNewsConfig.tags.length; i += 1) {\r\n oNewsConfig.tags[i].classList.remove('active');\r\n }\r\n oTag.classList.add('active');\r\n } else {\r\n oTag = document.querySelector('.js-tag.active');\r\n }\r\n\r\n if (oTag) {\r\n oRequest.open('GET', `/Umbraco/Surface/NewsOverview/GetAvailableNewsArticles?tag=${oTag.getAttribute('data-tag')}&pageId=${oNewsConfig.nPageId}`, true);\r\n oRequest.onreadystatechange = () => {\r\n if (oRequest.readyState === XMLHttpRequest.DONE) {\r\n if (oRequest.status === 200) {\r\n let newsResultsContainer = document.querySelector('.js-news-results');\r\n newsResultsContainer.innerHTML = oRequest.responseText;\r\n }\r\n }\r\n };\r\n oRequest.send();\r\n }\r\n }\r\n\r\n /*\r\n * Bind Click event to all tags\r\n */\r\n for (let i = 0; i < oNewsConfig.tags.length; i += 1) {\r\n oNewsConfig.tags[i].addEventListener('click', () => {\r\n fFilterNewsArticles(oNewsConfig.tags[i]);\r\n }, false);\r\n }\r\n\r\n /*\r\n * Get the default news article\r\n */\r\n fFilterNewsArticles(oNewsConfig.defaultTag);\r\n}\r\n"],"names":["fInitNews","oNewsConfig","fFilterNewsArticles","oTag","oRequest","i","newsResultsContainer"],"mappings":"AAAe,SAASA,GAAY,CAChC,IAAIC,EAAc,CACd,KAAM,SAAS,iBAAiB,SAAS,EACzC,WAAY,SAAS,cAAc,iBAAiB,EACpD,QAAS,SAAS,cAAc,UAAU,EAAI,SAAS,SAAS,cAAc,UAAU,EAAE,aAAa,aAAa,EAAG,EAAE,EAAI,IAChI,EAED,GAAIA,EAAY,KAAK,OAAS,EAAG,OAKjC,MAAMC,EAAuBC,GAAS,CAClC,IAAIC,EAAW,IAAI,eAEnB,GAAGD,EAAM,CACL,QAASE,EAAI,EAAGA,EAAIJ,EAAY,KAAK,OAAQI,GAAK,EAC9CJ,EAAY,KAAKI,CAAC,EAAE,UAAU,OAAO,QAAQ,EAEjDF,EAAK,UAAU,IAAI,QAAQ,CACvC,MACYA,EAAO,SAAS,cAAc,gBAAgB,EAG9CA,IACAC,EAAS,KAAK,MAAO,8DAA8DD,EAAK,aAAa,UAAU,CAAC,WAAWF,EAAY,OAAO,GAAI,EAAI,EACtJG,EAAS,mBAAqB,IAAM,CAChC,GAAIA,EAAS,aAAe,eAAe,MACnCA,EAAS,SAAW,IAAK,CACzB,IAAIE,EAAuB,SAAS,cAAc,kBAAkB,EACpEA,EAAqB,UAAYF,EAAS,YAC7C,CAErB,EACYA,EAAS,KAAI,EAEpB,EAKD,QAASC,EAAI,EAAGA,EAAIJ,EAAY,KAAK,OAAQI,GAAK,EAC9CJ,EAAY,KAAKI,CAAC,EAAE,iBAAiB,QAAS,IAAM,CAChDH,EAAoBD,EAAY,KAAKI,CAAC,CAAC,CAC1C,EAAE,EAAK,EAMZH,EAAoBD,EAAY,UAAU,CAC9C"}