{"version":3,"file":"events-news-list.js","mappings":"MAAA,MAAMA,UAAuBC,aAE5B,WAAAC,GACCC,QACAC,KAAKC,iCACLD,KAAKE,iCAAiC,aAAcF,KAAKC,+BAC1D,CACA,iBAAAE,GAAqB,CAErBF,+BAAiC,KAChC,MAAMG,EAAsBJ,KAAKK,iBAAiBC,WAAWC,iBAAiB,UAC9E,IAAK,IAAIC,KAAiBJ,EACzBI,EAAcC,iBAAiB,QAAST,KAAKU,6BAC9C,EAGDA,6BAA+BC,MAAOC,IACrC,MAAMC,EAAOD,EAAME,OAAOC,aAAa,mBACjCf,KAAKgB,WAAWH,EAAK,EAG5B,aAAMI,CAAQJ,GACb,MAAMK,EAAO,CACZC,IAAKnB,KAAKmB,IACVC,UAAW,CAAC,UAAW,cAEvBP,KAAMA,GAGP,aAD2Bb,KAAKqB,eAAeH,EAEhD,CAEA,cAAMI,CAAST,GACd,MAAMU,QAAqBvB,KAAKiB,QAAQJ,GACxCb,KAAKwB,sBAAsB,UAAWD,EAAaE,SACnDzB,KAAKwB,sBAAsB,aAAcD,EAAajB,WACvD,CAEA,gBAAMU,CAAWH,GAChB,MAAMU,QAAqBvB,KAAKiB,QAAQJ,GAClCa,EAAmB1B,KAAK2B,cAC7B,uCAEKC,EAAaC,SAASC,cAAc,OAC1CF,EAAWG,UAAYR,EAAaE,QACpC,MAAMO,EAAkBJ,EAAWrB,iBAClC,4CAED,IAAK,MAAM0B,KAAkBD,EAC5BN,EAAiBQ,OAAOD,GAEzBjC,KAAKwB,sBAAsB,aAAcD,EAAajB,WACvD,EAIDuB,SAASpB,iBAAiB,oBAAoB,KAC7C0B,eAAeC,OAAO,6BAA8BxC,EAAgB,CAACyC,QAAS,OAAO,G","sources":["webpack://customtheme/./custom-post-lists/events-news-list/scripts/src/events-news-list.js"],"sourcesContent":["class EventsNewsList extends ESWPPostList {\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.paginationAttachEventListeners();\n\t\tthis.addUpdateTemplateElementCallback('pagination', this.paginationAttachEventListeners);\n\t}\n\tconnectedCallback() {}\n\t\n\tpaginationAttachEventListeners = () => {\n\t\tconst pagerButtonElements = this.templateElements.pagination.querySelectorAll('button');\n\t\tfor (let buttonElement of pagerButtonElements) {\n\t\t\tbuttonElement.addEventListener('click', this.paginationButtonClickHandler);\n\t\t}\n\t}\n\n\tpaginationButtonClickHandler = async (event) => {\n\t\tconst page = event.target.getAttribute('data-page');\n\t\tawait this.appendPage(page);\n\t}\n\n\tasync getPage(page) {\n\t\tconst args = {\n\t\t\tkey: this.key,\n\t\t\ttemplates: ['results', 'pagination'],\n\t\t\t// request_data: {},\n\t\t\tpage: page\n\t\t};\n\t\tconst newTemplates = await this.fetchTemplates(args);\n\t\treturn newTemplates;\n\t}\n\n\tasync goToPage(page) {\n\t\tconst newTemplates = await this.getPage(page);\n\t\tthis.updateTemplateElement('results', newTemplates.results);\n\t\tthis.updateTemplateElement('pagination', newTemplates.pagination);\n\t}\n\n\tasync appendPage(page) {\n\t\tconst newTemplates = await this.getPage(page);\n\t\tconst resultsContainer = this.querySelector(\n\t\t\t'[data-post-list-template=\"results\"]'\n\t\t);\n\t\tconst htmlObject = document.createElement(\"div\");\n\t\thtmlObject.innerHTML = newTemplates.results;\n\t\tconst newResultsItems = htmlObject.querySelectorAll(\n\t\t\t'[data-post-list-template=\"results\"] > li'\n\t\t);\n\t\tfor (const newResultsItem of newResultsItems) {\n\t\t\tresultsContainer.append(newResultsItem);\n\t\t}\n\t\tthis.updateTemplateElement(\"pagination\", newTemplates.pagination);\n\t}\n\n}\n\ndocument.addEventListener('DOMContentLoaded', () => {\n\tcustomElements.define('post-list-events-news-list', EventsNewsList, {extends: 'div'});\n});\n"],"names":["EventsNewsList","ESWPPostList","constructor","super","this","paginationAttachEventListeners","addUpdateTemplateElementCallback","connectedCallback","pagerButtonElements","templateElements","pagination","querySelectorAll","buttonElement","addEventListener","paginationButtonClickHandler","async","event","page","target","getAttribute","appendPage","getPage","args","key","templates","fetchTemplates","goToPage","newTemplates","updateTemplateElement","results","resultsContainer","querySelector","htmlObject","document","createElement","innerHTML","newResultsItems","newResultsItem","append","customElements","define","extends"],"sourceRoot":""}