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S,SAACC,GACnCA,EAAIC,iBAEJ/B,EAASoC,WACb,GACJ,CACJ,EACAhD,OAAOC,YAAYC,gCAAgC+C,WAAY","sources":["webpack://advanced-web/./UI/js/core/modules/refreshedresourcescarouselblock.js"],"sourcesContent":["(function () {\r\n window.oneadvanced = window.oneadvanced || {};\r\n window.oneadvanced.refreshedresourcescarouselblock = window.oneadvanced.refreshedresourcescarouselblock || {};\r\n window.oneadvanced.refreshedresourcescarouselblock.init = function () {\r\n //console.log(\"initialising refreshedresourcescarouselblock...\");\r\n var refreshedResourcesCarousels = document.querySelectorAll('[data-refreshedresourcescarousel-block-id]');\r\n if (refreshedResourcesCarousels.length) {\r\n for (var rrc = 0; rrc < refreshedResourcesCarousels.length; rrc++) {\r\n refreshedResourcesCarouselHandler(\r\n refreshedResourcesCarousels[rrc].getAttribute('data-refreshedresourcescarousel-block-id')\r\n );\r\n }\r\n }\r\n function refreshedResourcesCarouselHandler(blockId) {\r\n // from here: https://medium.com/@networkaaron/swiper-how-to-destroy-swiper-on-min-width-breakpoints-a947491ddec8\r\n\r\n // breakpoint where swiper will be destroyed\r\n // and switches to a row layout\r\n var breakpoint = window.matchMedia('(min-width:1025px)');\r\n // keep track of swiper instances to destroy later\r\n var mySwiper;\r\n\r\n var resizeCardInternals = function () {\r\n //console.log(\"setting card internal heights.\");\r\n var allResourceCardTitles = document.querySelectorAll('.refreshedresourcecardblock__title');\r\n var cardMaxHeight = 0;\r\n\r\n allResourceCardTitles.forEach((card) => {\r\n if (card.offsetHeight > cardMaxHeight) {\r\n cardMaxHeight = card.offsetHeight;\r\n }\r\n });\r\n\r\n allResourceCardTitles.forEach((card) => {\r\n card.style.height = `${cardMaxHeight}px`;\r\n });\r\n };\r\n\r\n var breakpointChecker = function () {\r\n // if larger viewport and multi-row layout needed\r\n if (breakpoint.matches === true) {\r\n // clean up old instances and inline styles when available\r\n if (mySwiper !== undefined) mySwiper.destroy(true, true);\r\n // or/and do nothing\r\n resizeCardInternals();\r\n return;\r\n // else if a small viewport and single column layout needed\r\n } else if (breakpoint.matches === false) {\r\n // fire small viewport version of swiper\r\n return enableSwiper();\r\n }\r\n };\r\n\r\n var nextButton = document.getElementById('resSwiperNext');\r\n var prevButton = document.getElementById('resSwiperPrev');\r\n\r\n var enableSwiper = function () {\r\n mySwiper = new Swiper('[data-refreshedresourcescarousel-block-id=\"' + blockId + '\"]', {\r\n direction: 'horizontal',\r\n loop: false,\r\n slidesPerView: 'auto',\r\n initialSlide: 0,\r\n grabCursor: true,\r\n breakpoints: {\r\n // when window width is >= 320px Mobile \r\n 320: {\r\n slidesPerView: 1,\r\n centeredSlides: true,\r\n },\r\n },\r\n });\r\n resizeCardInternals();\r\n };\r\n\r\n // keep an eye on viewport size changes\r\n breakpoint.addListener(breakpointChecker);\r\n // kickstart\r\n breakpointChecker();\r\n\r\n nextButton?.addEventListener('click', (evt) => {\r\n evt.preventDefault();\r\n\r\n if (mySwiper.isBeginning) {\r\n prevButton?.classList.remove('invisible');\r\n }\r\n\r\n mySwiper.slideNext();\r\n });\r\n\r\n prevButton?.addEventListener('click', (evt) => {\r\n evt.preventDefault();\r\n\r\n mySwiper.slidePrev();\r\n });\r\n }\r\n };\r\n window.oneadvanced.refreshedresourcescarouselblock.hasLoaded = true;\r\n})();"],"names":["window","oneadvanced","refreshedresourcescarouselblock","init","refreshedResourcesCarousels","document","querySelectorAll","length","rrc","refreshedResourcesCarouselHandler","getAttribute","blockId","mySwiper","breakpoint","matchMedia","resizeCardInternals","allResourceCardTitles","cardMaxHeight","forEach","card","offsetHeight","style","height","concat","breakpointChecker","matches","undefined","destroy","enableSwiper","nextButton","getElementById","prevButton","Swiper","direction","loop","slidesPerView","initialSlide","grabCursor","breakpoints","centeredSlides","addListener","addEventListener","evt","preventDefault","isBeginning","classList","remove","slideNext","slidePrev","hasLoaded"],"sourceRoot":""}