@everymatrix/blog-articles-grid 1.76.7 → 1.76.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blog-articles-grid/blog-articles-grid.esm.js +1 -1
- package/dist/blog-articles-grid/blog-articles-grid_2.entry.js +1 -1
- package/dist/cjs/blog-articles-grid.cjs.js +1 -1
- package/dist/cjs/blog-articles-grid_2.cjs.entry.js +69 -34
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/blog-articles-grid/blog-articles-grid.js +74 -35
- package/dist/esm/blog-articles-grid.js +1 -1
- package/dist/esm/blog-articles-grid_2.entry.js +69 -34
- package/dist/esm/loader.js +1 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/packages/stencil/blog-articles-grid/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/packages/stencil/blog-articles-grid/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/blog-articles-grid/blog-articles-grid.d.ts +6 -3
- package/dist/types/utils/type.d.ts +0 -1
- package/package.json +1 -1
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/packages/stencil/blog-articles-grid/stencil.config.d.ts +0 -2
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/packages/stencil/blog-articles-grid/stencil.config.dev.d.ts +0 -2
- /package/dist/types/{builds/emfe-widgets → Users/adrian.pripon/Documents/Work}/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/libs/common/src/storybook/storybook-utils.d.ts +0 -0
- /package/dist/types/{builds/emfe-widgets → Users/adrian.pripon/Documents/Work}/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/packages/stencil/blog-articles-grid/storybook/main.d.ts +0 -0
- /package/dist/types/{builds/emfe-widgets → Users/adrian.pripon/Documents/Work}/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/packages/stencil/blog-articles-grid/storybook/preview.d.ts +0 -0
- /package/dist/types/{builds/emfe-widgets → Users/adrian.pripon/Documents/Work}/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/tools/plugins/index.d.ts +0 -0
- /package/dist/types/{builds/emfe-widgets → Users/adrian.pripon/Documents/Work}/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +0 -0
- /package/dist/types/{builds/emfe-widgets → Users/adrian.pripon/Documents/Work}/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/tools/plugins/vite-chunk-plugin.d.ts +0 -0
- /package/dist/types/{builds/emfe-widgets → Users/adrian.pripon/Documents/Work}/widgets-monorepo/packages/stencil/blog-articles-grid/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as t}from"./index-a336d277.js";export{s as setNonce}from"./index-a336d277.js";import{g as n}from"./app-globals-0f993ce5.js";(()=>{const t=import.meta.url,n={};return""!==t&&(n.resourcesUrl=new URL(".",t).href),e(n)})().then((async e=>(await n(),t([["blog-articles-grid_2",[[1,"blog-articles-grid",{cmsEndpoint:[513,"cms-endpoint"],language:[513],userRoles:[513,"user-roles"],cmsEnv:[513,"cms-env"],mbSource:[1,"mb-source"],clientStyling:[513,"client-styling"],clientStylingUrl:[513,"client-styling-url"],showPublishingDate:[516,"show-publishing-date"],showImage:[516,"show-image"],showTitle:[516,"show-title"],showContent:[516,"show-content"],showButton:[516,"show-button"],usePostmessage:[516,"use-postmessage"],postMessageEvent:[513,"post-message-event"],blogsLimit:[513,"blogs-limit"],paginationActive:[516,"pagination-active"],arrowsActive:[516,"arrows-active"],secondaryArrowsActive:[516,"secondary-arrows-active"],numberedNavActive:[516,"numbered-nav-active"],intlDateTimeFormat:[513,"intl-date-time-format"],page:[513],eventId:[513,"event-id"],paginationBlogList:[32],currentPage:[32],hasErrors:[32],isLoading:[32],bannerMatrixReady:[32],nextPage:[32],previousPage:[32],device:[32],
|
|
1
|
+
import{p as e,b as t}from"./index-a336d277.js";export{s as setNonce}from"./index-a336d277.js";import{g as n}from"./app-globals-0f993ce5.js";(()=>{const t=import.meta.url,n={};return""!==t&&(n.resourcesUrl=new URL(".",t).href),e(n)})().then((async e=>(await n(),t([["blog-articles-grid_2",[[1,"blog-articles-grid",{cmsEndpoint:[513,"cms-endpoint"],language:[513],userRoles:[513,"user-roles"],cmsEnv:[513,"cms-env"],mbSource:[1,"mb-source"],clientStyling:[513,"client-styling"],clientStylingUrl:[513,"client-styling-url"],showPublishingDate:[516,"show-publishing-date"],showImage:[516,"show-image"],showTitle:[516,"show-title"],showContent:[516,"show-content"],showButton:[516,"show-button"],usePostmessage:[516,"use-postmessage"],postMessageEvent:[513,"post-message-event"],blogsLimit:[513,"blogs-limit"],paginationActive:[516,"pagination-active"],arrowsActive:[516,"arrows-active"],secondaryArrowsActive:[516,"secondary-arrows-active"],numberedNavActive:[516,"numbered-nav-active"],intlDateTimeFormat:[513,"intl-date-time-format"],page:[513],eventId:[513,"event-id"],paginationBlogList:[32],currentPage:[32],hasErrors:[32],isLoading:[32],bannerMatrixReady:[32],nextPage:[32],previousPage:[32],device:[32],displayedBlogResponse:[32],paginationBlogResponse:[32],allBlogResponse:[32],totalBlogs:[32]},[[8,"BannerMatrixReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]],{page:["watchEndpoint"],hasErrors:["watchEndpoint"],cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"],cmsEnv:["watchEndpoint"],userRoles:["watchEndpoint"],blogsLimit:["watchEndpoint"],eventId:["watchEndpoint"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}],[1,"helper-pagination",{nextPage:[1537,"next-page"],prevPage:[1537,"prev-page"],offset:[1538],limit:[1538],total:[1538],language:[1537],mbSource:[1,"mb-source"],clientStyling:[1537,"client-styling"],clientStylingUrl:[1537,"client-styling-url"],arrowsActive:[1540,"arrows-active"],secondaryArrowsActive:[1540,"secondary-arrows-active"],numberedNavActive:[1540,"numbered-nav-active"],offsetInt:[32],lastPage:[32],previousPage:[32],limitInt:[32],totalInt:[32],pagesArray:[32],endInt:[32]},null,{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}]]]],e))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as n}from"./index-a336d277.js";const e={en:{error:"Error",readmore:"Read more"},ro:{error:"Eroare",readmore:"Read more"},fr:{error:"Error",readmore:"Read more"},ar:{error:"خطأ",readmore:"Read more"},hu:{error:"خطأ",readmore:"Tovább olvasom"},hr:{error:"Greška",readmore:"Pročitaj više"},"pt-br":{error:"Erro",readmore:"Ler mais"},"es-mx":{error:"Error",readmore:"Leer más"}},s=(t,i)=>e[void 0!==i&&i in e?i:"en"][t];function o(t,i){if(t){const n=document.createElement("style");n.innerHTML=i,t.appendChild(n)}}function a(t,i){const n=new URL(i);fetch(n.href).then((t=>t.text())).then((i=>{const n=document.createElement("style");n.innerHTML=i,t&&t.appendChild(n)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}function r(t,i){if(window.emMessageBus){const n=document.createElement("style");window.emMessageBus.subscribe(i,(i=>{n.innerHTML=i,t&&t.appendChild(n)}))}}const h=class{constructor(e){t(this,e),this.articleActionButton=i(this,"articleActionButton",7),this.clientStylingContent="",this.defaultStyling="\n div#PaginationContainer {\n justify-content: right;\n }\n .LeftItems button .NavigationButton {\n display: none;\n }\n .LeftItems button:after, .RightItems button:after {\n padding: 7px 12px;\n font-size: 18px;\n font-weight: 700;\n line-height: 46px;\n }\n .LeftItems button:after {\n content: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='1.2em' viewBox='0 0 320 512'%3E%3C!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --%3E%3Cpath d='M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z'/%3E%3C/svg%3E\");\n }\n .RightItems button:after {\n content: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='1.2em' viewBox='0 0 320 512'%3E%3C!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --%3E%3Cpath d='M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z'/%3E%3C/svg%3E\");\n display: block;\n height: 38px;\n }\n div.LeftItems button, div.RightItems button {\n width: unset;\n height: 40px;\n background-color: #fff;\n color: #000;\n border: 1px solid #000;\n overflow: hidden;\n &:disabled {\n background-color: #989898;\n }\n }\n div.LeftItems button {\n min-width: 60px;\n border-radius: 20px 0 0 20px;\n border-right: 0;\n }\n div.RightItems button {\n display: flex;\n min-width: 100px;\n justify-content: space-evenly;\n align-items: center;\n border-radius: 0 20px 20px 0;\n text-transform: none;\n }\n .RightItems button .NavigationButton {\n padding: 12px 0 12px 12px;\n font-weight: 700;\n }",this.setImage=t=>{let i="";switch(this.device){case"mobile":i=t.sources[0].pictureSource;break;case"tablet":i=t.sources[1].pictureSource;break;case"desktop":i=t.sources[2].pictureSource}return i},this.renderContentConditionally=t=>{if(t)return-1!==t.indexOf("<bannermatrix-banner")?this.bannerMatrixReady?n("div",{class:"BlogContent",innerHTML:t}):null:n("div",{class:"BlogContent",innerHTML:t})},this.cmsEndpoint=void 0,this.language="en",this.userRoles="everyone",this.cmsEnv="stage",this.mbSource=void 0,this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.showButton=!0,this.usePostmessage=void 0,this.postMessageEvent="",this.blogsLimit="0",this.paginationActive=void 0,this.arrowsActive=void 0,this.secondaryArrowsActive=void 0,this.numberedNavActive=void 0,this.intlDateTimeFormat="",this.page="1",this.eventId=void 0,this.paginationBlogList={offset:0},this.currentPage=0,this.hasErrors=!1,this.isLoading=!0,this.bannerMatrixReady=!1,this.nextPage="",this.previousPage="",this.device="",this.blogData=void 0,this.totalBlogs=0}getArticleId(t,i,n){this.usePostmessage?window.postMessage({type:this.postMessageEvent,postId:t.toString(),slug:i,customPath:n}):this.articleActionButton.emit({postId:t.toString(),slug:i,customPath:n})}handleBannerReady(){this.bannerMatrixReady=!0}watchEndpoint(t,i){this.currentPage=parseInt(this.page)-1,t&&t!=i&&this.cmsEndpoint&&this.language&&this.getBlogArticleGrid()}handleClientStylingChange(t,i){t!=i&&o(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(t,i){t!=i&&this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)}hpPageChange(t){var i,n;this.paginationBlogList=t.detail,this.currentPage=Math.floor((null===(i=this.paginationBlogList)||void 0===i?void 0:i.offset)/(null===(n=this.paginationBlogList)||void 0===n?void 0:n.limit)),this.page&&(this.currentPage=this.currentPage+ +this.page-1),this.currentPage+1>this.lastPage?this.nextPage=null:this.currentPage<0?this.previousPage=null:(window.postMessage({type:"BlogArticlesGridActivePagination",currentPage:this.currentPage},window.location.href),this.getBlogArticleGrid())}sortArticlesByDate(t){return t.sort(((t,i)=>t.publishingDate>i.publishingDate?-1:t.publishingDate<i.publishingDate?1:0)),t}findLatestFeatured(t){let i=t.filter((t=>t.isFeaturedPost));return 0===i.length?null:(i=this.sortArticlesByDate(i),i[0])}moveLatestFeatureToStart(t,i){const n=t.indexOf(i);return-1!==n&&(t.splice(n,1),t.unshift(i)),t}getBlogArticleGrid(t){this.isLoading=!0;let i=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);i.searchParams.append("per_page",this.eventId?"1000":this.blogsLimit),i.searchParams.append("page",JSON.stringify(t||this.currentPage+1)),i.searchParams.append("env",this.cmsEnv),i.searchParams.append("userRoles",this.userRoles),i.searchParams.append("device",(()=>{const t=(()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"})();if(t)return"PC"===t?"dk":"mtWeb"})()),fetch(i.href).then((t=>{if(t.status>=300)throw this.hasErrors=!0,new Error("There was an error while fetching the data");return t.json()})).then((t=>{let i;const n=this.eventId?t.items.filter((({eventIds:t})=>t.includes(this.eventId))):[];n.length?(i=n,this.totalBlogs=n.length):(i=t.items,this.totalBlogs=t.total),this.lastPage=+t.pages.last.match(/&page=(\d+)/)[1],this.nextPage=t.pages.next,this.previousPage=t.pages.previous;const e=this.findLatestFeatured(i);this.blogData=this.sortArticlesByDate(i),this.blogData=this.moveLatestFeatureToStart(i,e),this.blogData=i.map((t=>Object.assign(Object.assign({},t),{publishingDate:new Date(t.publishingDate).toLocaleDateString()}))),this.isLoading=!1,this.hasErrors=!1})).catch((t=>{this.hasErrors=!0,console.log("Error",t)})).finally((()=>this.isLoading=!1))}connectedCallback(){this.cmsEndpoint&&this.language&&this.blogsLimit&&(this.page?(this.currentPage=this.currentPage+ +this.page-1,this.getBlogArticleGrid(+this.page)):this.getBlogArticleGrid())}componentDidLoad(){this.stylingContainer&&(null!=window.emMessageBus?r(this.stylingContainer,`${this.mbSource}.Style`):(this.clientStyling&&o(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl))),window.postMessage({type:"BlogArticlesGridLoaded"},window.location.href),this.device=function(){const t=navigator.userAgent.toLowerCase();let i="";return i=t.includes("android")||t.includes("iphone")||function(){const t=navigator.userAgent.toLowerCase();return!!t.includes("ipad")||t.indexOf("macintosh")>-1&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2}()?function(){const t=screen.availWidth;return t<600?"mobile":t>=600&&t<1100?"tablet":void 0}():"desktop",i}()}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}formatDate(t){return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(t))}render(){if(this.hasErrors)return n("div",{class:"BlogsContainer"},n("div",{class:"ErrorMessage"},s("error",this.language)));const t=[];for(let i=0;i<parseInt(this.blogsLimit);i++)t.push(n("div",{class:"GridContainer FeaturedPost Skeleton"},n("div",{class:"GridWrapper"},n("div",{class:"GridSector"},n("div",{class:"VisualContent LoadingImage"})),n("div",{class:"GridSector"},n("div",{class:"BlogTitle LoadingStripe LoadingSmallStripe"}),n("div",{class:"BlogDetails LoadingStripe LoadingMediumStripe"}),n("div",{class:"BlogLink LoadingStripe LoadingLongStripe"})))));return n("div",{ref:t=>this.stylingContainer=t},n("div",{class:"BlogPageContainer"},n("div",{class:"BlogGridPaginationWrapper"},1==this.paginationActive&&this.totalBlogs>+this.blogsLimit&&n("helper-pagination",{"next-page":this.nextPage,"prev-page":this.previousPage,offset:this.paginationBlogList.offset,limit:parseInt(this.blogsLimit,10),total:this.totalBlogs,language:this.language,"md-source":this.mbSource,"client-styling":this.clientStyling||this.defaultStyling,"client-styling-url":this.clientStylingUrl,"arrows-active":this.arrowsActive||!0,"secondary-arrows-active":this.secondaryArrowsActive||!1,"numbered-nav-active":this.numberedNavActive||!1})),!this.isLoading&&n("div",{class:`GridContainerWrapper BlogPage-${this.currentPage}`},this.blogData&&this.blogData.map((t=>{var i,e;return n("div",{key:t.postID,class:t.isFeaturedPost?"GridContainer FeaturedPost":"GridContainer"},n("div",{class:"GridWrapper"},n("div",{class:"GridSector"},this.showPublishingDate&&n("div",{class:"BlogDate"},this.formatDate(null==t?void 0:t.publishingDate)),this.showImage&&(null===(i=t.image)||void 0===i?void 0:i.src)?n("div",{class:"VisualContent",style:{background:`url(${this.setImage(t.image)}) no-repeat center center / cover`}}):(null===(e=t.video)||void 0===e?void 0:e.sources[this.device])?n("video",{class:"VisualContent",src:t.video.sources[this.device],controls:!0}):n("h1",{class:"VisualContent",style:{color:"#fff"}},"No Image")),n("div",{class:"GridSector"},this.showTitle&&n("div",{class:"BlogTitle"},null==t?void 0:t.title),this.showContent&&this.renderContentConditionally(null==t?void 0:t.descriptionPreview),this.showButton&&n("div",{class:"BlogLink"},n("button",{onClick:()=>this.getArticleId(null==t?void 0:t.postID,null==t?void 0:t.slug,null==t?void 0:t.customPath)},s("readmore",this.language))))))}))),this.isLoading&&n("div",{class:"GridContainerWrapper LoadingGrid"},t)))}static get watchers(){return{page:["watchEndpoint"],hasErrors:["watchEndpoint"],cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"],cmsEnv:["watchEndpoint"],userRoles:["watchEndpoint"],blogsLimit:["watchEndpoint"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}}};h.style=":host {\n display: block;\n}\n\n.BlogPageContainer {\n background: #0A0A17;\n padding: 20px;\n}\n\n.GridContainerWrapper {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 20px;\n}\n\n.BlogPage-0 .GridContainer.FeaturedPost:first-child {\n width: 100%;\n flex-basis: auto;\n}\n\n.GridContainer {\n container-type: inline-size;\n container-name: article;\n border-radius: 15px;\n color: #000;\n overflow: hidden;\n}\n.GridContainer.FeaturedPost:first-child {\n grid-column: 1/-1;\n width: 100%;\n}\n.GridContainer .GridWrapper {\n display: flex;\n flex-direction: row;\n height: 280px;\n background: var(--emw--color-white, #FFFFFF);\n}\n.GridContainer .GridSector {\n flex-basis: 50%;\n position: relative;\n}\n.GridContainer .GridSector:first-of-type {\n height: 280px;\n display: flex;\n}\n.GridContainer .GridSector:last-of-type {\n padding: 20px 40px;\n display: flex;\n flex-direction: column;\n}\n.GridContainer .VisualContent {\n width: 100%;\n}\n.GridContainer .BlogDate {\n position: absolute;\n bottom: 0px;\n left: 30px;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: var(--emw--color-white, #FFFFFF);\n background-color: #CD0B5E;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n font-size: 24px;\n color: #000;\n padding-bottom: 10px;\n}\n.GridContainer .BlogContent {\n display: -webkit-box;\n font-size: 14px;\n line-height: 1.2em;\n -webkit-line-clamp: 6;\n color: #000;\n -webkit-box-orient: vertical;\n box-sizing: border-box;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n.GridContainer .BlogLink {\n color: #000;\n position: absolute;\n bottom: 16px;\n}\n.GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n padding: 0;\n background: none;\n color: #22B04E;\n cursor: pointer;\n}\n\n@container article (max-width: 550px) {\n .GridContainer .GridWrapper {\n height: 380px;\n flex-direction: column;\n }\n .GridContainer .GridWrapper .GridSector:first-of-type {\n height: 120px;\n flex-shrink: 0;\n flex-basis: 150px;\n }\n .GridContainer .GridWrapper .GridSector:last-of-type {\n padding: 20px 20px 40px;\n }\n}\n.LoadingImage {\n width: 100%;\n height: 100%;\n background-color: var(--emw--color-gray-100, #E6E6E6);\n}\n\n.LoadingStripe {\n border: 1px solid var(--emw--color-white, #FFFFFF);\n height: 20%;\n background-color: var(--emw--color-gray-100, #E6E6E6);\n margin-bottom: 5px;\n}\n\n.LoadingSmallStripe {\n width: 40%;\n}\n\n.LoadingMediumStripe {\n width: 70%;\n}\n\n.BlogLink.LoadingLongStripe {\n position: static;\n width: 100%;\n}\n\n.GridContainerWrapper.LoadingGrid .GridSector {\n justify-content: space-around;\n}\n\n.GridContainerWrapper.LoadingGrid .LoadingImage, .GridContainerWrapper.LoadingGrid .LoadingStripe {\n animation: pulsatingLoader 2s ease-in-out 0s infinite reverse;\n -webkit-animation: pulsatingLoader 2s ease-in-out 0s infinite reverse;\n}\n\n@keyframes pulsatingLoader {\n 0% {\n opacity: 0.5;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0.5;\n }\n}\n@-webkit-keyframes pulsatingLoader {\n 0% {\n opacity: 0.5;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0.5;\n }\n}";const d=t=>!!(t.toLowerCase().match(/android/i)||t.toLowerCase().match(/blackberry|bb/i)||t.toLowerCase().match(/iphone|ipad|ipod/i)||t.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i)),l={en:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"},ro:{firstPage:"Prima",previousPage:"Anterior",nextPage:"Urmatoarea",lastPage:"Ultima"},fr:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"},ar:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"},hu:{firstPage:"First",previousPage:"Previous",nextPage:"Következő",lastPage:"Last"},hr:{firstPage:"Prva",previousPage:"Prethodna",nextPage:"Slijedeća",lastPage:"Zadnja"}},c=(t,i)=>l[void 0!==i&&i in l?i:"en"][t],g=class{constructor(n){t(this,n),this.hpPageChange=i(this,"hpPageChange",7),this.userAgent=window.navigator.userAgent,this.currentPage=1,this.navigateTo=t=>{switch(t){case"firstPage":this.offsetInt=0;break;case"lastPage":this.offsetInt=this.endInt*this.limitInt;break;case"previousPage":this.offsetInt-=this.limitInt;break;case"nextPage":this.offsetInt+=this.limitInt;break;case"fivePagesBack":this.offsetInt-=5*this.limitInt,this.offsetInt=this.offsetInt<=0?0:this.offsetInt;break;case"fivePagesForward":this.offsetInt+=5*this.limitInt,this.offsetInt=this.offsetInt/this.limitInt>=this.endInt?this.endInt*this.limitInt:this.offsetInt}this.previousPage=!!this.offsetInt,this.hpPageChange.emit({offset:this.offsetInt,limit:this.limitInt,total:this.totalInt})},this.paginationNavigation=(t,i)=>{this.previousPage=!0,isNaN(t)?0===i&&this.currentPage<=4?this.navigateTo("firstPage"):0===i&&this.currentPage>4?this.navigateTo("fivePagesBack"):4===i&&this.endInt-this.currentPage>=2&&this.navigateTo("fivePagesForward"):1===t?(this.offsetInt=t-1,this.previousPage=!1):this.offsetInt=(t-1)*this.limitInt,this.hpPageChange.emit({offset:this.offsetInt,limit:this.limitInt,total:this.totalInt})},this.nextPage="",this.prevPage="",this.offset=0,this.limit=1,this.total=1,this.language="en",this.mbSource=void 0,this.clientStyling="",this.clientStylingUrl="",this.arrowsActive=void 0,this.secondaryArrowsActive=void 0,this.numberedNavActive=void 0,this.offsetInt=void 0,this.lastPage=!1,this.previousPage=!1,this.limitInt=void 0,this.totalInt=void 0,this.pagesArray=[],this.endInt=0}handleClientStylingChange(t,i){t!=i&&o(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(t,i){t!=i&&this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)}componentWillRender(){this.offsetInt=this.offset,this.limitInt=this.limit,this.currentPage=this.offsetInt/this.limitInt+1,this.limitInt=this.limit,this.totalInt=this.total,this.endInt=Math.ceil(this.totalInt/this.limitInt)-1,this.lastPage=!(this.offsetInt>=this.endInt*this.limitInt),1==this.currentPage||2==this.currentPage?(this.pagesArray=Array.from({length:4},((t,i)=>i+1)),this.pagesArray.push("...")):this.currentPage>=3&&this.endInt-this.currentPage>=2?(this.pagesArray=Array.from({length:3},((t,i)=>this.currentPage+i-1)),this.pagesArray.push("..."),this.pagesArray.unshift("...")):this.endInt-this.currentPage<3&&(this.pagesArray=Array.from({length:4},((t,i)=>this.endInt-2+i)),this.pagesArray.unshift("..."))}componentDidLoad(){this.stylingContainer&&(null!=window.emMessageBus?r(this.stylingContainer,`${this.mbSource}.Style`):(this.clientStyling&&o(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}render(){let t=n("ul",{class:"PaginationArea"},this.pagesArray.map(((t,i)=>n("li",{class:"PaginationItem"+(t===this.currentPage?" ActiveItem":" ")+" "+(d(this.userAgent)?"MobileButtons":"")},n("button",{disabled:t===this.currentPage,onClick:this.paginationNavigation.bind(this,t,i)},n("span",null,t)))))),i=n("button",{disabled:!this.prevPage,onClick:this.navigateTo.bind(this,"firstPage")},n("span",{class:"NavigationButton"},c("firstPage",this.language)),n("span",{class:"NavigationIcon"})),e=n("div",{class:"LeftItems"},this.secondaryArrowsActive&&i,n("button",{disabled:!this.prevPage,onClick:this.navigateTo.bind(this,"previousPage")},n("span",{class:"NavigationButton"},c("previousPage",this.language)),n("span",{class:"NavigationIcon"})));d(this.userAgent)&&(e=n("div",{class:"LeftItems"},n("button",{disabled:!this.prevPage,onClick:this.navigateTo.bind(this,"previousPage")},n("span",{class:"NavigationButton"},c("previousPage",this.language)),n("span",{class:"NavigationIcon"}))));let s=n("button",{disabled:!this.nextPage,onClick:this.navigateTo.bind(this,"lastPage")},n("span",{class:"NavigationButton"},c("lastPage",this.language)),n("span",{class:"NavigationIcon"})),o=n("div",{class:"RightItems"},n("button",{disabled:!this.nextPage,onClick:this.navigateTo.bind(this,"nextPage")},n("span",{class:"NavigationButton"},c("nextPage",this.language)),n("span",{class:"NavigationIcon"})),this.secondaryArrowsActive&&s);return d(this.userAgent)&&(o=n("div",{class:"RightItems"},n("button",{disabled:!this.nextPage,onClick:this.navigateTo.bind(this,"nextPage")},n("span",{class:"NavigationButton"},c("nextPage",this.language)),n("span",{class:"NavigationIcon"})))),n("div",{id:"PaginationContainer",ref:t=>this.stylingContainer=t},this.arrowsActive&&e,this.numberedNavActive&&t,this.arrowsActive&&o)}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}}};g.style='@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap");:host{display:block;font-family:"Roboto", sans-serif}#PaginationContainer{width:100%;margin:20px 0;display:inline-flex;justify-content:space-between;align-items:center}.LeftItems button:not(:first-child),.RightItems button:not(:last-child){margin:0 10px}.LeftItems button,.RightItems button{padding:0;background-color:#009993;border-color:#009993}.PaginationArea{display:inline-flex;gap:10px;list-style:none}.PaginationArea li{margin:0;padding:0}.PaginationArea li button{width:24px;height:24px;display:flex;border:0;padding:0;justify-content:center;align-items:center;background-color:transparent;color:#000;cursor:pointer;pointer-events:all}.PaginationItem.ActiveItem button{background:#009993;border-color:#009993;color:#fff}.PaginationItem.ActiveItem button:disabled{pointer-events:none;cursor:not-allowed}.PaginationItem button:hover,.PaginationItem button:active{background:#009993;border-color:#009993;color:#fff;opacity:0.8}button{width:100px;height:32px;border:1px solid #524e52;border-radius:5px;background:#524e52;color:#fff;font-size:14px;font:inherit;cursor:pointer;transition:all 0.1s linear;text-transform:uppercase;text-align:center;letter-spacing:0}button:hover,button:active{background:#004D4A;border-color:#004D4A}button:disabled{background-color:#ccc;border-color:#ccc;color:#fff;cursor:not-allowed}@media screen and (max-width: 720px){button{width:90px;font-size:14px}}@media screen and (max-width: 480px){button{width:70px;font-size:14px}.paginationArea{padding:5px}}@media screen and (max-width: 320px){button{width:58px;font-size:12px}.paginationArea{padding:5px;gap:5px}}@media (hover: none){.paginationItem button:hover{background:inherit;border-color:inherit;color:inherit;opacity:1}.paginationItem.activeItem button:hover{background:#009993;border-color:#009993;color:#fff}}';export{h as blog_articles_grid,g as helper_pagination}
|
|
1
|
+
import{r as t,c as i,h as n}from"./index-a336d277.js";const e={en:{error:"Error",readmore:"Read more"},ro:{error:"Eroare",readmore:"Read more"},fr:{error:"Error",readmore:"Read more"},ar:{error:"خطأ",readmore:"Read more"},hu:{error:"خطأ",readmore:"Tovább olvasom"},hr:{error:"Greška",readmore:"Pročitaj više"},"pt-br":{error:"Erro",readmore:"Ler mais"},"es-mx":{error:"Error",readmore:"Leer más"}},s=(t,i)=>e[void 0!==i&&i in e?i:"en"][t];function o(t,i){if(t){const n=document.createElement("style");n.innerHTML=i,t.appendChild(n)}}function a(t,i){const n=new URL(i);fetch(n.href).then((t=>t.text())).then((i=>{const n=document.createElement("style");n.innerHTML=i,t&&t.appendChild(n)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}function r(t,i){if(window.emMessageBus){const n=document.createElement("style");window.emMessageBus.subscribe(i,(i=>{n.innerHTML=i,t&&t.appendChild(n)}))}}const h=class{constructor(e){t(this,e),this.articleActionButton=i(this,"articleActionButton",7),this.clientStylingContent="",this.defaultStyling="\n div#PaginationContainer {\n justify-content: right;\n }\n .LeftItems button .NavigationButton {\n display: none;\n }\n .LeftItems button:after, .RightItems button:after {\n padding: 7px 12px;\n font-size: 18px;\n font-weight: 700;\n line-height: 46px;\n }\n .LeftItems button:after {\n content: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='1.2em' viewBox='0 0 320 512'%3E%3C!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --%3E%3Cpath d='M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z'/%3E%3C/svg%3E\");\n }\n .RightItems button:after {\n content: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='1.2em' viewBox='0 0 320 512'%3E%3C!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --%3E%3Cpath d='M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z'/%3E%3C/svg%3E\");\n display: block;\n height: 38px;\n }\n div.LeftItems button, div.RightItems button {\n width: unset;\n height: 40px;\n background-color: #fff;\n color: #000;\n border: 1px solid #000;\n overflow: hidden;\n &:disabled {\n background-color: #989898;\n }\n }\n div.LeftItems button {\n min-width: 60px;\n border-radius: 20px 0 0 20px;\n border-right: 0;\n }\n div.RightItems button {\n display: flex;\n min-width: 100px;\n justify-content: space-evenly;\n align-items: center;\n border-radius: 0 20px 20px 0;\n text-transform: none;\n }\n .RightItems button .NavigationButton {\n padding: 12px 0 12px 12px;\n font-weight: 700;\n }",this.setImage=t=>{let i="";switch(this.device){case"mobile":i=t.sources[0].pictureSource;break;case"tablet":i=t.sources[1].pictureSource;break;case"desktop":i=t.sources[2].pictureSource}return i},this.renderContentConditionally=t=>{if(t)return-1!==t.indexOf("<bannermatrix-banner")?this.bannerMatrixReady?n("div",{class:"BlogContent",innerHTML:t}):null:n("div",{class:"BlogContent",innerHTML:t})},this.cmsEndpoint=void 0,this.language="en",this.userRoles="everyone",this.cmsEnv="stage",this.mbSource=void 0,this.clientStyling="",this.clientStylingUrl="",this.showPublishingDate=!0,this.showImage=!0,this.showTitle=!0,this.showContent=!0,this.showButton=!0,this.usePostmessage=void 0,this.postMessageEvent="",this.blogsLimit="0",this.paginationActive=void 0,this.arrowsActive=void 0,this.secondaryArrowsActive=void 0,this.numberedNavActive=void 0,this.intlDateTimeFormat="",this.page="1",this.eventId=void 0,this.paginationBlogList={offset:0},this.currentPage=0,this.hasErrors=!1,this.isLoading=!0,this.bannerMatrixReady=!1,this.nextPage="",this.previousPage="",this.device="",this.displayedBlogResponse=void 0,this.paginationBlogResponse=void 0,this.allBlogResponse=void 0,this.totalBlogs=0}getArticleId(t,i,n){this.usePostmessage?window.postMessage({type:this.postMessageEvent,postId:t.toString(),slug:i,customPath:n}):this.articleActionButton.emit({postId:t.toString(),slug:i,customPath:n})}handleBannerReady(){this.bannerMatrixReady=!0}watchEndpoint(t,i){this.currentPage=parseInt(this.page)-1,(t||""===t)&&t!=i&&this.cmsEndpoint&&this.language&&this.getBlogArticleGrid()}handleClientStylingChange(t,i){t!=i&&o(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(t,i){t!=i&&this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)}hpPageChange(t){var i,n;this.paginationBlogList=t.detail,this.currentPage=Math.floor((null===(i=this.paginationBlogList)||void 0===i?void 0:i.offset)/(null===(n=this.paginationBlogList)||void 0===n?void 0:n.limit)),this.page&&(this.currentPage=this.currentPage+ +this.page-1),this.currentPage+1>this.lastPage?this.nextPage=null:this.currentPage<0?this.previousPage=null:(window.postMessage({type:"BlogArticlesGridActivePagination",currentPage:this.currentPage},window.location.href),this.getBlogArticleGrid(!0))}sortArticlesByDate(t){return t.sort(((t,i)=>t.publishingDate>i.publishingDate?-1:t.publishingDate<i.publishingDate?1:0)),t}findLatestFeatured(t){let i=t.filter((t=>t.isFeaturedPost));return 0===i.length?null:(i=this.sortArticlesByDate(i),i[0])}moveLatestFeatureToStart(t,i){const n=t.indexOf(i);return-1!==n&&(t.splice(n,1),t.unshift(i)),t}async fetchBlogPosts(t,i=!1){const n=new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);return n.searchParams.append("per_page",i?"300":this.blogsLimit),n.searchParams.append("page",`${t||this.currentPage+1}`),n.searchParams.append("env",this.cmsEnv),n.searchParams.append("userRoles",this.userRoles),n.searchParams.append("device",(()=>{const t=(()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"})();if(t)return"PC"===t?"dk":"mtWeb"})()),fetch(n.href).then((t=>{if(t.status>=300)throw this.hasErrors=!0,new Error("There was an error while fetching the data");return t.json()})).then((t=>{let n=t.items;const e=this.findLatestFeatured(n);return n=this.sortArticlesByDate(n),n=this.moveLatestFeatureToStart(n,e),n=n.map((t=>Object.assign(Object.assign({},t),{publishingDate:new Date(t.publishingDate).toLocaleDateString()}))),t=Object.assign(Object.assign({},t),{items:n}),i?this.allBlogResponse=t:this.paginationBlogResponse=t,t})).catch((t=>(this.hasErrors=!0,console.log("Error",t),{})))}async getBlogArticleGrid(t=!1,i){var n,e,s,o,a,r,h;this.isLoading=!0;try{let d;if(this.eventId&&this.eventId.length>0){const o=(null===(n=this.allBlogResponse)||void 0===n?void 0:n.items)?this.allBlogResponse:await this.fetchBlogPosts(1,!0),a=o.items.filter((({eventIds:t})=>t.includes(this.eventId)));d=a.length?Object.assign(Object.assign({},o),{items:a,total:Math.min(parseInt(this.blogsLimit),a.length)}):(null===(s=null===(e=this.paginationBlogResponse)||void 0===e?void 0:e.items)||void 0===s?void 0:s.length)&&!t?this.paginationBlogResponse:await this.fetchBlogPosts(i)}else d=(null===(a=null===(o=this.paginationBlogResponse)||void 0===o?void 0:o.items)||void 0===a?void 0:a.length)&&!t?this.paginationBlogResponse:await this.fetchBlogPosts(i);this.displayedBlogResponse=d,this.totalBlogs=d.total,this.lastPage=+(null===(h=null===(r=d.pages.last)||void 0===r?void 0:r.match(/&page=(\d+)/))||void 0===h?void 0:h[1])||1,this.nextPage=d.pages.next,this.previousPage=d.pages.previous,this.isLoading=!1,this.hasErrors=!1}catch(t){this.hasErrors=!0,console.log("Error",t)}}connectedCallback(){this.cmsEndpoint&&this.language&&this.blogsLimit&&(this.page?(this.currentPage=this.currentPage+ +this.page-1,this.getBlogArticleGrid(!1,+this.page)):this.getBlogArticleGrid())}componentDidLoad(){this.stylingContainer&&(null!=window.emMessageBus?r(this.stylingContainer,`${this.mbSource}.Style`):(this.clientStyling&&o(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl))),window.postMessage({type:"BlogArticlesGridLoaded"},window.location.href),this.device=function(){const t=navigator.userAgent.toLowerCase();let i="";return i=t.includes("android")||t.includes("iphone")||function(){const t=navigator.userAgent.toLowerCase();return!!t.includes("ipad")||t.indexOf("macintosh")>-1&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2}()?function(){const t=screen.availWidth;return t<600?"mobile":t>=600&&t<1100?"tablet":void 0}():"desktop",i}()}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}formatDate(t){return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(t))}render(){if(this.hasErrors)return n("div",{class:"BlogsContainer"},n("div",{class:"ErrorMessage"},s("error",this.language)));const t=[];for(let i=0;i<parseInt(this.blogsLimit);i++)t.push(n("div",{class:"GridContainer FeaturedPost Skeleton"},n("div",{class:"GridWrapper"},n("div",{class:"GridSector"},n("div",{class:"VisualContent LoadingImage"})),n("div",{class:"GridSector"},n("div",{class:"BlogTitle LoadingStripe LoadingSmallStripe"}),n("div",{class:"BlogDetails LoadingStripe LoadingMediumStripe"}),n("div",{class:"BlogLink LoadingStripe LoadingLongStripe"})))));return n("div",{ref:t=>this.stylingContainer=t},n("div",{class:"BlogPageContainer"},n("div",{class:"BlogGridPaginationWrapper"},1==this.paginationActive&&this.totalBlogs>+this.blogsLimit&&n("helper-pagination",{"next-page":this.nextPage,"prev-page":this.previousPage,offset:this.paginationBlogList.offset,limit:parseInt(this.blogsLimit,10),total:this.totalBlogs,language:this.language,"md-source":this.mbSource,"client-styling":this.clientStyling||this.defaultStyling,"client-styling-url":this.clientStylingUrl,"arrows-active":this.arrowsActive||!0,"secondary-arrows-active":this.secondaryArrowsActive||!1,"numbered-nav-active":this.numberedNavActive||!1})),!this.isLoading&&n("div",{class:`GridContainerWrapper BlogPage-${this.currentPage}`},this.displayedBlogResponse&&this.displayedBlogResponse.items.map((t=>{var i,e;return n("div",{key:t.postID,class:t.isFeaturedPost?"GridContainer FeaturedPost":"GridContainer"},n("div",{class:"GridWrapper"},n("div",{class:"GridSector"},this.showPublishingDate&&n("div",{class:"BlogDate"},this.formatDate(null==t?void 0:t.publishingDate)),this.showImage&&(null===(i=t.image)||void 0===i?void 0:i.src)?n("div",{class:"VisualContent",style:{background:`url(${this.setImage(t.image)}) no-repeat center center / cover`}}):(null===(e=t.video)||void 0===e?void 0:e.sources[this.device])?n("video",{class:"VisualContent",src:t.video.sources[this.device],controls:!0}):n("h1",{class:"VisualContent",style:{color:"#fff"}},"No Image")),n("div",{class:"GridSector"},this.showTitle&&n("div",{class:"BlogTitle"},null==t?void 0:t.title),this.showContent&&this.renderContentConditionally(null==t?void 0:t.descriptionPreview),this.showButton&&n("div",{class:"BlogLink"},n("button",{onClick:()=>this.getArticleId(null==t?void 0:t.postID,null==t?void 0:t.slug,null==t?void 0:t.customPath)},s("readmore",this.language))))))}))),this.isLoading&&n("div",{class:"GridContainerWrapper LoadingGrid"},t)))}static get watchers(){return{page:["watchEndpoint"],hasErrors:["watchEndpoint"],cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"],cmsEnv:["watchEndpoint"],userRoles:["watchEndpoint"],blogsLimit:["watchEndpoint"],eventId:["watchEndpoint"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}}};h.style=":host {\n display: block;\n}\n\n.BlogPageContainer {\n background: #0A0A17;\n padding: 20px;\n}\n\n.GridContainerWrapper {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 20px;\n}\n\n.BlogPage-0 .GridContainer.FeaturedPost:first-child {\n width: 100%;\n flex-basis: auto;\n}\n\n.GridContainer {\n container-type: inline-size;\n container-name: article;\n border-radius: 15px;\n color: #000;\n overflow: hidden;\n}\n.GridContainer.FeaturedPost:first-child {\n grid-column: 1/-1;\n width: 100%;\n}\n.GridContainer .GridWrapper {\n display: flex;\n flex-direction: row;\n height: 280px;\n background: var(--emw--color-white, #FFFFFF);\n}\n.GridContainer .GridSector {\n flex-basis: 50%;\n position: relative;\n}\n.GridContainer .GridSector:first-of-type {\n height: 280px;\n display: flex;\n}\n.GridContainer .GridSector:last-of-type {\n padding: 20px 40px;\n display: flex;\n flex-direction: column;\n}\n.GridContainer .VisualContent {\n width: 100%;\n}\n.GridContainer .BlogDate {\n position: absolute;\n bottom: 0px;\n left: 30px;\n font-size: 12px;\n border-radius: 5px 5px 0 0;\n padding: 10px;\n width: fit-content;\n text-align: center;\n color: var(--emw--color-white, #FFFFFF);\n background-color: #CD0B5E;\n z-index: 1;\n}\n.GridContainer .BlogTitle {\n font-size: 24px;\n color: #000;\n padding-bottom: 10px;\n}\n.GridContainer .BlogContent {\n display: -webkit-box;\n font-size: 14px;\n line-height: 1.2em;\n -webkit-line-clamp: 6;\n color: #000;\n -webkit-box-orient: vertical;\n box-sizing: border-box;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n.GridContainer .BlogLink {\n color: #000;\n position: absolute;\n bottom: 16px;\n}\n.GridContainer .BlogLink button {\n font-size: 14px;\n border: none;\n padding: 0;\n background: none;\n color: #22B04E;\n cursor: pointer;\n}\n\n@container article (max-width: 550px) {\n .GridContainer .GridWrapper {\n height: 380px;\n flex-direction: column;\n }\n .GridContainer .GridWrapper .GridSector:first-of-type {\n height: 120px;\n flex-shrink: 0;\n flex-basis: 150px;\n }\n .GridContainer .GridWrapper .GridSector:last-of-type {\n padding: 20px 20px 40px;\n }\n}\n.LoadingImage {\n width: 100%;\n height: 100%;\n background-color: var(--emw--color-gray-100, #E6E6E6);\n}\n\n.LoadingStripe {\n border: 1px solid var(--emw--color-white, #FFFFFF);\n height: 20%;\n background-color: var(--emw--color-gray-100, #E6E6E6);\n margin-bottom: 5px;\n}\n\n.LoadingSmallStripe {\n width: 40%;\n}\n\n.LoadingMediumStripe {\n width: 70%;\n}\n\n.BlogLink.LoadingLongStripe {\n position: static;\n width: 100%;\n}\n\n.GridContainerWrapper.LoadingGrid .GridSector {\n justify-content: space-around;\n}\n\n.GridContainerWrapper.LoadingGrid .LoadingImage, .GridContainerWrapper.LoadingGrid .LoadingStripe {\n animation: pulsatingLoader 2s ease-in-out 0s infinite reverse;\n -webkit-animation: pulsatingLoader 2s ease-in-out 0s infinite reverse;\n}\n\n@keyframes pulsatingLoader {\n 0% {\n opacity: 0.5;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0.5;\n }\n}\n@-webkit-keyframes pulsatingLoader {\n 0% {\n opacity: 0.5;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n opacity: 0.5;\n }\n}";const d=t=>!!(t.toLowerCase().match(/android/i)||t.toLowerCase().match(/blackberry|bb/i)||t.toLowerCase().match(/iphone|ipad|ipod/i)||t.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i)),l={en:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"},ro:{firstPage:"Prima",previousPage:"Anterior",nextPage:"Urmatoarea",lastPage:"Ultima"},fr:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"},ar:{firstPage:"First",previousPage:"Previous",nextPage:"Next",lastPage:"Last"},hu:{firstPage:"First",previousPage:"Previous",nextPage:"Következő",lastPage:"Last"},hr:{firstPage:"Prva",previousPage:"Prethodna",nextPage:"Slijedeća",lastPage:"Zadnja"}},c=(t,i)=>l[void 0!==i&&i in l?i:"en"][t],g=class{constructor(n){t(this,n),this.hpPageChange=i(this,"hpPageChange",7),this.userAgent=window.navigator.userAgent,this.currentPage=1,this.navigateTo=t=>{switch(t){case"firstPage":this.offsetInt=0;break;case"lastPage":this.offsetInt=this.endInt*this.limitInt;break;case"previousPage":this.offsetInt-=this.limitInt;break;case"nextPage":this.offsetInt+=this.limitInt;break;case"fivePagesBack":this.offsetInt-=5*this.limitInt,this.offsetInt=this.offsetInt<=0?0:this.offsetInt;break;case"fivePagesForward":this.offsetInt+=5*this.limitInt,this.offsetInt=this.offsetInt/this.limitInt>=this.endInt?this.endInt*this.limitInt:this.offsetInt}this.previousPage=!!this.offsetInt,this.hpPageChange.emit({offset:this.offsetInt,limit:this.limitInt,total:this.totalInt})},this.paginationNavigation=(t,i)=>{this.previousPage=!0,isNaN(t)?0===i&&this.currentPage<=4?this.navigateTo("firstPage"):0===i&&this.currentPage>4?this.navigateTo("fivePagesBack"):4===i&&this.endInt-this.currentPage>=2&&this.navigateTo("fivePagesForward"):1===t?(this.offsetInt=t-1,this.previousPage=!1):this.offsetInt=(t-1)*this.limitInt,this.hpPageChange.emit({offset:this.offsetInt,limit:this.limitInt,total:this.totalInt})},this.nextPage="",this.prevPage="",this.offset=0,this.limit=1,this.total=1,this.language="en",this.mbSource=void 0,this.clientStyling="",this.clientStylingUrl="",this.arrowsActive=void 0,this.secondaryArrowsActive=void 0,this.numberedNavActive=void 0,this.offsetInt=void 0,this.lastPage=!1,this.previousPage=!1,this.limitInt=void 0,this.totalInt=void 0,this.pagesArray=[],this.endInt=0}handleClientStylingChange(t,i){t!=i&&o(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(t,i){t!=i&&this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)}componentWillRender(){this.offsetInt=this.offset,this.limitInt=this.limit,this.currentPage=this.offsetInt/this.limitInt+1,this.limitInt=this.limit,this.totalInt=this.total,this.endInt=Math.ceil(this.totalInt/this.limitInt)-1,this.lastPage=!(this.offsetInt>=this.endInt*this.limitInt),1==this.currentPage||2==this.currentPage?(this.pagesArray=Array.from({length:4},((t,i)=>i+1)),this.pagesArray.push("...")):this.currentPage>=3&&this.endInt-this.currentPage>=2?(this.pagesArray=Array.from({length:3},((t,i)=>this.currentPage+i-1)),this.pagesArray.push("..."),this.pagesArray.unshift("...")):this.endInt-this.currentPage<3&&(this.pagesArray=Array.from({length:4},((t,i)=>this.endInt-2+i)),this.pagesArray.unshift("..."))}componentDidLoad(){this.stylingContainer&&(null!=window.emMessageBus?r(this.stylingContainer,`${this.mbSource}.Style`):(this.clientStyling&&o(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}render(){let t=n("ul",{class:"PaginationArea"},this.pagesArray.map(((t,i)=>n("li",{class:"PaginationItem"+(t===this.currentPage?" ActiveItem":" ")+" "+(d(this.userAgent)?"MobileButtons":"")},n("button",{disabled:t===this.currentPage,onClick:this.paginationNavigation.bind(this,t,i)},n("span",null,t)))))),i=n("button",{disabled:!this.prevPage,onClick:this.navigateTo.bind(this,"firstPage")},n("span",{class:"NavigationButton"},c("firstPage",this.language)),n("span",{class:"NavigationIcon"})),e=n("div",{class:"LeftItems"},this.secondaryArrowsActive&&i,n("button",{disabled:!this.prevPage,onClick:this.navigateTo.bind(this,"previousPage")},n("span",{class:"NavigationButton"},c("previousPage",this.language)),n("span",{class:"NavigationIcon"})));d(this.userAgent)&&(e=n("div",{class:"LeftItems"},n("button",{disabled:!this.prevPage,onClick:this.navigateTo.bind(this,"previousPage")},n("span",{class:"NavigationButton"},c("previousPage",this.language)),n("span",{class:"NavigationIcon"}))));let s=n("button",{disabled:!this.nextPage,onClick:this.navigateTo.bind(this,"lastPage")},n("span",{class:"NavigationButton"},c("lastPage",this.language)),n("span",{class:"NavigationIcon"})),o=n("div",{class:"RightItems"},n("button",{disabled:!this.nextPage,onClick:this.navigateTo.bind(this,"nextPage")},n("span",{class:"NavigationButton"},c("nextPage",this.language)),n("span",{class:"NavigationIcon"})),this.secondaryArrowsActive&&s);return d(this.userAgent)&&(o=n("div",{class:"RightItems"},n("button",{disabled:!this.nextPage,onClick:this.navigateTo.bind(this,"nextPage")},n("span",{class:"NavigationButton"},c("nextPage",this.language)),n("span",{class:"NavigationIcon"})))),n("div",{id:"PaginationContainer",ref:t=>this.stylingContainer=t},this.arrowsActive&&e,this.numberedNavActive&&t,this.arrowsActive&&o)}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"]}}};g.style='@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap");:host{display:block;font-family:"Roboto", sans-serif}#PaginationContainer{width:100%;margin:20px 0;display:inline-flex;justify-content:space-between;align-items:center}.LeftItems button:not(:first-child),.RightItems button:not(:last-child){margin:0 10px}.LeftItems button,.RightItems button{padding:0;background-color:#009993;border-color:#009993}.PaginationArea{display:inline-flex;gap:10px;list-style:none}.PaginationArea li{margin:0;padding:0}.PaginationArea li button{width:24px;height:24px;display:flex;border:0;padding:0;justify-content:center;align-items:center;background-color:transparent;color:#000;cursor:pointer;pointer-events:all}.PaginationItem.ActiveItem button{background:#009993;border-color:#009993;color:#fff}.PaginationItem.ActiveItem button:disabled{pointer-events:none;cursor:not-allowed}.PaginationItem button:hover,.PaginationItem button:active{background:#009993;border-color:#009993;color:#fff;opacity:0.8}button{width:100px;height:32px;border:1px solid #524e52;border-radius:5px;background:#524e52;color:#fff;font-size:14px;font:inherit;cursor:pointer;transition:all 0.1s linear;text-transform:uppercase;text-align:center;letter-spacing:0}button:hover,button:active{background:#004D4A;border-color:#004D4A}button:disabled{background-color:#ccc;border-color:#ccc;color:#fff;cursor:not-allowed}@media screen and (max-width: 720px){button{width:90px;font-size:14px}}@media screen and (max-width: 480px){button{width:70px;font-size:14px}.paginationArea{padding:5px}}@media screen and (max-width: 320px){button{width:58px;font-size:12px}.paginationArea{padding:5px;gap:5px}}@media (hover: none){.paginationItem button:hover{background:inherit;border-color:inherit;color:inherit;opacity:1}.paginationItem.activeItem button:hover{background:#009993;border-color:#009993;color:#fff}}';export{h as blog_articles_grid,g as helper_pagination}
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["blog-articles-grid_2.cjs",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"
|
|
22
|
+
return index.bootstrapLazy([["blog-articles-grid_2.cjs",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"displayedBlogResponse":[32],"paginationBlogResponse":[32],"allBlogResponse":[32],"totalBlogs":[32]},[[8,"BannerMatrixReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]],{"page":["watchEndpoint"],"hasErrors":["watchEndpoint"],"cmsEndpoint":["watchEndpoint"],"language":["watchEndpoint"],"cmsEnv":["watchEndpoint"],"userRoles":["watchEndpoint"],"blogsLimit":["watchEndpoint"],"eventId":["watchEndpoint"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}],[1,"helper-pagination",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"mbSource":[1,"mb-source"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[1537,"client-styling-url"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -268,7 +268,9 @@ const BlogArticlesGrid = class {
|
|
|
268
268
|
this.nextPage = '';
|
|
269
269
|
this.previousPage = '';
|
|
270
270
|
this.device = '';
|
|
271
|
-
this.
|
|
271
|
+
this.displayedBlogResponse = undefined;
|
|
272
|
+
this.paginationBlogResponse = undefined;
|
|
273
|
+
this.allBlogResponse = undefined;
|
|
272
274
|
this.totalBlogs = 0;
|
|
273
275
|
}
|
|
274
276
|
getArticleId(postId, slug, customPath) {
|
|
@@ -285,7 +287,7 @@ const BlogArticlesGrid = class {
|
|
|
285
287
|
}
|
|
286
288
|
watchEndpoint(newValue, oldValue) {
|
|
287
289
|
this.currentPage = parseInt(this.page) - 1;
|
|
288
|
-
if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
290
|
+
if ((newValue || newValue === '') && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
289
291
|
this.getBlogArticleGrid();
|
|
290
292
|
}
|
|
291
293
|
}
|
|
@@ -316,7 +318,7 @@ const BlogArticlesGrid = class {
|
|
|
316
318
|
return;
|
|
317
319
|
}
|
|
318
320
|
window.postMessage({ type: 'BlogArticlesGridActivePagination', currentPage: this.currentPage }, window.location.href);
|
|
319
|
-
this.getBlogArticleGrid();
|
|
321
|
+
this.getBlogArticleGrid(true);
|
|
320
322
|
}
|
|
321
323
|
sortArticlesByDate(blogItems) {
|
|
322
324
|
blogItems.sort((a, b) => {
|
|
@@ -344,15 +346,14 @@ const BlogArticlesGrid = class {
|
|
|
344
346
|
}
|
|
345
347
|
return blogItems;
|
|
346
348
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
url.searchParams.append('
|
|
351
|
-
url.searchParams.append('page', JSON.stringify(page ? page : this.currentPage + 1));
|
|
349
|
+
async fetchBlogPosts(page, allPosts = false) {
|
|
350
|
+
const url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
|
|
351
|
+
url.searchParams.append('per_page', allPosts ? '300' : this.blogsLimit);
|
|
352
|
+
url.searchParams.append('page', `${page ? page : this.currentPage + 1}`);
|
|
352
353
|
url.searchParams.append('env', this.cmsEnv);
|
|
353
354
|
url.searchParams.append('userRoles', this.userRoles);
|
|
354
355
|
url.searchParams.append('device', getDevicePlatform());
|
|
355
|
-
fetch(url.href)
|
|
356
|
+
return fetch(url.href)
|
|
356
357
|
.then((res) => {
|
|
357
358
|
if (res.status >= 300) {
|
|
358
359
|
this.hasErrors = true;
|
|
@@ -360,42 +361,75 @@ const BlogArticlesGrid = class {
|
|
|
360
361
|
}
|
|
361
362
|
return res.json();
|
|
362
363
|
})
|
|
363
|
-
.then((
|
|
364
|
-
let
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
364
|
+
.then((blogResponse) => {
|
|
365
|
+
let items = blogResponse.items;
|
|
366
|
+
const latestFeatured = this.findLatestFeatured(items);
|
|
367
|
+
items = this.sortArticlesByDate(items);
|
|
368
|
+
items = this.moveLatestFeatureToStart(items, latestFeatured);
|
|
369
|
+
items = items.map((item) => {
|
|
370
|
+
return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
|
|
371
|
+
});
|
|
372
|
+
blogResponse = Object.assign(Object.assign({}, blogResponse), { items });
|
|
373
|
+
if (allPosts) {
|
|
374
|
+
this.allBlogResponse = blogResponse;
|
|
371
375
|
}
|
|
372
376
|
else {
|
|
373
|
-
|
|
374
|
-
this.totalBlogs = blogContent.total;
|
|
377
|
+
this.paginationBlogResponse = blogResponse;
|
|
375
378
|
}
|
|
376
|
-
|
|
377
|
-
this.nextPage = blogContent.pages.next;
|
|
378
|
-
this.previousPage = blogContent.pages.previous;
|
|
379
|
-
const latestFeatured = this.findLatestFeatured(blogItems);
|
|
380
|
-
this.blogData = this.sortArticlesByDate(blogItems);
|
|
381
|
-
this.blogData = this.moveLatestFeatureToStart(blogItems, latestFeatured);
|
|
382
|
-
this.blogData = blogItems.map((item) => {
|
|
383
|
-
return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
|
|
384
|
-
});
|
|
385
|
-
this.isLoading = false;
|
|
386
|
-
this.hasErrors = false;
|
|
379
|
+
return blogResponse;
|
|
387
380
|
})
|
|
388
381
|
.catch((err) => {
|
|
389
382
|
this.hasErrors = true;
|
|
390
383
|
console.log('Error', err);
|
|
391
|
-
|
|
392
|
-
|
|
384
|
+
return {};
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
async getBlogArticleGrid(forceFetch = false, page) {
|
|
388
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
389
|
+
this.isLoading = true;
|
|
390
|
+
try {
|
|
391
|
+
let blogResponse;
|
|
392
|
+
const foundEventId = this.eventId && this.eventId.length > 0;
|
|
393
|
+
if (foundEventId) {
|
|
394
|
+
// TODO: this is a temporary solution for filter blogPost by eventId from all blog posts.
|
|
395
|
+
// apijson should have functionality to filter in backend side in future.
|
|
396
|
+
const allBlogData = ((_a = this.allBlogResponse) === null || _a === void 0 ? void 0 : _a.items) ? this.allBlogResponse : await this.fetchBlogPosts(1, true);
|
|
397
|
+
const filteredItems = allBlogData.items.filter(({ eventIds }) => eventIds.includes(this.eventId));
|
|
398
|
+
if (filteredItems.length) {
|
|
399
|
+
blogResponse = Object.assign(Object.assign({}, allBlogData), { items: filteredItems, total: Math.min(parseInt(this.blogsLimit), filteredItems.length) });
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
// if eventId not match any blogPost, show default behavior (pagination blogPosts)
|
|
403
|
+
blogResponse =
|
|
404
|
+
((_c = (_b = this.paginationBlogResponse) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.length) && !forceFetch
|
|
405
|
+
? this.paginationBlogResponse
|
|
406
|
+
: await this.fetchBlogPosts(page);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
blogResponse =
|
|
411
|
+
((_e = (_d = this.paginationBlogResponse) === null || _d === void 0 ? void 0 : _d.items) === null || _e === void 0 ? void 0 : _e.length) && !forceFetch
|
|
412
|
+
? this.paginationBlogResponse
|
|
413
|
+
: await this.fetchBlogPosts(page);
|
|
414
|
+
}
|
|
415
|
+
this.displayedBlogResponse = blogResponse;
|
|
416
|
+
this.totalBlogs = blogResponse.total;
|
|
417
|
+
this.lastPage = +((_g = (_f = blogResponse.pages.last) === null || _f === void 0 ? void 0 : _f.match(/&page=(\d+)/)) === null || _g === void 0 ? void 0 : _g[1]) || 1;
|
|
418
|
+
this.nextPage = blogResponse.pages.next;
|
|
419
|
+
this.previousPage = blogResponse.pages.previous;
|
|
420
|
+
this.isLoading = false;
|
|
421
|
+
this.hasErrors = false;
|
|
422
|
+
}
|
|
423
|
+
catch (err) {
|
|
424
|
+
this.hasErrors = true;
|
|
425
|
+
console.log('Error', err);
|
|
426
|
+
}
|
|
393
427
|
}
|
|
394
428
|
connectedCallback() {
|
|
395
429
|
if (this.cmsEndpoint && this.language && this.blogsLimit) {
|
|
396
430
|
if (this.page) {
|
|
397
431
|
this.currentPage = this.currentPage + +this.page - 1;
|
|
398
|
-
this.getBlogArticleGrid(+this.page);
|
|
432
|
+
this.getBlogArticleGrid(false, +this.page);
|
|
399
433
|
}
|
|
400
434
|
else {
|
|
401
435
|
this.getBlogArticleGrid();
|
|
@@ -434,7 +468,7 @@ const BlogArticlesGrid = class {
|
|
|
434
468
|
placeholderCards.push(index.h("div", { class: "GridContainer FeaturedPost Skeleton" }, index.h("div", { class: "GridWrapper" }, index.h("div", { class: "GridSector" }, index.h("div", { class: "VisualContent LoadingImage" })), index.h("div", { class: "GridSector" }, index.h("div", { class: "BlogTitle LoadingStripe LoadingSmallStripe" }), index.h("div", { class: "BlogDetails LoadingStripe LoadingMediumStripe" }), index.h("div", { class: "BlogLink LoadingStripe LoadingLongStripe" })))));
|
|
435
469
|
}
|
|
436
470
|
return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("div", { class: "BlogPageContainer" }, index.h("div", { class: "BlogGridPaginationWrapper" }, this.paginationActive == true && this.totalBlogs > +this.blogsLimit && index.h("helper-pagination", { "next-page": this.nextPage, "prev-page": this.previousPage, offset: this.paginationBlogList.offset, limit: parseInt(this.blogsLimit, 10), total: this.totalBlogs, language: this.language, "md-source": this.mbSource, "client-styling": this.clientStyling || this.defaultStyling, "client-styling-url": this.clientStylingUrl, "arrows-active": this.arrowsActive || true, "secondary-arrows-active": this.secondaryArrowsActive || false, "numbered-nav-active": this.numberedNavActive || false })), (!this.isLoading) &&
|
|
437
|
-
index.h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.
|
|
471
|
+
index.h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.displayedBlogResponse && this.displayedBlogResponse.items.map((data) => {
|
|
438
472
|
var _a, _b;
|
|
439
473
|
return index.h("div", { key: data.postID, class: data.isFeaturedPost ? 'GridContainer FeaturedPost' : 'GridContainer' }, index.h("div", { class: "GridWrapper" }, index.h("div", { class: "GridSector" }, this.showPublishingDate &&
|
|
440
474
|
index.h("div", { class: "BlogDate" }, this.formatDate(data === null || data === void 0 ? void 0 : data.publishingDate)), this.showImage && ((_a = data.image) === null || _a === void 0 ? void 0 : _a.src) ? (index.h("div", { class: "VisualContent", style: { background: `url(${this.setImage(data.image)}) no-repeat center center / cover` } })) : (((_b = data.video) === null || _b === void 0 ? void 0 : _b.sources[this.device]) ? (index.h("video", { class: "VisualContent", src: data.video.sources[this.device], controls: true })) : (index.h("h1", { class: "VisualContent", style: { color: "#fff" } }, "No Image")))), index.h("div", { class: "GridSector" }, this.showTitle &&
|
|
@@ -452,6 +486,7 @@ const BlogArticlesGrid = class {
|
|
|
452
486
|
"cmsEnv": ["watchEndpoint"],
|
|
453
487
|
"userRoles": ["watchEndpoint"],
|
|
454
488
|
"blogsLimit": ["watchEndpoint"],
|
|
489
|
+
"eventId": ["watchEndpoint"],
|
|
455
490
|
"clientStyling": ["handleClientStylingChange"],
|
|
456
491
|
"clientStylingUrl": ["handleClientStylingChangeURL"]
|
|
457
492
|
}; }
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
|
10
10
|
await appGlobals.globalScripts();
|
|
11
|
-
return index.bootstrapLazy([["blog-articles-grid_2.cjs",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"
|
|
11
|
+
return index.bootstrapLazy([["blog-articles-grid_2.cjs",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"displayedBlogResponse":[32],"paginationBlogResponse":[32],"allBlogResponse":[32],"totalBlogs":[32]},[[8,"BannerMatrixReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]],{"page":["watchEndpoint"],"hasErrors":["watchEndpoint"],"cmsEndpoint":["watchEndpoint"],"language":["watchEndpoint"],"cmsEnv":["watchEndpoint"],"userRoles":["watchEndpoint"],"blogsLimit":["watchEndpoint"],"eventId":["watchEndpoint"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}],[1,"helper-pagination",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"mbSource":[1,"mb-source"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[1537,"client-styling-url"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}]]]], options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|
|
@@ -114,7 +114,9 @@ export class BlogArticlesGrid {
|
|
|
114
114
|
this.nextPage = '';
|
|
115
115
|
this.previousPage = '';
|
|
116
116
|
this.device = '';
|
|
117
|
-
this.
|
|
117
|
+
this.displayedBlogResponse = undefined;
|
|
118
|
+
this.paginationBlogResponse = undefined;
|
|
119
|
+
this.allBlogResponse = undefined;
|
|
118
120
|
this.totalBlogs = 0;
|
|
119
121
|
}
|
|
120
122
|
getArticleId(postId, slug, customPath) {
|
|
@@ -131,7 +133,7 @@ export class BlogArticlesGrid {
|
|
|
131
133
|
}
|
|
132
134
|
watchEndpoint(newValue, oldValue) {
|
|
133
135
|
this.currentPage = parseInt(this.page) - 1;
|
|
134
|
-
if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
136
|
+
if ((newValue || newValue === '') && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
135
137
|
this.getBlogArticleGrid();
|
|
136
138
|
}
|
|
137
139
|
}
|
|
@@ -162,7 +164,7 @@ export class BlogArticlesGrid {
|
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
166
|
window.postMessage({ type: 'BlogArticlesGridActivePagination', currentPage: this.currentPage }, window.location.href);
|
|
165
|
-
this.getBlogArticleGrid();
|
|
167
|
+
this.getBlogArticleGrid(true);
|
|
166
168
|
}
|
|
167
169
|
sortArticlesByDate(blogItems) {
|
|
168
170
|
blogItems.sort((a, b) => {
|
|
@@ -190,15 +192,14 @@ export class BlogArticlesGrid {
|
|
|
190
192
|
}
|
|
191
193
|
return blogItems;
|
|
192
194
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
url.searchParams.append('
|
|
197
|
-
url.searchParams.append('page', JSON.stringify(page ? page : this.currentPage + 1));
|
|
195
|
+
async fetchBlogPosts(page, allPosts = false) {
|
|
196
|
+
const url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
|
|
197
|
+
url.searchParams.append('per_page', allPosts ? '300' : this.blogsLimit);
|
|
198
|
+
url.searchParams.append('page', `${page ? page : this.currentPage + 1}`);
|
|
198
199
|
url.searchParams.append('env', this.cmsEnv);
|
|
199
200
|
url.searchParams.append('userRoles', this.userRoles);
|
|
200
201
|
url.searchParams.append('device', getDevicePlatform());
|
|
201
|
-
fetch(url.href)
|
|
202
|
+
return fetch(url.href)
|
|
202
203
|
.then((res) => {
|
|
203
204
|
if (res.status >= 300) {
|
|
204
205
|
this.hasErrors = true;
|
|
@@ -206,42 +207,75 @@ export class BlogArticlesGrid {
|
|
|
206
207
|
}
|
|
207
208
|
return res.json();
|
|
208
209
|
})
|
|
209
|
-
.then((
|
|
210
|
-
let
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
.then((blogResponse) => {
|
|
211
|
+
let items = blogResponse.items;
|
|
212
|
+
const latestFeatured = this.findLatestFeatured(items);
|
|
213
|
+
items = this.sortArticlesByDate(items);
|
|
214
|
+
items = this.moveLatestFeatureToStart(items, latestFeatured);
|
|
215
|
+
items = items.map((item) => {
|
|
216
|
+
return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
|
|
217
|
+
});
|
|
218
|
+
blogResponse = Object.assign(Object.assign({}, blogResponse), { items });
|
|
219
|
+
if (allPosts) {
|
|
220
|
+
this.allBlogResponse = blogResponse;
|
|
217
221
|
}
|
|
218
222
|
else {
|
|
219
|
-
|
|
220
|
-
this.totalBlogs = blogContent.total;
|
|
223
|
+
this.paginationBlogResponse = blogResponse;
|
|
221
224
|
}
|
|
222
|
-
|
|
223
|
-
this.nextPage = blogContent.pages.next;
|
|
224
|
-
this.previousPage = blogContent.pages.previous;
|
|
225
|
-
const latestFeatured = this.findLatestFeatured(blogItems);
|
|
226
|
-
this.blogData = this.sortArticlesByDate(blogItems);
|
|
227
|
-
this.blogData = this.moveLatestFeatureToStart(blogItems, latestFeatured);
|
|
228
|
-
this.blogData = blogItems.map((item) => {
|
|
229
|
-
return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
|
|
230
|
-
});
|
|
231
|
-
this.isLoading = false;
|
|
232
|
-
this.hasErrors = false;
|
|
225
|
+
return blogResponse;
|
|
233
226
|
})
|
|
234
227
|
.catch((err) => {
|
|
235
228
|
this.hasErrors = true;
|
|
236
229
|
console.log('Error', err);
|
|
237
|
-
|
|
238
|
-
|
|
230
|
+
return {};
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
async getBlogArticleGrid(forceFetch = false, page) {
|
|
234
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
235
|
+
this.isLoading = true;
|
|
236
|
+
try {
|
|
237
|
+
let blogResponse;
|
|
238
|
+
const foundEventId = this.eventId && this.eventId.length > 0;
|
|
239
|
+
if (foundEventId) {
|
|
240
|
+
// TODO: this is a temporary solution for filter blogPost by eventId from all blog posts.
|
|
241
|
+
// apijson should have functionality to filter in backend side in future.
|
|
242
|
+
const allBlogData = ((_a = this.allBlogResponse) === null || _a === void 0 ? void 0 : _a.items) ? this.allBlogResponse : await this.fetchBlogPosts(1, true);
|
|
243
|
+
const filteredItems = allBlogData.items.filter(({ eventIds }) => eventIds.includes(this.eventId));
|
|
244
|
+
if (filteredItems.length) {
|
|
245
|
+
blogResponse = Object.assign(Object.assign({}, allBlogData), { items: filteredItems, total: Math.min(parseInt(this.blogsLimit), filteredItems.length) });
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
// if eventId not match any blogPost, show default behavior (pagination blogPosts)
|
|
249
|
+
blogResponse =
|
|
250
|
+
((_c = (_b = this.paginationBlogResponse) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.length) && !forceFetch
|
|
251
|
+
? this.paginationBlogResponse
|
|
252
|
+
: await this.fetchBlogPosts(page);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
blogResponse =
|
|
257
|
+
((_e = (_d = this.paginationBlogResponse) === null || _d === void 0 ? void 0 : _d.items) === null || _e === void 0 ? void 0 : _e.length) && !forceFetch
|
|
258
|
+
? this.paginationBlogResponse
|
|
259
|
+
: await this.fetchBlogPosts(page);
|
|
260
|
+
}
|
|
261
|
+
this.displayedBlogResponse = blogResponse;
|
|
262
|
+
this.totalBlogs = blogResponse.total;
|
|
263
|
+
this.lastPage = +((_g = (_f = blogResponse.pages.last) === null || _f === void 0 ? void 0 : _f.match(/&page=(\d+)/)) === null || _g === void 0 ? void 0 : _g[1]) || 1;
|
|
264
|
+
this.nextPage = blogResponse.pages.next;
|
|
265
|
+
this.previousPage = blogResponse.pages.previous;
|
|
266
|
+
this.isLoading = false;
|
|
267
|
+
this.hasErrors = false;
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
this.hasErrors = true;
|
|
271
|
+
console.log('Error', err);
|
|
272
|
+
}
|
|
239
273
|
}
|
|
240
274
|
connectedCallback() {
|
|
241
275
|
if (this.cmsEndpoint && this.language && this.blogsLimit) {
|
|
242
276
|
if (this.page) {
|
|
243
277
|
this.currentPage = this.currentPage + +this.page - 1;
|
|
244
|
-
this.getBlogArticleGrid(+this.page);
|
|
278
|
+
this.getBlogArticleGrid(false, +this.page);
|
|
245
279
|
}
|
|
246
280
|
else {
|
|
247
281
|
this.getBlogArticleGrid();
|
|
@@ -280,7 +314,7 @@ export class BlogArticlesGrid {
|
|
|
280
314
|
placeholderCards.push(h("div", { class: "GridContainer FeaturedPost Skeleton" }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, h("div", { class: "VisualContent LoadingImage" })), h("div", { class: "GridSector" }, h("div", { class: "BlogTitle LoadingStripe LoadingSmallStripe" }), h("div", { class: "BlogDetails LoadingStripe LoadingMediumStripe" }), h("div", { class: "BlogLink LoadingStripe LoadingLongStripe" })))));
|
|
281
315
|
}
|
|
282
316
|
return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "BlogPageContainer" }, h("div", { class: "BlogGridPaginationWrapper" }, this.paginationActive == true && this.totalBlogs > +this.blogsLimit && h("helper-pagination", { "next-page": this.nextPage, "prev-page": this.previousPage, offset: this.paginationBlogList.offset, limit: parseInt(this.blogsLimit, 10), total: this.totalBlogs, language: this.language, "md-source": this.mbSource, "client-styling": this.clientStyling || this.defaultStyling, "client-styling-url": this.clientStylingUrl, "arrows-active": this.arrowsActive || true, "secondary-arrows-active": this.secondaryArrowsActive || false, "numbered-nav-active": this.numberedNavActive || false })), (!this.isLoading) &&
|
|
283
|
-
h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.
|
|
317
|
+
h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.displayedBlogResponse && this.displayedBlogResponse.items.map((data) => {
|
|
284
318
|
var _a, _b;
|
|
285
319
|
return h("div", { key: data.postID, class: data.isFeaturedPost ? 'GridContainer FeaturedPost' : 'GridContainer' }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, this.showPublishingDate &&
|
|
286
320
|
h("div", { class: "BlogDate" }, this.formatDate(data === null || data === void 0 ? void 0 : data.publishingDate)), this.showImage && ((_a = data.image) === null || _a === void 0 ? void 0 : _a.src) ? (h("div", { class: "VisualContent", style: { background: `url(${this.setImage(data.image)}) no-repeat center center / cover` } })) : (((_b = data.video) === null || _b === void 0 ? void 0 : _b.sources[this.device]) ? (h("video", { class: "VisualContent", src: data.video.sources[this.device], controls: true })) : (h("h1", { class: "VisualContent", style: { color: "#fff" } }, "No Image")))), h("div", { class: "GridSector" }, this.showTitle &&
|
|
@@ -704,7 +738,9 @@ export class BlogArticlesGrid {
|
|
|
704
738
|
"nextPage": {},
|
|
705
739
|
"previousPage": {},
|
|
706
740
|
"device": {},
|
|
707
|
-
"
|
|
741
|
+
"displayedBlogResponse": {},
|
|
742
|
+
"paginationBlogResponse": {},
|
|
743
|
+
"allBlogResponse": {},
|
|
708
744
|
"totalBlogs": {}
|
|
709
745
|
};
|
|
710
746
|
}
|
|
@@ -753,6 +789,9 @@ export class BlogArticlesGrid {
|
|
|
753
789
|
}, {
|
|
754
790
|
"propName": "blogsLimit",
|
|
755
791
|
"methodName": "watchEndpoint"
|
|
792
|
+
}, {
|
|
793
|
+
"propName": "eventId",
|
|
794
|
+
"methodName": "watchEndpoint"
|
|
756
795
|
}, {
|
|
757
796
|
"propName": "clientStyling",
|
|
758
797
|
"methodName": "handleClientStylingChange"
|
|
@@ -16,5 +16,5 @@ var patchBrowser = () => {
|
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(async (options) => {
|
|
18
18
|
await globalScripts();
|
|
19
|
-
return bootstrapLazy([["blog-articles-grid_2",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"
|
|
19
|
+
return bootstrapLazy([["blog-articles-grid_2",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"displayedBlogResponse":[32],"paginationBlogResponse":[32],"allBlogResponse":[32],"totalBlogs":[32]},[[8,"BannerMatrixReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]],{"page":["watchEndpoint"],"hasErrors":["watchEndpoint"],"cmsEndpoint":["watchEndpoint"],"language":["watchEndpoint"],"cmsEnv":["watchEndpoint"],"userRoles":["watchEndpoint"],"blogsLimit":["watchEndpoint"],"eventId":["watchEndpoint"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}],[1,"helper-pagination",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"mbSource":[1,"mb-source"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[1537,"client-styling-url"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}]]]], options);
|
|
20
20
|
});
|
|
@@ -264,7 +264,9 @@ const BlogArticlesGrid = class {
|
|
|
264
264
|
this.nextPage = '';
|
|
265
265
|
this.previousPage = '';
|
|
266
266
|
this.device = '';
|
|
267
|
-
this.
|
|
267
|
+
this.displayedBlogResponse = undefined;
|
|
268
|
+
this.paginationBlogResponse = undefined;
|
|
269
|
+
this.allBlogResponse = undefined;
|
|
268
270
|
this.totalBlogs = 0;
|
|
269
271
|
}
|
|
270
272
|
getArticleId(postId, slug, customPath) {
|
|
@@ -281,7 +283,7 @@ const BlogArticlesGrid = class {
|
|
|
281
283
|
}
|
|
282
284
|
watchEndpoint(newValue, oldValue) {
|
|
283
285
|
this.currentPage = parseInt(this.page) - 1;
|
|
284
|
-
if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
286
|
+
if ((newValue || newValue === '') && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
285
287
|
this.getBlogArticleGrid();
|
|
286
288
|
}
|
|
287
289
|
}
|
|
@@ -312,7 +314,7 @@ const BlogArticlesGrid = class {
|
|
|
312
314
|
return;
|
|
313
315
|
}
|
|
314
316
|
window.postMessage({ type: 'BlogArticlesGridActivePagination', currentPage: this.currentPage }, window.location.href);
|
|
315
|
-
this.getBlogArticleGrid();
|
|
317
|
+
this.getBlogArticleGrid(true);
|
|
316
318
|
}
|
|
317
319
|
sortArticlesByDate(blogItems) {
|
|
318
320
|
blogItems.sort((a, b) => {
|
|
@@ -340,15 +342,14 @@ const BlogArticlesGrid = class {
|
|
|
340
342
|
}
|
|
341
343
|
return blogItems;
|
|
342
344
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
url.searchParams.append('
|
|
347
|
-
url.searchParams.append('page', JSON.stringify(page ? page : this.currentPage + 1));
|
|
345
|
+
async fetchBlogPosts(page, allPosts = false) {
|
|
346
|
+
const url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
|
|
347
|
+
url.searchParams.append('per_page', allPosts ? '300' : this.blogsLimit);
|
|
348
|
+
url.searchParams.append('page', `${page ? page : this.currentPage + 1}`);
|
|
348
349
|
url.searchParams.append('env', this.cmsEnv);
|
|
349
350
|
url.searchParams.append('userRoles', this.userRoles);
|
|
350
351
|
url.searchParams.append('device', getDevicePlatform());
|
|
351
|
-
fetch(url.href)
|
|
352
|
+
return fetch(url.href)
|
|
352
353
|
.then((res) => {
|
|
353
354
|
if (res.status >= 300) {
|
|
354
355
|
this.hasErrors = true;
|
|
@@ -356,42 +357,75 @@ const BlogArticlesGrid = class {
|
|
|
356
357
|
}
|
|
357
358
|
return res.json();
|
|
358
359
|
})
|
|
359
|
-
.then((
|
|
360
|
-
let
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
360
|
+
.then((blogResponse) => {
|
|
361
|
+
let items = blogResponse.items;
|
|
362
|
+
const latestFeatured = this.findLatestFeatured(items);
|
|
363
|
+
items = this.sortArticlesByDate(items);
|
|
364
|
+
items = this.moveLatestFeatureToStart(items, latestFeatured);
|
|
365
|
+
items = items.map((item) => {
|
|
366
|
+
return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
|
|
367
|
+
});
|
|
368
|
+
blogResponse = Object.assign(Object.assign({}, blogResponse), { items });
|
|
369
|
+
if (allPosts) {
|
|
370
|
+
this.allBlogResponse = blogResponse;
|
|
367
371
|
}
|
|
368
372
|
else {
|
|
369
|
-
|
|
370
|
-
this.totalBlogs = blogContent.total;
|
|
373
|
+
this.paginationBlogResponse = blogResponse;
|
|
371
374
|
}
|
|
372
|
-
|
|
373
|
-
this.nextPage = blogContent.pages.next;
|
|
374
|
-
this.previousPage = blogContent.pages.previous;
|
|
375
|
-
const latestFeatured = this.findLatestFeatured(blogItems);
|
|
376
|
-
this.blogData = this.sortArticlesByDate(blogItems);
|
|
377
|
-
this.blogData = this.moveLatestFeatureToStart(blogItems, latestFeatured);
|
|
378
|
-
this.blogData = blogItems.map((item) => {
|
|
379
|
-
return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
|
|
380
|
-
});
|
|
381
|
-
this.isLoading = false;
|
|
382
|
-
this.hasErrors = false;
|
|
375
|
+
return blogResponse;
|
|
383
376
|
})
|
|
384
377
|
.catch((err) => {
|
|
385
378
|
this.hasErrors = true;
|
|
386
379
|
console.log('Error', err);
|
|
387
|
-
|
|
388
|
-
|
|
380
|
+
return {};
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
async getBlogArticleGrid(forceFetch = false, page) {
|
|
384
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
385
|
+
this.isLoading = true;
|
|
386
|
+
try {
|
|
387
|
+
let blogResponse;
|
|
388
|
+
const foundEventId = this.eventId && this.eventId.length > 0;
|
|
389
|
+
if (foundEventId) {
|
|
390
|
+
// TODO: this is a temporary solution for filter blogPost by eventId from all blog posts.
|
|
391
|
+
// apijson should have functionality to filter in backend side in future.
|
|
392
|
+
const allBlogData = ((_a = this.allBlogResponse) === null || _a === void 0 ? void 0 : _a.items) ? this.allBlogResponse : await this.fetchBlogPosts(1, true);
|
|
393
|
+
const filteredItems = allBlogData.items.filter(({ eventIds }) => eventIds.includes(this.eventId));
|
|
394
|
+
if (filteredItems.length) {
|
|
395
|
+
blogResponse = Object.assign(Object.assign({}, allBlogData), { items: filteredItems, total: Math.min(parseInt(this.blogsLimit), filteredItems.length) });
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
// if eventId not match any blogPost, show default behavior (pagination blogPosts)
|
|
399
|
+
blogResponse =
|
|
400
|
+
((_c = (_b = this.paginationBlogResponse) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.length) && !forceFetch
|
|
401
|
+
? this.paginationBlogResponse
|
|
402
|
+
: await this.fetchBlogPosts(page);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
blogResponse =
|
|
407
|
+
((_e = (_d = this.paginationBlogResponse) === null || _d === void 0 ? void 0 : _d.items) === null || _e === void 0 ? void 0 : _e.length) && !forceFetch
|
|
408
|
+
? this.paginationBlogResponse
|
|
409
|
+
: await this.fetchBlogPosts(page);
|
|
410
|
+
}
|
|
411
|
+
this.displayedBlogResponse = blogResponse;
|
|
412
|
+
this.totalBlogs = blogResponse.total;
|
|
413
|
+
this.lastPage = +((_g = (_f = blogResponse.pages.last) === null || _f === void 0 ? void 0 : _f.match(/&page=(\d+)/)) === null || _g === void 0 ? void 0 : _g[1]) || 1;
|
|
414
|
+
this.nextPage = blogResponse.pages.next;
|
|
415
|
+
this.previousPage = blogResponse.pages.previous;
|
|
416
|
+
this.isLoading = false;
|
|
417
|
+
this.hasErrors = false;
|
|
418
|
+
}
|
|
419
|
+
catch (err) {
|
|
420
|
+
this.hasErrors = true;
|
|
421
|
+
console.log('Error', err);
|
|
422
|
+
}
|
|
389
423
|
}
|
|
390
424
|
connectedCallback() {
|
|
391
425
|
if (this.cmsEndpoint && this.language && this.blogsLimit) {
|
|
392
426
|
if (this.page) {
|
|
393
427
|
this.currentPage = this.currentPage + +this.page - 1;
|
|
394
|
-
this.getBlogArticleGrid(+this.page);
|
|
428
|
+
this.getBlogArticleGrid(false, +this.page);
|
|
395
429
|
}
|
|
396
430
|
else {
|
|
397
431
|
this.getBlogArticleGrid();
|
|
@@ -430,7 +464,7 @@ const BlogArticlesGrid = class {
|
|
|
430
464
|
placeholderCards.push(h("div", { class: "GridContainer FeaturedPost Skeleton" }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, h("div", { class: "VisualContent LoadingImage" })), h("div", { class: "GridSector" }, h("div", { class: "BlogTitle LoadingStripe LoadingSmallStripe" }), h("div", { class: "BlogDetails LoadingStripe LoadingMediumStripe" }), h("div", { class: "BlogLink LoadingStripe LoadingLongStripe" })))));
|
|
431
465
|
}
|
|
432
466
|
return (h("div", { ref: el => this.stylingContainer = el }, h("div", { class: "BlogPageContainer" }, h("div", { class: "BlogGridPaginationWrapper" }, this.paginationActive == true && this.totalBlogs > +this.blogsLimit && h("helper-pagination", { "next-page": this.nextPage, "prev-page": this.previousPage, offset: this.paginationBlogList.offset, limit: parseInt(this.blogsLimit, 10), total: this.totalBlogs, language: this.language, "md-source": this.mbSource, "client-styling": this.clientStyling || this.defaultStyling, "client-styling-url": this.clientStylingUrl, "arrows-active": this.arrowsActive || true, "secondary-arrows-active": this.secondaryArrowsActive || false, "numbered-nav-active": this.numberedNavActive || false })), (!this.isLoading) &&
|
|
433
|
-
h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.
|
|
467
|
+
h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.displayedBlogResponse && this.displayedBlogResponse.items.map((data) => {
|
|
434
468
|
var _a, _b;
|
|
435
469
|
return h("div", { key: data.postID, class: data.isFeaturedPost ? 'GridContainer FeaturedPost' : 'GridContainer' }, h("div", { class: "GridWrapper" }, h("div", { class: "GridSector" }, this.showPublishingDate &&
|
|
436
470
|
h("div", { class: "BlogDate" }, this.formatDate(data === null || data === void 0 ? void 0 : data.publishingDate)), this.showImage && ((_a = data.image) === null || _a === void 0 ? void 0 : _a.src) ? (h("div", { class: "VisualContent", style: { background: `url(${this.setImage(data.image)}) no-repeat center center / cover` } })) : (((_b = data.video) === null || _b === void 0 ? void 0 : _b.sources[this.device]) ? (h("video", { class: "VisualContent", src: data.video.sources[this.device], controls: true })) : (h("h1", { class: "VisualContent", style: { color: "#fff" } }, "No Image")))), h("div", { class: "GridSector" }, this.showTitle &&
|
|
@@ -448,6 +482,7 @@ const BlogArticlesGrid = class {
|
|
|
448
482
|
"cmsEnv": ["watchEndpoint"],
|
|
449
483
|
"userRoles": ["watchEndpoint"],
|
|
450
484
|
"blogsLimit": ["watchEndpoint"],
|
|
485
|
+
"eventId": ["watchEndpoint"],
|
|
451
486
|
"clientStyling": ["handleClientStylingChange"],
|
|
452
487
|
"clientStylingUrl": ["handleClientStylingChangeURL"]
|
|
453
488
|
}; }
|
package/dist/esm/loader.js
CHANGED
|
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-0f993ce5.js';
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await globalScripts();
|
|
8
|
-
return bootstrapLazy([["blog-articles-grid_2",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"
|
|
8
|
+
return bootstrapLazy([["blog-articles-grid_2",[[1,"blog-articles-grid",{"cmsEndpoint":[513,"cms-endpoint"],"language":[513],"userRoles":[513,"user-roles"],"cmsEnv":[513,"cms-env"],"mbSource":[1,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"showPublishingDate":[516,"show-publishing-date"],"showImage":[516,"show-image"],"showTitle":[516,"show-title"],"showContent":[516,"show-content"],"showButton":[516,"show-button"],"usePostmessage":[516,"use-postmessage"],"postMessageEvent":[513,"post-message-event"],"blogsLimit":[513,"blogs-limit"],"paginationActive":[516,"pagination-active"],"arrowsActive":[516,"arrows-active"],"secondaryArrowsActive":[516,"secondary-arrows-active"],"numberedNavActive":[516,"numbered-nav-active"],"intlDateTimeFormat":[513,"intl-date-time-format"],"page":[513],"eventId":[513,"event-id"],"paginationBlogList":[32],"currentPage":[32],"hasErrors":[32],"isLoading":[32],"bannerMatrixReady":[32],"nextPage":[32],"previousPage":[32],"device":[32],"displayedBlogResponse":[32],"paginationBlogResponse":[32],"allBlogResponse":[32],"totalBlogs":[32]},[[8,"BannerMatrixReady","handleBannerReady"],[0,"hpPageChange","hpPageChange"]],{"page":["watchEndpoint"],"hasErrors":["watchEndpoint"],"cmsEndpoint":["watchEndpoint"],"language":["watchEndpoint"],"cmsEnv":["watchEndpoint"],"userRoles":["watchEndpoint"],"blogsLimit":["watchEndpoint"],"eventId":["watchEndpoint"],"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}],[1,"helper-pagination",{"nextPage":[1537,"next-page"],"prevPage":[1537,"prev-page"],"offset":[1538],"limit":[1538],"total":[1538],"language":[1537],"mbSource":[1,"mb-source"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[1537,"client-styling-url"],"arrowsActive":[1540,"arrows-active"],"secondaryArrowsActive":[1540,"secondary-arrows-active"],"numberedNavActive":[1540,"numbered-nav-active"],"offsetInt":[32],"lastPage":[32],"previousPage":[32],"limitInt":[32],"totalInt":[32],"pagesArray":[32],"endInt":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingChangeURL"]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { defineCustomElements };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
2
|
import "../../../../../../dist/packages/stencil/helper-pagination/dist/types/index";
|
|
3
|
-
import type { BlogPost } from '../../utils/type';
|
|
3
|
+
import type { BlogPost, BlogPostResponse } from '../../utils/type';
|
|
4
4
|
export declare class BlogArticlesGrid {
|
|
5
5
|
/**
|
|
6
6
|
* Endpoint URL for the source of data
|
|
@@ -100,7 +100,9 @@ export declare class BlogArticlesGrid {
|
|
|
100
100
|
nextPage: string;
|
|
101
101
|
previousPage: string;
|
|
102
102
|
device: string;
|
|
103
|
-
|
|
103
|
+
displayedBlogResponse: BlogPostResponse;
|
|
104
|
+
paginationBlogResponse: BlogPostResponse;
|
|
105
|
+
allBlogResponse: BlogPostResponse;
|
|
104
106
|
totalBlogs: number;
|
|
105
107
|
lastPage: number;
|
|
106
108
|
clientStylingContent: string;
|
|
@@ -115,7 +117,8 @@ export declare class BlogArticlesGrid {
|
|
|
115
117
|
sortArticlesByDate(blogItems: BlogPost[]): BlogPost[];
|
|
116
118
|
findLatestFeatured(blogItems: BlogPost[]): BlogPost;
|
|
117
119
|
moveLatestFeatureToStart(blogItems: BlogPost[], latestFeatured: BlogPost): BlogPost[];
|
|
118
|
-
|
|
120
|
+
fetchBlogPosts(page?: number, allPosts?: boolean): Promise<BlogPostResponse>;
|
|
121
|
+
getBlogArticleGrid(forceFetch?: boolean, page?: number): Promise<void>;
|
|
119
122
|
connectedCallback(): void;
|
|
120
123
|
componentDidLoad(): void;
|
|
121
124
|
disconnectedCallback(): void;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|