{"version":3,"sources":["webpack:///./widgets/articleList.js"],"names":["CLS","ArticleList","$el","_classCallCheck","this","key","value","setArticleList","$wg","$","hasClass","concat","$loadMoreForm","find","$loadBtn","$items","itemsCount","length","skipCount","parseInt","val","attr","each","index","element","data","parent","addClass","on","startPos","last","endPos","i","eq","removeClass","setTimeout","animate","scrollTop","offset","top"],"mappings":"+1BAEA,IACMA,EAAM,cASCC,EAAW,WAItB,O,EAHD,SAAAA,EAAYC,I,4FAAKC,CAAA,KAAAF,GAEhBG,KAAKF,IAAMA,I,EACX,EAAAG,IAAA,OAAAC,MAED,WACCF,KAAKG,mBACL,CAAAF,IAAA,iBAAAC,MAED,WAEC,IAAIE,EAAMC,EAAEL,KAAKF,KAEjB,GAAIM,EAAIE,SAAS,GAADC,OAAIX,EAAG,cAAc,CACpC,IAAIY,EAAgBJ,EAAIK,KAAK,QACzBC,EAAWF,EAAcC,KAAK,mBAC9BE,EAASP,EAAIK,KAAK,oBAClBG,EAAaD,EAAOE,OACpBC,EAAYC,SAASP,EAAcC,KAAK,kCAAkCO,QAAU,EAGxFN,EAASO,KAAK,OAAQ,UAEtBN,EAAOO,MAAK,SAACC,EAAOC,GACnBf,EAAEe,GAASC,KAAK,QAASF,GAErBA,EAAM,EAAIL,GACbT,EAAEe,GAASE,SAASC,SAAS,aAI3BX,GAAcE,GACjBJ,EAASa,SAAS,UAGnBb,EAASc,GAAG,SAAS,WAGpB,GAFwBpB,EAAIK,KAAK,4BAA4BI,OAErCD,EAAY,CAGnC,IAFA,IAAIa,EAAWrB,EAAIK,KAAK,4BAA4BiB,OAAOL,KAAK,SAAW,EACvEM,EAASF,EAAWX,EACfc,EAAIH,EAAUG,EAAID,EAAQC,IAClCjB,EAAOkB,GAAGD,GAAGN,SAASQ,YAAY,UAE9B1B,EAAIK,KAAK,4BAA4BiB,OAAOL,KAAK,SAAW,IAAMV,EAAOE,QAC5EH,EAASa,SAAS,UAIpBQ,YAAW,WACV1B,EAAE,cAAc2B,QAAQ,CACvBC,UAAWtB,EAAOkB,GAAGJ,GAAUS,SAASC,KACtC,OACD,UAEHzB,EAASa,SAAS,mB,0FAxDC,I","file":"15.js","sourcesContent":["/* eslint-disable no-unused-vars, max-len */\n// CONSTANTS are all caps.\nconst NS = 'ArticleList';\nconst CLS = 'articleList';\nconst WG = '.' + CLS + '-';\n\n// Import stuff here if you need to or even better to import them dynamically\n// eslint-disable-next-line max-len\n// for ex. of dynamic import check out src/scripts/loadWg/articleList.js using Webpack dynamic imports as chunks.\n// import $ from 'jquery'\n\n\nexport class ArticleList {\n\tconstructor($el) {\n\t\t// $el is the widget node return by the loadArticleList function\n\t\tthis.$el = $el;\n\t}\n\n\tinit() {\n\t\tthis.setArticleList();\n\t}\n\n\tsetArticleList() {\n\t\t// Add Some logic here\n\t\tlet $wg = $(this.$el);\n\n\t\tif ($wg.hasClass(`${CLS}--showAll`)) {\n\t\t\tlet $loadMoreForm = $wg.find('form');\n\t\t\tlet $loadBtn = $loadMoreForm.find('[type=\"submit\"]');\n\t\t\tlet $items = $wg.find('.articleListItem');\n\t\t\tlet itemsCount = $items.length;\n\t\t\tlet skipCount = parseInt($loadMoreForm.find('[name=\"SearchFilter.LoadSkip\"]').val()) || 4;\n\n\t\t\t// no form submit\n\t\t\t$loadBtn.attr('type', 'button');\n\n\t\t\t$items.each((index, element) => {\n\t\t\t\t$(element).data('index', index);\n\n\t\t\t\tif (index+1 > skipCount) {\n\t\t\t\t\t$(element).parent().addClass('d-none');\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tif (itemsCount <= skipCount) {\n\t\t\t\t$loadBtn.addClass('d-none');\n\t\t\t}\n\n\t\t\t$loadBtn.on('click', () => {\n\t\t\t\tlet visibleItemsCount = $wg.find('.articleListItem:visible').length;\n\n\t\t\t\tif (visibleItemsCount < itemsCount) {\n\t\t\t\t\tlet startPos = $wg.find('.articleListItem:visible').last().data('index') + 1;\n\t\t\t\t\tlet endPos = startPos + skipCount;\n\t\t\t\t\tfor (let i = startPos; i < endPos; i++) {\n\t\t\t\t\t\t$items.eq(i).parent().removeClass('d-none');\n\n\t\t\t\t\t\tif ($wg.find('.articleListItem:visible').last().data('index') + 1 === $items.length) {\n\t\t\t\t\t\t\t$loadBtn.addClass('d-none');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t$('html, body').animate({\n\t\t\t\t\t\t\tscrollTop: $items.eq(startPos).offset().top,\n\t\t\t\t\t\t}, 500);\n\t\t\t\t\t}, 250);\n\t\t\t\t} else {\n\t\t\t\t\t$loadBtn.addClass('d-none');\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t// Add more functions like on above here\n}\n"],"sourceRoot":""}