@everymatrix/blog-articles-grid 1.44.0 → 1.45.2
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/p-786304d4.js +2 -0
- package/dist/blog-articles-grid/p-dde0107e.entry.js +1 -0
- package/dist/blog-articles-grid/p-e1255160.js +1 -0
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/blog-articles-grid.cjs.js +17 -11
- package/dist/cjs/blog-articles-grid_2.cjs.entry.js +504 -567
- package/dist/cjs/index-fad8e671.js +1332 -0
- package/dist/cjs/loader.cjs.js +7 -13
- package/dist/collection/collection-manifest.json +3 -3
- package/dist/collection/components/blog-articles-grid/blog-articles-grid.js +676 -717
- package/dist/collection/components/blog-articles-grid/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +34 -34
- package/dist/collection/utils/utils.js +52 -52
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/blog-articles-grid.js +14 -11
- package/dist/esm/blog-articles-grid_2.entry.js +504 -567
- package/dist/esm/index-2c19cd94.js +1305 -0
- package/dist/esm/loader.js +7 -13
- package/dist/stencil.config.dev.js +17 -0
- package/dist/stencil.config.js +14 -19
- 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 +114 -114
- package/dist/types/components/blog-articles-grid/index.d.ts +1 -0
- package/dist/types/components.d.ts +16 -1
- package/dist/types/stencil-public-runtime.d.ts +142 -33
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.d.ts +13 -1
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/loader/package.json +1 -0
- package/package.json +9 -3
- package/dist/blog-articles-grid/p-cb7acb6b.js +0 -1
- package/dist/blog-articles-grid/p-cbc63da6.entry.js +0 -1
- package/dist/cjs/index-159efcd2.js +0 -1355
- package/dist/components/blog-articles-grid.d.ts +0 -11
- package/dist/components/blog-articles-grid.js +0 -485
- package/dist/components/helper-pagination.js +0 -6
- package/dist/components/helper-pagination2.js +0 -287
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -1
- package/dist/esm/index-6c1af2f1.js +0 -1329
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/blog-articles-grid/.stencil/packages/blog-articles-grid/stencil.config.d.ts +0 -2
|
@@ -2,174 +2,108 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-fad8e671.js');
|
|
6
6
|
|
|
7
7
|
const DEFAULT_LANGUAGE$1 = 'en';
|
|
8
8
|
const TRANSLATIONS$1 = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
9
|
+
en: {
|
|
10
|
+
error: 'Error',
|
|
11
|
+
readmore: 'Read more',
|
|
12
|
+
},
|
|
13
|
+
ro: {
|
|
14
|
+
error: 'Eroare',
|
|
15
|
+
readmore: 'Read more',
|
|
16
|
+
},
|
|
17
|
+
fr: {
|
|
18
|
+
error: 'Error',
|
|
19
|
+
readmore: 'Read more',
|
|
20
|
+
},
|
|
21
|
+
ar: {
|
|
22
|
+
error: 'خطأ',
|
|
23
|
+
readmore: 'Read more',
|
|
24
|
+
},
|
|
25
|
+
hu: {
|
|
26
|
+
error: 'خطأ',
|
|
27
|
+
readmore: 'Tovább olvasom',
|
|
28
|
+
},
|
|
29
|
+
hr: {
|
|
30
|
+
error: 'Greška',
|
|
31
|
+
readmore: 'Pročitaj više'
|
|
32
|
+
},
|
|
33
|
+
'pt-br': {
|
|
34
|
+
error: 'Erro',
|
|
35
|
+
readmore: 'Ler mais'
|
|
36
|
+
},
|
|
37
|
+
'es-mx': {
|
|
38
|
+
error: 'Error',
|
|
39
|
+
readmore: 'Leer más'
|
|
40
|
+
}
|
|
41
41
|
};
|
|
42
42
|
const translate$1 = (key, customLang) => {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const lang = customLang;
|
|
44
|
+
return TRANSLATIONS$1[(lang !== undefined) && (lang in TRANSLATIONS$1) ? lang : DEFAULT_LANGUAGE$1][key];
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
function checkCustomDeviceWidth() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
const width = screen.availWidth;
|
|
49
|
+
if (width < 600) {
|
|
50
|
+
return 'mobile';
|
|
51
|
+
}
|
|
52
|
+
else if (width >= 600 && width < 1100) {
|
|
53
|
+
return 'tablet';
|
|
54
|
+
}
|
|
55
55
|
}
|
|
56
56
|
function isIpad() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
58
|
+
// Traditional iPad user agent
|
|
59
|
+
if (userAgent.includes('ipad')) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return userAgent.indexOf('macintosh') > -1 && navigator.maxTouchPoints && navigator.maxTouchPoints > 2;
|
|
63
63
|
}
|
|
64
64
|
function getDeviceCustom() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
66
|
+
let source = '';
|
|
67
|
+
source = (userAgent.includes('android') || userAgent.includes('iphone') || isIpad()) ? checkCustomDeviceWidth() : 'desktop';
|
|
68
|
+
return source;
|
|
69
69
|
}
|
|
70
70
|
const getDevice = () => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
if (userAgent.toLowerCase().match(/iphone/i)) {
|
|
76
|
-
return 'iPhone';
|
|
77
|
-
}
|
|
78
|
-
if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
|
|
79
|
-
return 'iPad';
|
|
80
|
-
}
|
|
81
|
-
return 'PC';
|
|
82
|
-
};
|
|
83
|
-
const getDevicePlatform = () => {
|
|
84
|
-
const device = getDevice();
|
|
85
|
-
if (device) {
|
|
86
|
-
if (device === 'PC') {
|
|
87
|
-
return 'dk';
|
|
71
|
+
let userAgent = window.navigator.userAgent;
|
|
72
|
+
if (userAgent.toLowerCase().match(/android/i)) {
|
|
73
|
+
return 'Android';
|
|
88
74
|
}
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
if (userAgent.toLowerCase().match(/iphone/i)) {
|
|
76
|
+
return 'iPhone';
|
|
91
77
|
}
|
|
92
|
-
|
|
93
|
-
|
|
78
|
+
if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
|
|
79
|
+
return 'iPad';
|
|
80
|
+
}
|
|
81
|
+
return 'PC';
|
|
82
|
+
};
|
|
83
|
+
const getDevicePlatform = () => {
|
|
84
|
+
const device = getDevice();
|
|
85
|
+
if (device) {
|
|
86
|
+
if (device === 'PC') {
|
|
87
|
+
return 'dk';
|
|
88
|
+
}
|
|
89
|
+
else if (device === 'iPad' || device === 'iPhone') {
|
|
90
|
+
return 'mtWeb';
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return 'mtWeb';
|
|
94
|
+
}
|
|
94
95
|
}
|
|
95
|
-
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const blogArticlesGridCss = ":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(--emfe-w-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(--emfe-w-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: #D0046C;\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(--emfe-w-color-gray-100, #E6E6E6);\n}\n\n.LoadingStripe {\n border: 1px solid var(--emfe-w-color-white, #FFFFFF);\n height: 20%;\n background-color: var(--emfe-w-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}";
|
|
99
|
+
const BlogArticlesGridStyle0 = blogArticlesGridCss;
|
|
99
100
|
|
|
100
101
|
const BlogArticlesGrid = class {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*/
|
|
107
|
-
this.language = 'en';
|
|
108
|
-
/**
|
|
109
|
-
* User roles
|
|
110
|
-
*/
|
|
111
|
-
this.userRoles = 'everyone';
|
|
112
|
-
/**
|
|
113
|
-
* CMS Endpoint stage
|
|
114
|
-
*/
|
|
115
|
-
this.cmsEnv = 'stage';
|
|
116
|
-
/**
|
|
117
|
-
* Client custom styling via string
|
|
118
|
-
*/
|
|
119
|
-
this.clientStyling = '';
|
|
120
|
-
/**
|
|
121
|
-
* Client custom styling via url
|
|
122
|
-
*/
|
|
123
|
-
this.clientStylingUrl = '';
|
|
124
|
-
/**
|
|
125
|
-
* Property used to display the publishing date
|
|
126
|
-
*/
|
|
127
|
-
this.showPublishingDate = true;
|
|
128
|
-
/**
|
|
129
|
-
* Property used to display the image
|
|
130
|
-
*/
|
|
131
|
-
this.showImage = true;
|
|
132
|
-
/**
|
|
133
|
-
* Property used to display the image
|
|
134
|
-
*/
|
|
135
|
-
this.showTitle = true;
|
|
136
|
-
/**
|
|
137
|
-
* Property used to display the description
|
|
138
|
-
*/
|
|
139
|
-
this.showContent = true;
|
|
140
|
-
/**
|
|
141
|
-
* Property used to display the button
|
|
142
|
-
*/
|
|
143
|
-
this.showButton = true;
|
|
144
|
-
/**
|
|
145
|
-
* Event name to be sent when the button is clicked
|
|
146
|
-
*/
|
|
147
|
-
this.postMessageEvent = '';
|
|
148
|
-
/**
|
|
149
|
-
* Customize pagination: Activate pagination numbered navigation
|
|
150
|
-
*/
|
|
151
|
-
this.blogsLimit = '0';
|
|
152
|
-
/**
|
|
153
|
-
* Intl date format
|
|
154
|
-
*/
|
|
155
|
-
this.intlDateTimeFormat = '';
|
|
156
|
-
/**
|
|
157
|
-
* Page to particularly be opened on start
|
|
158
|
-
*/
|
|
159
|
-
this.page = '1';
|
|
160
|
-
this.paginationBlogList = {
|
|
161
|
-
offset: 0
|
|
162
|
-
};
|
|
163
|
-
this.currentPage = 0;
|
|
164
|
-
this.hasErrors = false;
|
|
165
|
-
this.isLoading = true;
|
|
166
|
-
this.bannerMatrixReady = false;
|
|
167
|
-
this.nextPage = '';
|
|
168
|
-
this.previousPage = '';
|
|
169
|
-
this.device = '';
|
|
170
|
-
this.totalBlogs = 0;
|
|
171
|
-
this.clientStylingContent = '';
|
|
172
|
-
this.defaultStyling = `
|
|
102
|
+
constructor(hostRef) {
|
|
103
|
+
index.registerInstance(this, hostRef);
|
|
104
|
+
this.articleActionButton = index.createEvent(this, "articleActionButton", 7);
|
|
105
|
+
this.clientStylingContent = '';
|
|
106
|
+
this.defaultStyling = `
|
|
173
107
|
div#PaginationContainer {
|
|
174
108
|
justify-content: right;
|
|
175
109
|
}
|
|
@@ -218,218 +152,250 @@ const BlogArticlesGrid = class {
|
|
|
218
152
|
padding: 12px 0 12px 12px;
|
|
219
153
|
font-weight: 700;
|
|
220
154
|
}`;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
155
|
+
this.setClientStyling = () => {
|
|
156
|
+
this.clientStylingContent += this.clientStyling;
|
|
157
|
+
const sheet = document.createElement('style');
|
|
158
|
+
sheet.innerHTML = this.clientStylingContent;
|
|
159
|
+
this.stylingContainer.prepend(sheet);
|
|
160
|
+
};
|
|
161
|
+
this.setImage = (image) => {
|
|
162
|
+
let source = '';
|
|
163
|
+
switch (this.device) {
|
|
164
|
+
case 'mobile':
|
|
165
|
+
source = image.sources[0].pictureSource;
|
|
166
|
+
break;
|
|
167
|
+
case 'tablet':
|
|
168
|
+
source = image.sources[1].pictureSource;
|
|
169
|
+
break;
|
|
170
|
+
case 'desktop':
|
|
171
|
+
source = image.sources[2].pictureSource;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
return source;
|
|
175
|
+
};
|
|
176
|
+
this.renderContentConditionally = (content) => {
|
|
177
|
+
if (!content)
|
|
178
|
+
return;
|
|
179
|
+
const hasBanner = content.indexOf('<bannermatrix-banner') !== -1;
|
|
180
|
+
if (!hasBanner) {
|
|
181
|
+
return index.h("div", { class: "BlogContent", innerHTML: content });
|
|
182
|
+
}
|
|
183
|
+
if (this.bannerMatrixReady) {
|
|
184
|
+
return index.h("div", { class: "BlogContent", innerHTML: content });
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
};
|
|
188
|
+
this.cmsEndpoint = undefined;
|
|
189
|
+
this.language = 'en';
|
|
190
|
+
this.userRoles = 'everyone';
|
|
191
|
+
this.cmsEnv = 'stage';
|
|
192
|
+
this.clientStyling = '';
|
|
193
|
+
this.clientStylingUrl = '';
|
|
194
|
+
this.showPublishingDate = true;
|
|
195
|
+
this.showImage = true;
|
|
196
|
+
this.showTitle = true;
|
|
197
|
+
this.showContent = true;
|
|
198
|
+
this.showButton = true;
|
|
199
|
+
this.usePostmessage = undefined;
|
|
200
|
+
this.postMessageEvent = '';
|
|
201
|
+
this.blogsLimit = '0';
|
|
202
|
+
this.paginationActive = undefined;
|
|
203
|
+
this.arrowsActive = undefined;
|
|
204
|
+
this.secondaryArrowsActive = undefined;
|
|
205
|
+
this.numberedNavActive = undefined;
|
|
206
|
+
this.intlDateTimeFormat = '';
|
|
207
|
+
this.page = '1';
|
|
208
|
+
this.paginationBlogList = {
|
|
209
|
+
offset: 0
|
|
210
|
+
};
|
|
211
|
+
this.currentPage = 0;
|
|
212
|
+
this.hasErrors = false;
|
|
213
|
+
this.isLoading = true;
|
|
214
|
+
this.bannerMatrixReady = false;
|
|
215
|
+
this.nextPage = '';
|
|
216
|
+
this.previousPage = '';
|
|
217
|
+
this.device = '';
|
|
218
|
+
this.blogData = undefined;
|
|
219
|
+
this.totalBlogs = 0;
|
|
258
220
|
}
|
|
259
|
-
|
|
260
|
-
|
|
221
|
+
getArticleId(postId, slug, customPath) {
|
|
222
|
+
if (this.usePostmessage) {
|
|
223
|
+
window.postMessage({ type: this.postMessageEvent, postId, slug, customPath });
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
this.articleActionButton.emit({ postId, slug, customPath });
|
|
227
|
+
}
|
|
261
228
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.bannerMatrixReady = true;
|
|
266
|
-
}
|
|
267
|
-
watchEndpoint(newValue, oldValue) {
|
|
268
|
-
this.currentPage = parseInt(this.page) - 1;
|
|
269
|
-
if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
270
|
-
this.getBlogArticleGrid();
|
|
229
|
+
// Rerender when bannermatrix has finished loaded. Issue when bannermatrix passed as content from CMS.
|
|
230
|
+
handleBannerReady() {
|
|
231
|
+
this.bannerMatrixReady = true;
|
|
271
232
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
233
|
+
watchEndpoint(newValue, oldValue) {
|
|
234
|
+
this.currentPage = parseInt(this.page) - 1;
|
|
235
|
+
if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
236
|
+
this.getBlogArticleGrid();
|
|
237
|
+
}
|
|
276
238
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
this.currentPage = Math.floor(((_a = this.paginationBlogList) === null || _a === void 0 ? void 0 : _a.offset) / ((_b = this.paginationBlogList) === null || _b === void 0 ? void 0 : _b.limit));
|
|
282
|
-
if (this.page) {
|
|
283
|
-
this.currentPage = this.currentPage + +this.page - 1;
|
|
239
|
+
handleStylingChange(newValue, oldValue) {
|
|
240
|
+
if (newValue !== oldValue) {
|
|
241
|
+
this.fetchClientStyling().then(_ => this.setClientStyling());
|
|
242
|
+
}
|
|
284
243
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
244
|
+
hpPageChange(event) {
|
|
245
|
+
var _a, _b;
|
|
246
|
+
this.paginationBlogList = event.detail;
|
|
247
|
+
this.currentPage = Math.floor(((_a = this.paginationBlogList) === null || _a === void 0 ? void 0 : _a.offset) / ((_b = this.paginationBlogList) === null || _b === void 0 ? void 0 : _b.limit));
|
|
248
|
+
if (this.page) {
|
|
249
|
+
this.currentPage = this.currentPage + +this.page - 1;
|
|
250
|
+
}
|
|
251
|
+
if (this.currentPage + 1 > this.lastPage) {
|
|
252
|
+
this.nextPage = null;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (this.currentPage < 0) {
|
|
256
|
+
this.previousPage = null;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
window.postMessage({ type: 'BlogArticlesGridActivePagination', currentPage: this.currentPage }, window.location.href);
|
|
260
|
+
this.getBlogArticleGrid();
|
|
288
261
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
262
|
+
sortArticlesByDate(arr) {
|
|
263
|
+
arr.sort((a, b) => {
|
|
264
|
+
if (a.publishingDate > b.publishingDate)
|
|
265
|
+
return -1;
|
|
266
|
+
if (a.publishingDate < b.publishingDate)
|
|
267
|
+
return 1;
|
|
268
|
+
return 0;
|
|
269
|
+
});
|
|
270
|
+
return arr;
|
|
292
271
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return
|
|
300
|
-
if (a.publishingDate < b.publishingDate)
|
|
301
|
-
return 1;
|
|
302
|
-
return 0;
|
|
303
|
-
});
|
|
304
|
-
return arr;
|
|
305
|
-
}
|
|
306
|
-
findLatestFeatured(array) {
|
|
307
|
-
let featuredItems = array.filter(item => item.isFeaturedPost);
|
|
308
|
-
if (featuredItems.length === 0) {
|
|
309
|
-
return null;
|
|
272
|
+
findLatestFeatured(array) {
|
|
273
|
+
let featuredItems = array.filter(item => item.isFeaturedPost);
|
|
274
|
+
if (featuredItems.length === 0) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
featuredItems = this.sortArticlesByDate(featuredItems);
|
|
278
|
+
return featuredItems[0];
|
|
310
279
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
articlesArray.unshift(latestFeatured);
|
|
280
|
+
moveLatestFeatureToStart(articlesArray, latestFeatured) {
|
|
281
|
+
const index = articlesArray.indexOf(latestFeatured);
|
|
282
|
+
if (index !== -1) {
|
|
283
|
+
articlesArray.splice(index, 1);
|
|
284
|
+
articlesArray.unshift(latestFeatured);
|
|
285
|
+
}
|
|
286
|
+
return articlesArray;
|
|
319
287
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
})
|
|
357
|
-
.finally(() => this.isLoading = false);
|
|
358
|
-
}
|
|
359
|
-
connectedCallback() {
|
|
360
|
-
if (this.cmsEndpoint && this.language && this.blogsLimit) {
|
|
361
|
-
if (this.page) {
|
|
362
|
-
this.currentPage = this.currentPage + +this.page - 1;
|
|
363
|
-
this.getBlogArticleGrid(+this.page);
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
this.getBlogArticleGrid();
|
|
367
|
-
}
|
|
288
|
+
getBlogArticleGrid(page) {
|
|
289
|
+
this.isLoading = true;
|
|
290
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/blog-posts`);
|
|
291
|
+
url.searchParams.append('per_page', this.blogsLimit);
|
|
292
|
+
url.searchParams.append('page', JSON.stringify(page ? page : this.currentPage + 1));
|
|
293
|
+
url.searchParams.append('env', this.cmsEnv);
|
|
294
|
+
url.searchParams.append('userRoles', this.userRoles);
|
|
295
|
+
url.searchParams.append('device', getDevicePlatform());
|
|
296
|
+
fetch(url.href)
|
|
297
|
+
.then((res) => {
|
|
298
|
+
if (res.status >= 300) {
|
|
299
|
+
this.hasErrors = true;
|
|
300
|
+
throw new Error('There was an error while fetching the data');
|
|
301
|
+
}
|
|
302
|
+
return res.json();
|
|
303
|
+
})
|
|
304
|
+
.then((blogContent) => {
|
|
305
|
+
this.lastPage = +blogContent.pages.last.match(/&page=(\d+)/)[1];
|
|
306
|
+
let blogItems = blogContent.items;
|
|
307
|
+
this.nextPage = blogContent.pages.next;
|
|
308
|
+
this.previousPage = blogContent.pages.previous;
|
|
309
|
+
this.totalBlogs = blogContent.total;
|
|
310
|
+
const latestFeatured = this.findLatestFeatured(blogItems);
|
|
311
|
+
this.blogData = this.sortArticlesByDate(blogItems);
|
|
312
|
+
this.blogData = this.moveLatestFeatureToStart(blogItems, latestFeatured);
|
|
313
|
+
this.blogData.items = blogItems.map((item) => {
|
|
314
|
+
return Object.assign(Object.assign({}, item), { publishingDate: new Date(item.publishingDate).toLocaleDateString() });
|
|
315
|
+
});
|
|
316
|
+
this.isLoading = false;
|
|
317
|
+
this.hasErrors = false;
|
|
318
|
+
})
|
|
319
|
+
.catch((err) => {
|
|
320
|
+
this.hasErrors = true;
|
|
321
|
+
console.log('Error', err);
|
|
322
|
+
})
|
|
323
|
+
.finally(() => this.isLoading = false);
|
|
368
324
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
return new Promise(resolve => {
|
|
384
|
-
fetch(this.clientStylingUrl)
|
|
385
|
-
.then((res) => res.text())
|
|
386
|
-
.then((data) => {
|
|
387
|
-
resolve(data);
|
|
388
|
-
this.clientStylingContent += data;
|
|
389
|
-
})
|
|
390
|
-
.catch((err) => {
|
|
391
|
-
console.error('Error fetching Client Styling:', err);
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
formatDate(dateString) {
|
|
396
|
-
return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(dateString));
|
|
397
|
-
}
|
|
398
|
-
render() {
|
|
399
|
-
var _a, _b;
|
|
400
|
-
if (this.hasErrors) {
|
|
401
|
-
return (index.h("div", { class: "BlogsContainer" }, index.h("div", { class: "ErrorMessage" }, translate$1('error', this.language))));
|
|
325
|
+
connectedCallback() {
|
|
326
|
+
if (this.cmsEndpoint && this.language && this.blogsLimit) {
|
|
327
|
+
if (this.page) {
|
|
328
|
+
this.currentPage = this.currentPage + +this.page - 1;
|
|
329
|
+
this.getBlogArticleGrid(+this.page);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
this.getBlogArticleGrid();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
componentWillLoad() {
|
|
337
|
+
if (this.clientStylingUrl)
|
|
338
|
+
return this.fetchClientStyling();
|
|
402
339
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
340
|
+
componentDidLoad() {
|
|
341
|
+
if (this.clientStyling || this.clientStylingUrl)
|
|
342
|
+
this.setClientStyling();
|
|
343
|
+
window.postMessage({ type: 'BlogArticlesGridLoaded' }, window.location.href);
|
|
344
|
+
this.device = getDeviceCustom();
|
|
408
345
|
}
|
|
409
|
-
|
|
410
|
-
|
|
346
|
+
fetchClientStyling() {
|
|
347
|
+
if (!this.clientStylingUrl)
|
|
348
|
+
return;
|
|
349
|
+
return new Promise(resolve => {
|
|
350
|
+
fetch(this.clientStylingUrl)
|
|
351
|
+
.then((res) => res.text())
|
|
352
|
+
.then((data) => {
|
|
353
|
+
resolve(data);
|
|
354
|
+
this.clientStylingContent += data;
|
|
355
|
+
})
|
|
356
|
+
.catch((err) => {
|
|
357
|
+
console.error('Error fetching Client Styling:', err);
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
formatDate(dateString) {
|
|
362
|
+
return new Intl.DateTimeFormat(this.intlDateTimeFormat).format(new Date(dateString));
|
|
363
|
+
}
|
|
364
|
+
render() {
|
|
411
365
|
var _a, _b;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
366
|
+
if (this.hasErrors) {
|
|
367
|
+
return (index.h("div", { class: "BlogsContainer" }, index.h("div", { class: "ErrorMessage" }, translate$1('error', this.language))));
|
|
368
|
+
}
|
|
369
|
+
// Create an array to store the placeholder elements for each card
|
|
370
|
+
const placeholderCards = [];
|
|
371
|
+
// Loop through the blogsLimit in order to generate the desired number of cards
|
|
372
|
+
for (let i = 0; i < parseInt(this.blogsLimit); i++) {
|
|
373
|
+
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" })))));
|
|
374
|
+
}
|
|
375
|
+
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: (_b = (_a = this.blogData) === null || _a === void 0 ? void 0 : _a.items) === null || _b === void 0 ? void 0 : _b.length, language: this.language, "client-styling": this.clientStyling || this.defaultStyling, "arrows-active": this.arrowsActive || true, "secondary-arrows-active": this.secondaryArrowsActive || false, "numbered-nav-active": this.numberedNavActive || false })), (!this.isLoading) &&
|
|
376
|
+
index.h("div", { class: `GridContainerWrapper BlogPage-${this.currentPage}` }, this.blogData && this.blogData.map((data) => {
|
|
377
|
+
var _a, _b;
|
|
378
|
+
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 &&
|
|
379
|
+
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 &&
|
|
380
|
+
index.h("div", { class: "BlogTitle" }, data === null || data === void 0 ? void 0 : data.title), this.showContent &&
|
|
381
|
+
this.renderContentConditionally(data === null || data === void 0 ? void 0 : data.descriptionPreview), this.showButton &&
|
|
382
|
+
index.h("div", { class: "BlogLink" }, index.h("button", { onClick: () => this.getArticleId(data === null || data === void 0 ? void 0 : data.postID, data === null || data === void 0 ? void 0 : data.slug, data === null || data === void 0 ? void 0 : data.customPath) }, translate$1('readmore', this.language))))));
|
|
383
|
+
})), (this.isLoading) &&
|
|
384
|
+
index.h("div", { class: "GridContainerWrapper LoadingGrid" }, placeholderCards))));
|
|
385
|
+
}
|
|
386
|
+
static get watchers() { return {
|
|
387
|
+
"page": ["watchEndpoint"],
|
|
388
|
+
"hasErrors": ["watchEndpoint"],
|
|
389
|
+
"cmsEndpoint": ["watchEndpoint"],
|
|
390
|
+
"language": ["watchEndpoint"],
|
|
391
|
+
"cmsEnv": ["watchEndpoint"],
|
|
392
|
+
"userRoles": ["watchEndpoint"],
|
|
393
|
+
"blogsLimit": ["watchEndpoint"],
|
|
394
|
+
"clientStyling": ["handleStylingChange"],
|
|
395
|
+
"clientStylingUrl": ["handleStylingChange"]
|
|
396
|
+
}; }
|
|
431
397
|
};
|
|
432
|
-
BlogArticlesGrid.style =
|
|
398
|
+
BlogArticlesGrid.style = BlogArticlesGridStyle0;
|
|
433
399
|
|
|
434
400
|
/**
|
|
435
401
|
* @name isMobile
|
|
@@ -438,247 +404,218 @@ BlogArticlesGrid.style = blogArticlesGridCss;
|
|
|
438
404
|
* @returns {Boolean} true or false
|
|
439
405
|
*/
|
|
440
406
|
const isMobile = (userAgent) => {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
407
|
+
return !!(userAgent.toLowerCase().match(/android/i) ||
|
|
408
|
+
userAgent.toLowerCase().match(/blackberry|bb/i) ||
|
|
409
|
+
userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
|
|
410
|
+
userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
|
|
445
411
|
};
|
|
446
412
|
|
|
447
413
|
const DEFAULT_LANGUAGE = 'en';
|
|
448
414
|
const TRANSLATIONS = {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
415
|
+
en: {
|
|
416
|
+
firstPage: 'First',
|
|
417
|
+
previousPage: 'Previous',
|
|
418
|
+
nextPage: 'Next',
|
|
419
|
+
lastPage: 'Last'
|
|
420
|
+
},
|
|
421
|
+
ro: {
|
|
422
|
+
firstPage: 'Prima',
|
|
423
|
+
previousPage: 'Anterior',
|
|
424
|
+
nextPage: 'Urmatoarea',
|
|
425
|
+
lastPage: 'Ultima'
|
|
426
|
+
},
|
|
427
|
+
fr: {
|
|
428
|
+
firstPage: 'First',
|
|
429
|
+
previousPage: 'Previous',
|
|
430
|
+
nextPage: 'Next',
|
|
431
|
+
lastPage: 'Last'
|
|
432
|
+
},
|
|
433
|
+
ar: {
|
|
434
|
+
firstPage: 'First',
|
|
435
|
+
previousPage: 'Previous',
|
|
436
|
+
nextPage: 'Next',
|
|
437
|
+
lastPage: 'Last'
|
|
438
|
+
},
|
|
439
|
+
hu: {
|
|
440
|
+
firstPage: 'First',
|
|
441
|
+
previousPage: 'Previous',
|
|
442
|
+
nextPage: 'Következő',
|
|
443
|
+
lastPage: 'Last'
|
|
444
|
+
},
|
|
445
|
+
hr: {
|
|
446
|
+
firstPage: 'Prva',
|
|
447
|
+
previousPage: 'Prethodna',
|
|
448
|
+
nextPage: 'Slijedeća',
|
|
449
|
+
lastPage: 'Zadnja'
|
|
450
|
+
}
|
|
485
451
|
};
|
|
486
452
|
const translate = (key, customLang) => {
|
|
487
|
-
|
|
488
|
-
|
|
453
|
+
const lang = customLang;
|
|
454
|
+
return TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
|
|
489
455
|
};
|
|
490
456
|
|
|
491
457
|
const helperPaginationCss = "@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}}";
|
|
458
|
+
const HelperPaginationStyle0 = helperPaginationCss;
|
|
492
459
|
|
|
493
460
|
const HelperPagination = class {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
461
|
+
constructor(hostRef) {
|
|
462
|
+
index.registerInstance(this, hostRef);
|
|
463
|
+
this.hpPageChange = index.createEvent(this, "hpPageChange", 7);
|
|
464
|
+
this.userAgent = window.navigator.userAgent;
|
|
465
|
+
this.currentPage = 1;
|
|
466
|
+
/**
|
|
467
|
+
* Navigation logic
|
|
468
|
+
*/
|
|
469
|
+
this.navigateTo = (navigationPage) => {
|
|
470
|
+
switch (navigationPage) {
|
|
471
|
+
case 'firstPage':
|
|
472
|
+
this.offsetInt = 0;
|
|
473
|
+
break;
|
|
474
|
+
case 'lastPage':
|
|
475
|
+
this.offsetInt = this.endInt * this.limitInt;
|
|
476
|
+
break;
|
|
477
|
+
case 'previousPage':
|
|
478
|
+
this.offsetInt -= this.limitInt;
|
|
479
|
+
break;
|
|
480
|
+
case 'nextPage':
|
|
481
|
+
this.offsetInt += this.limitInt;
|
|
482
|
+
break;
|
|
483
|
+
case 'fivePagesBack':
|
|
484
|
+
this.offsetInt -= this.limitInt * 5;
|
|
485
|
+
this.offsetInt = this.offsetInt <= 0 ? 0 : this.offsetInt;
|
|
486
|
+
break;
|
|
487
|
+
case 'fivePagesForward':
|
|
488
|
+
this.offsetInt += this.limitInt * 5;
|
|
489
|
+
this.offsetInt = this.offsetInt / this.limitInt >= this.endInt ? this.endInt * this.limitInt : this.offsetInt;
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
this.previousPage = !this.offsetInt ? false : true;
|
|
493
|
+
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
494
|
+
};
|
|
495
|
+
/**
|
|
496
|
+
* Handle navigation from here
|
|
497
|
+
*/
|
|
498
|
+
this.paginationNavigation = (pageNumber, index) => {
|
|
499
|
+
this.previousPage = true;
|
|
500
|
+
if (!isNaN(pageNumber)) {
|
|
501
|
+
if (pageNumber === 1) {
|
|
502
|
+
this.offsetInt = pageNumber - 1;
|
|
503
|
+
this.previousPage = false;
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
this.offsetInt = (pageNumber - 1) * this.limitInt;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
if (index === 0 && this.currentPage <= 4) {
|
|
511
|
+
this.navigateTo('firstPage');
|
|
512
|
+
}
|
|
513
|
+
else if (index === 0 && this.currentPage > 4) {
|
|
514
|
+
this.navigateTo('fivePagesBack');
|
|
515
|
+
}
|
|
516
|
+
else if (index === 4 && this.endInt - this.currentPage >= 2) {
|
|
517
|
+
this.navigateTo('fivePagesForward');
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
521
|
+
};
|
|
522
|
+
this.setClientStyling = () => {
|
|
523
|
+
let sheet = document.createElement('style');
|
|
524
|
+
sheet.innerHTML = this.clientStyling;
|
|
525
|
+
this.stylingContainer.prepend(sheet);
|
|
526
|
+
};
|
|
527
|
+
this.setClientStylingURL = () => {
|
|
528
|
+
let cssFile = document.createElement('style');
|
|
529
|
+
setTimeout(() => {
|
|
530
|
+
cssFile.innerHTML = this.clientStylingUrlContent;
|
|
531
|
+
this.stylingContainer.prepend(cssFile);
|
|
532
|
+
}, 1);
|
|
533
|
+
};
|
|
534
|
+
this.nextPage = '';
|
|
535
|
+
this.prevPage = '';
|
|
536
|
+
this.offset = 0;
|
|
537
|
+
this.limit = 1;
|
|
538
|
+
this.total = 1;
|
|
539
|
+
this.language = 'en';
|
|
540
|
+
this.clientStyling = '';
|
|
541
|
+
this.clientStylingUrlContent = '';
|
|
542
|
+
this.arrowsActive = undefined;
|
|
543
|
+
this.secondaryArrowsActive = undefined;
|
|
544
|
+
this.numberedNavActive = undefined;
|
|
545
|
+
this.offsetInt = undefined;
|
|
546
|
+
this.lastPage = false;
|
|
547
|
+
this.previousPage = false;
|
|
548
|
+
this.limitInt = undefined;
|
|
549
|
+
this.totalInt = undefined;
|
|
550
|
+
this.pagesArray = [];
|
|
551
|
+
this.endInt = 0;
|
|
552
|
+
this.limitStylingAppends = false;
|
|
553
|
+
}
|
|
554
|
+
componentWillRender() {
|
|
555
|
+
this.offsetInt = this.offset;
|
|
556
|
+
this.limitInt = this.limit;
|
|
557
|
+
this.currentPage = (this.offsetInt / this.limitInt) + 1;
|
|
558
|
+
this.limitInt = this.limit;
|
|
559
|
+
this.totalInt = this.total;
|
|
560
|
+
this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
|
|
561
|
+
this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
|
|
562
|
+
/**
|
|
563
|
+
* Construct numbered navigation area based on current page position
|
|
564
|
+
*/
|
|
565
|
+
if (this.currentPage == 1 || this.currentPage == 2) {
|
|
566
|
+
this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
|
|
567
|
+
this.pagesArray.push('...');
|
|
594
568
|
}
|
|
595
|
-
else if (
|
|
596
|
-
|
|
569
|
+
else if (this.currentPage >= 3 && ((this.endInt - this.currentPage) >= 2)) {
|
|
570
|
+
this.pagesArray = Array.from({ length: 3 }, (_, i) => this.currentPage + i - 1);
|
|
571
|
+
this.pagesArray.push('...');
|
|
572
|
+
this.pagesArray.unshift('...');
|
|
597
573
|
}
|
|
598
|
-
else if (
|
|
599
|
-
|
|
574
|
+
else if ((this.endInt - this.currentPage) < 3) {
|
|
575
|
+
this.pagesArray = Array.from({ length: 4 }, (_, i) => this.endInt - 2 + i);
|
|
576
|
+
this.pagesArray.unshift('...');
|
|
600
577
|
}
|
|
601
|
-
}
|
|
602
|
-
this.hpPageChange.emit({ offset: this.offsetInt, limit: this.limitInt, total: this.totalInt });
|
|
603
|
-
};
|
|
604
|
-
this.setClientStyling = () => {
|
|
605
|
-
let sheet = document.createElement('style');
|
|
606
|
-
sheet.innerHTML = this.clientStyling;
|
|
607
|
-
this.stylingContainer.prepend(sheet);
|
|
608
|
-
};
|
|
609
|
-
this.setClientStylingURL = () => {
|
|
610
|
-
let cssFile = document.createElement('style');
|
|
611
|
-
setTimeout(() => {
|
|
612
|
-
cssFile.innerHTML = this.clientStylingUrlContent;
|
|
613
|
-
this.stylingContainer.prepend(cssFile);
|
|
614
|
-
}, 1);
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
componentWillRender() {
|
|
618
|
-
this.offsetInt = this.offset;
|
|
619
|
-
this.limitInt = this.limit;
|
|
620
|
-
this.currentPage = (this.offsetInt / this.limitInt) + 1;
|
|
621
|
-
this.limitInt = this.limit;
|
|
622
|
-
this.totalInt = this.total;
|
|
623
|
-
this.endInt = (Math.ceil(this.totalInt / this.limitInt) - 1);
|
|
624
|
-
this.lastPage = (this.offsetInt >= this.endInt * this.limitInt) ? false : true;
|
|
625
|
-
/**
|
|
626
|
-
* Construct numbered navigation area based on current page position
|
|
627
|
-
*/
|
|
628
|
-
if (this.currentPage == 1 || this.currentPage == 2) {
|
|
629
|
-
this.pagesArray = Array.from({ length: 4 }, (_, i) => i + 1);
|
|
630
|
-
this.pagesArray.push('...');
|
|
631
578
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
componentDidRender() {
|
|
643
|
-
// start custom styling area
|
|
644
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
645
|
-
if (this.clientStyling)
|
|
646
|
-
this.setClientStyling();
|
|
647
|
-
if (this.clientStylingUrlContent)
|
|
648
|
-
this.setClientStylingURL();
|
|
649
|
-
this.limitStylingAppends = true;
|
|
650
|
-
}
|
|
651
|
-
// end custom styling area
|
|
652
|
-
}
|
|
653
|
-
render() {
|
|
654
|
-
/**
|
|
655
|
-
* Center navigation area
|
|
656
|
-
*/
|
|
657
|
-
let navigationArea = index.h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index$1) => {
|
|
658
|
-
return (index.h("li", { class: 'PaginationItem' + (item === this.currentPage ? ' ActiveItem' : ' ') + ' ' + (isMobile(this.userAgent) ? 'MobileButtons' : '') }, index.h("button", { disabled: item === this.currentPage ? true : false, onClick: this.paginationNavigation.bind(this, item, index$1) }, index.h("span", null, item))));
|
|
659
|
-
}));
|
|
660
|
-
/**
|
|
661
|
-
* Left navigation area
|
|
662
|
-
*/
|
|
663
|
-
let buttonSecondaryLeftSide = index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'firstPage') }, index.h("span", { class: "NavigationButton" }, translate('firstPage', this.language)), index.h("span", { class: "NavigationIcon" }));
|
|
664
|
-
let buttonsLeftSide = index.h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
|
|
665
|
-
if (isMobile(this.userAgent)) {
|
|
666
|
-
buttonsLeftSide =
|
|
667
|
-
index.h("div", { class: "LeftItems" }, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
|
|
579
|
+
componentDidRender() {
|
|
580
|
+
// start custom styling area
|
|
581
|
+
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
582
|
+
if (this.clientStyling)
|
|
583
|
+
this.setClientStyling();
|
|
584
|
+
if (this.clientStylingUrlContent)
|
|
585
|
+
this.setClientStylingURL();
|
|
586
|
+
this.limitStylingAppends = true;
|
|
587
|
+
}
|
|
588
|
+
// end custom styling area
|
|
668
589
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
590
|
+
render() {
|
|
591
|
+
/**
|
|
592
|
+
* Center navigation area
|
|
593
|
+
*/
|
|
594
|
+
let navigationArea = index.h("ul", { class: "PaginationArea" }, this.pagesArray.map((item, index$1) => {
|
|
595
|
+
return (index.h("li", { class: 'PaginationItem' + (item === this.currentPage ? ' ActiveItem' : ' ') + ' ' + (isMobile(this.userAgent) ? 'MobileButtons' : '') }, index.h("button", { disabled: item === this.currentPage ? true : false, onClick: this.paginationNavigation.bind(this, item, index$1) }, index.h("span", null, item))));
|
|
596
|
+
}));
|
|
597
|
+
/**
|
|
598
|
+
* Left navigation area
|
|
599
|
+
*/
|
|
600
|
+
let buttonSecondaryLeftSide = index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'firstPage') }, index.h("span", { class: "NavigationButton" }, translate('firstPage', this.language)), index.h("span", { class: "NavigationIcon" }));
|
|
601
|
+
let buttonsLeftSide = index.h("div", { class: "LeftItems" }, this.secondaryArrowsActive && buttonSecondaryLeftSide, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
|
|
602
|
+
if (isMobile(this.userAgent)) {
|
|
603
|
+
buttonsLeftSide =
|
|
604
|
+
index.h("div", { class: "LeftItems" }, index.h("button", { disabled: this.prevPage ? false : true, onClick: this.navigateTo.bind(this, 'previousPage') }, index.h("span", { class: "NavigationButton" }, translate('previousPage', this.language)), index.h("span", { class: "NavigationIcon" })));
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Right navigation area
|
|
608
|
+
*/
|
|
609
|
+
let buttonSecondaryRightSide = index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'lastPage') }, index.h("span", { class: "NavigationButton" }, translate('lastPage', this.language)), index.h("span", { class: "NavigationIcon" }));
|
|
610
|
+
let buttonsRightSide = index.h("div", { class: "RightItems" }, index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })), this.secondaryArrowsActive && buttonSecondaryRightSide);
|
|
611
|
+
if (isMobile(this.userAgent)) {
|
|
612
|
+
buttonsRightSide =
|
|
613
|
+
index.h("div", { class: "RightItems" }, index.h("button", { disabled: this.nextPage ? false : true, onClick: this.navigateTo.bind(this, 'nextPage') }, index.h("span", { class: "NavigationButton" }, translate('nextPage', this.language)), index.h("span", { class: "NavigationIcon" })));
|
|
614
|
+
}
|
|
615
|
+
return (index.h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
|
|
677
616
|
}
|
|
678
|
-
return (index.h("div", { id: "PaginationContainer", ref: el => this.stylingContainer = el }, this.arrowsActive && buttonsLeftSide, this.numberedNavActive && navigationArea, this.arrowsActive && buttonsRightSide));
|
|
679
|
-
}
|
|
680
617
|
};
|
|
681
|
-
HelperPagination.style =
|
|
618
|
+
HelperPagination.style = HelperPaginationStyle0;
|
|
682
619
|
|
|
683
620
|
exports.blog_articles_grid = BlogArticlesGrid;
|
|
684
621
|
exports.helper_pagination = HelperPagination;
|