{"version":3,"sources":["genericPaging.js"],"names":["GenericPaging","constructor","_guid","this","sectionGuid","undefined","perPage","pagedItemCount","pageNo","parentElement","pagedItems","$paginationTarget","me","InitGenericPaging","_resultsPerPage","_parentElementID","_pagedItemSelector","sectionGuidWithUnderScore","document","querySelector","querySelectorAll","length","$","pagination","items","itemsOnPage","cssStyle","onPageClick","_pageNo","event","preventDefault","ChangePage","bind","onInit","resultCount","DoPagination","toPage","startPage","endPage","i","classList","remove","add","currentPage","show","hide"],"mappings":"AAAA,MAAMA,cACFC,YAAYC,GAEJC,KAAKC,iBADKC,IAAVH,EACmBA,EAEA,KAI3BE,YAAc,KAEdE,QAAU,KACVC,eAAiB,EACjBC,OAAS,EAETC,cAAgB,KAChBC,WAAa,KACbC,kBAAoB,KAEpBC,GAAKT,KAELU,kBAAkBC,EAAiBC,EAAkBC,GACjDb,KAAKc,0BAAkD,OAArBd,KAAKC,YAAwB,GAAK,IAAMD,KAAKC,YAE/ED,KAAKG,QAAUQ,EACfX,KAAKM,cAAgBS,SAASC,cAAcJ,EAAmBZ,KAAKc,2BACpEd,KAAKO,WAAaP,KAAKM,cAAcW,iBAAiBJ,GACtDb,KAAKI,eAAiBJ,KAAKO,WAAWW,OACtClB,KAAKQ,kBAAoBW,EAAE,qBAAuBnB,KAAKc,2BAEvDd,KAAKQ,kBAAkBY,WAAW,CAC9BC,MAAOrB,KAAKI,eACZkB,YAAatB,KAAKG,QAClBoB,SAAU,cACVC,YAAa,SAAUC,EAASC,GAC5BA,EAAMC,iBACN3B,KAAK4B,WAAWH,IAClBI,KAAK7B,MACP8B,OAAQ,WAEJ,IAAIC,EAAc,EACM,OAApB/B,KAAKO,aACLwB,EAAc/B,KAAKI,gBAEvBJ,KAAKgC,aAAaD,EAAa/B,KAAKK,SACtCwB,KAAK7B,QAEXA,KAAK4B,WAAW,GAGpBA,WAAWK,GACP,IACIC,GADAD,EAAUA,EAAS,GACG,EAAMA,EAASjC,KAAKG,QAAW,EACrDgC,EAAWF,EAAS,EAAMC,EAAYlC,KAAKG,QAAWH,KAAKG,QAG/D,IAAK,IAAIiC,EAAI,EAAGA,EAAIpC,KAAKI,eAAgBgC,IACjCA,GAAKF,GAAaE,EAAID,EACtBnC,KAAKO,WAAW6B,GAAGC,UAAUC,OAAO,UAEpCtC,KAAKO,WAAW6B,GAAGC,UAAUE,IAAI,UAK7CP,aAAaD,EAAaS,GACF,OAAhBT,GAAwBA,EAAc/B,KAAKG,SAC3CH,KAAKQ,kBAAkBY,WAAW,WAClCpB,KAAKQ,kBAAkBY,WAAW,cAAeW,GACjD/B,KAAKQ,kBAAkBY,WAAW,WAAYoB,GAC9CxC,KAAKQ,kBAAkBiC,QAEvBzC,KAAKQ,kBAAkBkC","file":"../genericPaging.js","sourcesContent":["class GenericPaging {\r\n constructor(_guid) {\r\n if (_guid !== undefined) {\r\n this.sectionGuid = _guid;\r\n } else {\r\n this.sectionGuid = null;\r\n }\r\n }\r\n\r\n sectionGuid = null;\r\n\r\n perPage = null;\r\n pagedItemCount = 0;\r\n pageNo = 1;\r\n\r\n parentElement = null;\r\n pagedItems = null;\r\n $paginationTarget = null;\r\n\r\n me = this;\r\n\r\n InitGenericPaging(_resultsPerPage, _parentElementID, _pagedItemSelector) {\r\n this.sectionGuidWithUnderScore = (this.sectionGuid === null) ? '' : '_' + this.sectionGuid;\r\n\r\n this.perPage = _resultsPerPage;\r\n this.parentElement = document.querySelector(_parentElementID + this.sectionGuidWithUnderScore);\r\n this.pagedItems = this.parentElement.querySelectorAll(_pagedItemSelector);\r\n this.pagedItemCount = this.pagedItems.length;\r\n this.$paginationTarget = $('#pagination_search' + this.sectionGuidWithUnderScore);\r\n\r\n this.$paginationTarget.pagination({\r\n items: this.pagedItemCount,\r\n itemsOnPage: this.perPage,\r\n cssStyle: 'light-theme',\r\n onPageClick: function (_pageNo, event) {\r\n event.preventDefault();\r\n this.ChangePage(_pageNo);\r\n }.bind(this),\r\n onInit: function () {\r\n //console.log('Init paging %o', this);\r\n var resultCount = 0;\r\n if (this.pagedItems !== null) {\r\n resultCount = this.pagedItemCount;\r\n }\r\n this.DoPagination(resultCount, this.pageNo);\r\n }.bind(this)\r\n });\r\n this.ChangePage(1);\r\n }\r\n\r\n ChangePage(toPage) {\r\n var toPage = (toPage - 1); // 0 based\r\n var startPage = (toPage > 0) ? (toPage * this.perPage) : 0;\r\n var endPage = (toPage > 0) ? (startPage + this.perPage) : this.perPage;\r\n\r\n //console.log(startPage + \" - \" + endPage + \" - \" + this.pagedItemCount);\r\n for (let i = 0; i < this.pagedItemCount; i++) {\r\n if (i >= startPage && i < endPage) {\r\n this.pagedItems[i].classList.remove('hidden');\r\n } else {\r\n this.pagedItems[i].classList.add('hidden');\r\n }\r\n }\r\n }\r\n\r\n DoPagination(resultCount, currentPage) {\r\n if (resultCount !== null && resultCount > this.perPage) {\r\n this.$paginationTarget.pagination('destroy');\r\n this.$paginationTarget.pagination('updateItems', resultCount);\r\n this.$paginationTarget.pagination('drawPage', currentPage);\r\n this.$paginationTarget.show();\r\n } else {\r\n this.$paginationTarget.hide();\r\n }\r\n }\r\n}"]}