{"version":3,"sources":["pwa/pages/communityResults/searchResultsAds.js","pwa/pages/communityResults/skeletonManager.js","pwa/pages/communityResults/onLoadedUtils.js"],"names":["define","fastdom","paramsObserver","appNexus","generateAds","generateAllAds","lastAd","document","querySelectorAll","index","length","refreshAdByName","id","subscribe","mutate","loadCss","css","getElementById","getSkeletonHtml","innerHTML","replaceResultsWithDummyCards","visibleCards","Array","from","skeletonDiv","createRange","createContextualFragment","querySelector","scrollIntoView","forEach","target","replaceWith","cloneNode","isMoreResults","listingContent","listingsContainer","resultCards","i","insertAdjacentHTML","appendDummyCards","removeDummyCards","elements","getElementsByClassName","parentNode","removeChild","value","loadPagination","event","element","pagination","closest","body","removeEventListener","preventDefault","stopPropagation","require","click","addEventListener"],"mappings":"AAAAA,OACA,mBAAA,CACA,UACA,iBACA,aAEA,CACAC,QACAC,eACAC,YAEA,aAEA,SAAAC,cACAD,SAAAE,gBAAA,GAEA,MAAAC,OAAAC,SAAAC,iBAAA,yDAEA,IAAA,IAAAC,MAAA,EAAAA,MAAAH,OAAAI,OAAAD,OAAA,EACAN,SAAAQ,gBAAAL,OAAAG,OAAAG,IAQAV,eAAAW,UAAA,iBAJA,WACAZ,QAAAa,OAAAV,mBAOAJ,OAAA,kBAAA,CAAA,UC9BA,iBACA,UACA,cACA,CACAC,QACAC,eACAa,WAEA,aAEA,MAAAC,IAAAT,SAAAU,eAAA,mBAEA,SAAAC,kBACA,OAAAX,SAAAU,eAAA,gBAAAE,UA2BA,SAAAC,+BACA,MAAAC,aAAAC,MAAAC,KAAAhB,SAAAC,iBACA,+CAEAgB,YAAAjB,SAAAkB,cAAAC,yBAAAR,mBAEAG,aAAAX,OAAA,GA7BAH,SAAAoB,cAAA,6BACAC,iBA8BAP,aAAAQ,SAAAC,SACAA,OAAAC,YAAAP,YAAAQ,WAAA,QA5BA,SAAAC,eACA,IAAAC,eAAA,GACA,MAAAC,kBAAA5B,SAAAoB,cAAA,0CACAS,YAAAD,kBAAA3B,iBACA,mEAGA,IAAA,IAAA6B,EAAA,EAAAA,EAAA,EAAAA,GAAA,EACAH,gBAAAhB,kBAGAe,eAAAG,YAAA1B,OAAA,EACA0B,YAAAA,YAAA1B,OAAA,GACA4B,mBAAA,WAAAJ,gBAEAC,kBAAAhB,UAAAe,eAgBAK,EAAA,GAIA,SAAAC,mBACA,MAAAC,SAAAlC,SAAAmC,uBAAA,iBAEA,KAAAD,SAAA/B,OAAA,GACA+B,SAAA,GAAAE,WAAAC,YAAAH,SAAA,IAYAvC,eAAAW,UAAA,qBARA,WACAG,KACAD,QAAAC,IAAA6B,OAGA5C,QAAAa,OAAAM,iCAIAlB,eAAAW,UAAA,gBAAA,KAAAZ,QAAAa,OAAA0B,wBAGAxC,OC5EA,gBAAA,CACA,UACA,iBACA,WACA,mBACA,oBAEA,KACA,aAUA,SAAA8C,eAAAC,OACA,MAAAC,QAAAD,MAAAjB,OACAmB,WAAAD,QAAAE,QAAA,qBACA3C,SAAA4C,KAAAC,oBAAA,WAAAN,gBACAvC,SAAA4C,KAAAC,oBAAA,QAAAN,gBAEAG,aACAF,MAAAM,iBACAN,MAAAO,mBAGAC,QAAA,CAAA,eAAA,KACAN,YACAD,QAAAQ,WArBAjD,SAAAoB,cAAA,8BA2BApB,SAAA4C,KAAAM,iBAAA,WAAAX,gBACAvC,SAAA4C,KAAAM,iBAAA,QAAAX","file":"../onloadedutils-4a61f0b82a.js","sourceRoot":"..","sourcesContent":["define(\r\n 'searchResultsAds',[\r\n 'fastdom',\r\n 'paramsObserver',\r\n 'appNexus'\r\n ],\r\n (\r\n fastdom,\r\n paramsObserver,\r\n appNexus\r\n ) => {\r\n 'use strict';\r\n\r\n function generateAds() {\r\n appNexus.generateAllAds(false);\r\n\r\n const lastAd = document.querySelectorAll(\".nhs_ASTBelowDiv[data-width='300'][data-height='250']\");\r\n\r\n for (let index = 0; index < lastAd.length; index += 1) {\r\n appNexus.refreshAdByName(lastAd[index].id);\r\n }\r\n }\r\n\r\n function handleAds() {\r\n fastdom.mutate(generateAds);\r\n }\r\n\r\n paramsObserver.subscribe('resultsLoaded', handleAds);\r\n }\r\n);\r\n\n","define('skeletonManager',['fastdom',\r\n 'paramsObserver',\r\n 'loadCss',\r\n 'domHelper'\r\n], (\r\n fastdom,\r\n paramsObserver,\r\n loadCss\r\n) => {\r\n 'use strict';\r\n\r\n const css = document.getElementById('nhs_SkeletonCss');\r\n\r\n function getSkeletonHtml() {\r\n return document.getElementById('skeletonHtml').innerHTML;\r\n }\r\n\r\n function scrollToTopResults() {\r\n const topElement = document.querySelector('#nhs_Main, #nhs_ResTabBar');\r\n topElement.scrollIntoView();\r\n }\r\n\r\n function appendDummyCards(isMoreResults) {\r\n let listingContent = '';\r\n const listingsContainer = document.querySelector('.nhs_ResultsContainer, #nhs_ResultList');\r\n const resultCards = listingsContainer.querySelectorAll(\r\n '.nhs_ResultsContainer .nhs_ResItem, .result[data-srp-card-type]'\r\n );\r\n\r\n for (let i = 0; i < 3; i += 1) {\r\n listingContent += getSkeletonHtml();\r\n }\r\n\r\n if (isMoreResults && resultCards.length > 0) {\r\n const lastResultCard = resultCards[resultCards.length - 1];\r\n lastResultCard.insertAdjacentHTML('afterend', listingContent);\r\n } else {\r\n listingsContainer.innerHTML = listingContent;\r\n }\r\n }\r\n\r\n function replaceResultsWithDummyCards() {\r\n const visibleCards = Array.from(document.querySelectorAll(\r\n '.card-listing, .result[data-srp-card-type]'\r\n ));\r\n const skeletonDiv = document.createRange().createContextualFragment(getSkeletonHtml());\r\n\r\n if (visibleCards.length > 0) {\r\n scrollToTopResults();\r\n visibleCards.forEach((target) => {\r\n target.replaceWith(skeletonDiv.cloneNode(true));\r\n });\r\n } else {\r\n appendDummyCards(false);\r\n }\r\n }\r\n\r\n function removeDummyCards() {\r\n const elements = document.getElementsByClassName('card-skeleton');\r\n\r\n while (elements.length > 0) {\r\n elements[0].parentNode.removeChild(elements[0]);\r\n }\r\n }\r\n\r\n function skeletonManager() {\r\n if (css) {\r\n loadCss(css.value);\r\n }\r\n\r\n fastdom.mutate(replaceResultsWithDummyCards);\r\n }\r\n\r\n paramsObserver.subscribe('beforeResultsLoad', skeletonManager);\r\n paramsObserver.subscribe('resultsReady', () => { fastdom.mutate(removeDummyCards); });\r\n});\r\n\n","define(\r\n 'onLoadedUtils',[\r\n 'fastdom',\r\n 'paramsObserver',\r\n 'appNexus',\r\n 'searchResultsAds',\r\n 'skeletonManager'\r\n ],\r\n () => {\r\n 'use strict';\r\n\r\n const resultList = document.querySelector('[data-container-results]');\r\n\r\n /**\r\n * @private\r\n * loadPagination: load pagination module.\r\n *\r\n * @param {Event} event trigger on tab pagination.\r\n */\r\n function loadPagination(event) {\r\n const element = event.target;\r\n const pagination = element.closest('[data-pagination]');\r\n document.body.removeEventListener('touchend', loadPagination);\r\n document.body.removeEventListener('click', loadPagination);\r\n\r\n if (pagination) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n }\r\n\r\n require(['pagination'], () => {\r\n if (pagination) {\r\n element.click();\r\n }\r\n });\r\n }\r\n\r\n if (resultList) {\r\n document.body.addEventListener('touchend', loadPagination);\r\n document.body.addEventListener('click', loadPagination);\r\n }\r\n }\r\n);\r\n\n"]}