@everymatrix/general-news-notification 1.45.7
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/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/general-news-notification-57b70677.js +206 -0
- package/dist/cjs/general-news-notification.cjs.entry.js +10 -0
- package/dist/cjs/general-news-notification.cjs.js +25 -0
- package/dist/cjs/index-95e31eec.js +1207 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/general-news-notification/general-news-notification.css +110 -0
- package/dist/collection/components/general-news-notification/general-news-notification.js +330 -0
- package/dist/collection/components/general-news-notification/index.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +34 -0
- package/dist/collection/utils/utils.js +30 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/general-news-notification-c65ccc64.js +204 -0
- package/dist/esm/general-news-notification.entry.js +2 -0
- package/dist/esm/general-news-notification.js +20 -0
- package/dist/esm/index-cffad24d.js +1181 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/general-news-notification/general-news-notification.esm.js +1 -0
- package/dist/general-news-notification/index.esm.js +1 -0
- package/dist/general-news-notification/p-8b27880f.js +2 -0
- package/dist/general-news-notification/p-cfdc487f.js +1 -0
- package/dist/general-news-notification/p-e06cf24f.entry.js +1 -0
- package/dist/general-news-notification/p-e1255160.js +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.dev.js +14 -0
- package/dist/stencil.config.js +17 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-news-notification/.stencil/packages/stencil/general-news-notification/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-news-notification/.stencil/packages/stencil/general-news-notification/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/general-news-notification/general-news-notification.d.ts +56 -0
- package/dist/types/components/general-news-notification/index.d.ts +1 -0
- package/dist/types/components.d.ts +109 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/locale.utils.d.ts +2 -0
- package/dist/types/utils/utils.d.ts +3 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +26 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const generalNewsNotification = require('./general-news-notification-57b70677.js');
|
|
6
|
+
require('./index-95e31eec.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.GeneralNewsNotification = generalNewsNotification.GeneralNewsNotification;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-95e31eec.js');
|
|
6
|
+
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
|
+
|
|
8
|
+
const defineCustomElements = async (win, options) => {
|
|
9
|
+
if (typeof window === 'undefined') return undefined;
|
|
10
|
+
await appGlobals.globalScripts();
|
|
11
|
+
return index.bootstrapLazy([["general-news-notification.cjs",[[1,"general-news-notification",{"cmsEndpoint":[1,"cms-endpoint"],"language":[1],"animationType":[1,"animation-type"],"speed":[2],"canMinimize":[4,"can-minimize"],"canClose":[4,"can-close"],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"translationUrl":[1,"translation-url"],"message":[32],"isMinimized":[32],"isClosed":[32],"isLoading":[32]},null,{"cmsEndpoint":["watchEndpoint"],"language":["watchEndpoint"],"clientStyling":["handleStylingChange"],"clientStylingUrl":["handleStylingUrlChange"],"translationUrl":["handleNewTranslations"]}]]]], options);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.setNonce = index.setNonce;
|
|
15
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.NotificationWrapper {
|
|
6
|
+
background: var(--emw-header-color-background, var(--emw-color-background, #000000));
|
|
7
|
+
color: var(--emfe-w-color-white, #FFFFFF);
|
|
8
|
+
position: sticky;
|
|
9
|
+
width: 100%;
|
|
10
|
+
text-align: center;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
z-index: 298;
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: flex-end;
|
|
15
|
+
align-items: center;
|
|
16
|
+
border-bottom: 6px solid var(--emfe-w-color-primary, #22B04E);
|
|
17
|
+
max-height: 40px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.SlidingBar {
|
|
21
|
+
transition: all 0.3s ease-in-out;
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.Message {
|
|
26
|
+
will-change: transform;
|
|
27
|
+
margin: 0 auto;
|
|
28
|
+
padding: 10px;
|
|
29
|
+
width: 90%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ScrollLeft .Message {
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
animation: scroll-left 10s linear infinite;
|
|
35
|
+
width: 100%;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.ScrollRight .Message {
|
|
39
|
+
white-space: nowrap;
|
|
40
|
+
animation: scroll-right 10s linear infinite;
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.VisibleButtons .Message {
|
|
45
|
+
display: flex;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@keyframes scroll-left {
|
|
49
|
+
from {
|
|
50
|
+
transform: translateX(100%);
|
|
51
|
+
}
|
|
52
|
+
to {
|
|
53
|
+
transform: translateX(-100%);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
@keyframes scroll-right {
|
|
57
|
+
from {
|
|
58
|
+
transform: translateX(-100%);
|
|
59
|
+
}
|
|
60
|
+
to {
|
|
61
|
+
transform: translateX(100%);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
.SlidingBar:hover .Message {
|
|
65
|
+
animation-play-state: paused;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.CloseButton {
|
|
69
|
+
padding-left: 10px;
|
|
70
|
+
background-color: var(--emw-header-color-background, var(--emw-color-background, #000000));
|
|
71
|
+
display: flex;
|
|
72
|
+
z-index: 299;
|
|
73
|
+
gap: 10px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.ToggleButton {
|
|
77
|
+
position: absolute;
|
|
78
|
+
left: 0;
|
|
79
|
+
}
|
|
80
|
+
.ToggleButton .TriangleActive, .ToggleButton .TriangleInactive {
|
|
81
|
+
display: block;
|
|
82
|
+
transition: all 0.2s;
|
|
83
|
+
}
|
|
84
|
+
.ToggleButton .TriangleActive {
|
|
85
|
+
transform: scale(1.1) rotateX(180deg) translateY(3px);
|
|
86
|
+
fill: var(--emw--color-primary, #52d004);
|
|
87
|
+
margin-top: 8px;
|
|
88
|
+
}
|
|
89
|
+
.ToggleButton svg {
|
|
90
|
+
fill: var(--emw-header-color-background, var(--emw-color-background, #000000));
|
|
91
|
+
width: 16px;
|
|
92
|
+
transform: rotate(180deg);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.CloseButton {
|
|
96
|
+
right: 10px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
button {
|
|
100
|
+
background-color: var(--emfe-w-color-primary, #22B04E);
|
|
101
|
+
color: var(--emw-header-color-background, var(--emw-color-background, #000000));
|
|
102
|
+
border: none;
|
|
103
|
+
width: 40px;
|
|
104
|
+
height: 40px;
|
|
105
|
+
cursor: pointer;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.NotificationWrapper.Minimized {
|
|
109
|
+
visibility: hidden;
|
|
110
|
+
}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { getDevicePlatform } from "../../utils/utils";
|
|
3
|
+
import { getTranslations, translate } from "../../utils/locale.utils";
|
|
4
|
+
export class GeneralNewsNotification {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.componentDidLoad = () => {
|
|
7
|
+
// start custom styling area
|
|
8
|
+
if (this.stylingContainer) {
|
|
9
|
+
if (this.clientStyling)
|
|
10
|
+
this.setClientStyling();
|
|
11
|
+
if (this.clientStylingUrl)
|
|
12
|
+
this.setClientStylingURL();
|
|
13
|
+
}
|
|
14
|
+
// end custom styling area
|
|
15
|
+
};
|
|
16
|
+
this.connectedCallback = () => {
|
|
17
|
+
if (this.cmsEndpoint && this.language) {
|
|
18
|
+
this.getNotificationMessage();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
this.setClientStyling = () => {
|
|
22
|
+
let sheet = document.createElement('style');
|
|
23
|
+
sheet.innerHTML = this.clientStyling;
|
|
24
|
+
this.stylingContainer.prepend(sheet);
|
|
25
|
+
};
|
|
26
|
+
this.setClientStylingURL = () => {
|
|
27
|
+
let url = new URL(this.clientStylingUrl);
|
|
28
|
+
let cssFile = document.createElement('style');
|
|
29
|
+
fetch(url.href)
|
|
30
|
+
.then((res) => res.text())
|
|
31
|
+
.then((data) => {
|
|
32
|
+
cssFile.innerHTML = data;
|
|
33
|
+
setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
|
|
34
|
+
})
|
|
35
|
+
.catch((err) => {
|
|
36
|
+
console.log('error ', err);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
this.getNotificationMessage = () => {
|
|
40
|
+
this.isLoading = true;
|
|
41
|
+
try {
|
|
42
|
+
let url = new URL(`${this.cmsEndpoint}/${this.language}/header-notification`);
|
|
43
|
+
url.searchParams.append('device', getDevicePlatform());
|
|
44
|
+
url.searchParams.append('platform', getDevicePlatform());
|
|
45
|
+
fetch(url.href)
|
|
46
|
+
.then((res) => {
|
|
47
|
+
if (res.status === 200) {
|
|
48
|
+
return res.json();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw new Error("HTTP status " + res.status);
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
.then((data) => {
|
|
55
|
+
this.message = data.message;
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
// Handle any errors
|
|
59
|
+
console.error(err);
|
|
60
|
+
})
|
|
61
|
+
.finally(() => this.isLoading = false);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error('Error fetching message:', error);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
this.toggleMinimize = () => {
|
|
68
|
+
this.isMinimized = !this.isMinimized;
|
|
69
|
+
};
|
|
70
|
+
this.closeNotification = () => {
|
|
71
|
+
this.isClosed = true;
|
|
72
|
+
};
|
|
73
|
+
this.cmsEndpoint = undefined;
|
|
74
|
+
this.language = undefined;
|
|
75
|
+
this.animationType = 'static';
|
|
76
|
+
this.speed = 30;
|
|
77
|
+
this.canMinimize = false;
|
|
78
|
+
this.canClose = false;
|
|
79
|
+
this.clientStyling = '';
|
|
80
|
+
this.clientStylingUrl = '';
|
|
81
|
+
this.translationUrl = '';
|
|
82
|
+
this.message = undefined;
|
|
83
|
+
this.isMinimized = false;
|
|
84
|
+
this.isClosed = false;
|
|
85
|
+
this.isLoading = true;
|
|
86
|
+
}
|
|
87
|
+
watchEndpoint(newValue, oldValue) {
|
|
88
|
+
if (newValue && newValue != oldValue && this.cmsEndpoint && this.language) {
|
|
89
|
+
this.getNotificationMessage();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
handleStylingChange(newValue, oldValue) {
|
|
93
|
+
if (newValue !== oldValue)
|
|
94
|
+
this.setClientStyling();
|
|
95
|
+
}
|
|
96
|
+
handleStylingUrlChange(newValue, oldValue) {
|
|
97
|
+
if (newValue !== oldValue)
|
|
98
|
+
this.setClientStylingURL();
|
|
99
|
+
}
|
|
100
|
+
handleNewTranslations() {
|
|
101
|
+
this.isLoading = true;
|
|
102
|
+
getTranslations(this.translationUrl).then(() => {
|
|
103
|
+
this.isLoading = false;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async componentWillLoad() {
|
|
107
|
+
if (this.translationUrl.length > 2) {
|
|
108
|
+
await getTranslations(this.translationUrl);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
render() {
|
|
112
|
+
if (this.isClosed)
|
|
113
|
+
return null;
|
|
114
|
+
const animationDuration = `${this.speed}s`;
|
|
115
|
+
return (h("div", { ref: el => this.stylingContainer = el }, this.canMinimize && (h("button", { class: "ToggleButton", onClick: this.toggleMinimize }, h("span", { class: this.isMinimized ? 'TriangleActive' : 'TriangleInactive' }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "6.835", viewBox: "0 0 14 6.835" }, h("path", { id: "arrow", d: "M281.541,447.921a.488.488,0,0,0,.295-.122l6.5-5.851a.488.488,0,1,0-.65-.726l-6.176,5.556-6.176-5.556h0a.488.488,0,1,0-.65.726l6.5,5.851a.488.488,0,0,0,.355.122Z", transform: "translate(-274.511 -441.088)" }))))), h("div", { class: {
|
|
116
|
+
'NotificationWrapper': true,
|
|
117
|
+
'Minimized': this.isMinimized
|
|
118
|
+
} }, h("div", { class: {
|
|
119
|
+
'SlidingBar': true,
|
|
120
|
+
'Minimized': this.isMinimized,
|
|
121
|
+
'ScrollLeft': this.animationType === 'scroll-left',
|
|
122
|
+
'ScrollRight': this.animationType === 'scroll-right',
|
|
123
|
+
'VisibleButtons': this.canMinimize || this.canClose === true
|
|
124
|
+
} }, h("div", { class: "Message", style: {
|
|
125
|
+
animationDuration: animationDuration,
|
|
126
|
+
} }, this.isLoading ? translate('loading', this.language) : this.message)), this.canClose && (h("div", { class: "CloseButton" }, h("button", { onClick: this.closeNotification }, "X"))))));
|
|
127
|
+
}
|
|
128
|
+
static get is() { return "general-news-notification"; }
|
|
129
|
+
static get encapsulation() { return "shadow"; }
|
|
130
|
+
static get originalStyleUrls() {
|
|
131
|
+
return {
|
|
132
|
+
"$": ["general-news-notification.scss"]
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
static get styleUrls() {
|
|
136
|
+
return {
|
|
137
|
+
"$": ["general-news-notification.css"]
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
static get properties() {
|
|
141
|
+
return {
|
|
142
|
+
"cmsEndpoint": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"mutable": false,
|
|
145
|
+
"complexType": {
|
|
146
|
+
"original": "string",
|
|
147
|
+
"resolved": "string",
|
|
148
|
+
"references": {}
|
|
149
|
+
},
|
|
150
|
+
"required": false,
|
|
151
|
+
"optional": false,
|
|
152
|
+
"docs": {
|
|
153
|
+
"tags": [],
|
|
154
|
+
"text": "The CMS endpoint"
|
|
155
|
+
},
|
|
156
|
+
"attribute": "cms-endpoint",
|
|
157
|
+
"reflect": false
|
|
158
|
+
},
|
|
159
|
+
"language": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"mutable": false,
|
|
162
|
+
"complexType": {
|
|
163
|
+
"original": "string",
|
|
164
|
+
"resolved": "string",
|
|
165
|
+
"references": {}
|
|
166
|
+
},
|
|
167
|
+
"required": false,
|
|
168
|
+
"optional": false,
|
|
169
|
+
"docs": {
|
|
170
|
+
"tags": [],
|
|
171
|
+
"text": "The language"
|
|
172
|
+
},
|
|
173
|
+
"attribute": "language",
|
|
174
|
+
"reflect": false
|
|
175
|
+
},
|
|
176
|
+
"animationType": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"mutable": false,
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "'static' | 'scroll-left' | 'scroll-right'",
|
|
181
|
+
"resolved": "\"scroll-left\" | \"scroll-right\" | \"static\"",
|
|
182
|
+
"references": {}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": false,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "Animation types"
|
|
189
|
+
},
|
|
190
|
+
"attribute": "animation-type",
|
|
191
|
+
"reflect": false,
|
|
192
|
+
"defaultValue": "'static'"
|
|
193
|
+
},
|
|
194
|
+
"speed": {
|
|
195
|
+
"type": "number",
|
|
196
|
+
"mutable": false,
|
|
197
|
+
"complexType": {
|
|
198
|
+
"original": "number",
|
|
199
|
+
"resolved": "number",
|
|
200
|
+
"references": {}
|
|
201
|
+
},
|
|
202
|
+
"required": false,
|
|
203
|
+
"optional": false,
|
|
204
|
+
"docs": {
|
|
205
|
+
"tags": [],
|
|
206
|
+
"text": "Default speed of the scroll animation in seconds"
|
|
207
|
+
},
|
|
208
|
+
"attribute": "speed",
|
|
209
|
+
"reflect": false,
|
|
210
|
+
"defaultValue": "30"
|
|
211
|
+
},
|
|
212
|
+
"canMinimize": {
|
|
213
|
+
"type": "boolean",
|
|
214
|
+
"mutable": false,
|
|
215
|
+
"complexType": {
|
|
216
|
+
"original": "boolean",
|
|
217
|
+
"resolved": "boolean",
|
|
218
|
+
"references": {}
|
|
219
|
+
},
|
|
220
|
+
"required": false,
|
|
221
|
+
"optional": false,
|
|
222
|
+
"docs": {
|
|
223
|
+
"tags": [],
|
|
224
|
+
"text": "Option to minimize"
|
|
225
|
+
},
|
|
226
|
+
"attribute": "can-minimize",
|
|
227
|
+
"reflect": false,
|
|
228
|
+
"defaultValue": "false"
|
|
229
|
+
},
|
|
230
|
+
"canClose": {
|
|
231
|
+
"type": "boolean",
|
|
232
|
+
"mutable": false,
|
|
233
|
+
"complexType": {
|
|
234
|
+
"original": "boolean",
|
|
235
|
+
"resolved": "boolean",
|
|
236
|
+
"references": {}
|
|
237
|
+
},
|
|
238
|
+
"required": false,
|
|
239
|
+
"optional": false,
|
|
240
|
+
"docs": {
|
|
241
|
+
"tags": [],
|
|
242
|
+
"text": "Option to close the notification"
|
|
243
|
+
},
|
|
244
|
+
"attribute": "can-close",
|
|
245
|
+
"reflect": false,
|
|
246
|
+
"defaultValue": "false"
|
|
247
|
+
},
|
|
248
|
+
"clientStyling": {
|
|
249
|
+
"type": "string",
|
|
250
|
+
"mutable": false,
|
|
251
|
+
"complexType": {
|
|
252
|
+
"original": "string",
|
|
253
|
+
"resolved": "string",
|
|
254
|
+
"references": {}
|
|
255
|
+
},
|
|
256
|
+
"required": false,
|
|
257
|
+
"optional": false,
|
|
258
|
+
"docs": {
|
|
259
|
+
"tags": [],
|
|
260
|
+
"text": "Client custom styling via string"
|
|
261
|
+
},
|
|
262
|
+
"attribute": "client-styling",
|
|
263
|
+
"reflect": false,
|
|
264
|
+
"defaultValue": "''"
|
|
265
|
+
},
|
|
266
|
+
"clientStylingUrl": {
|
|
267
|
+
"type": "string",
|
|
268
|
+
"mutable": false,
|
|
269
|
+
"complexType": {
|
|
270
|
+
"original": "string",
|
|
271
|
+
"resolved": "string",
|
|
272
|
+
"references": {}
|
|
273
|
+
},
|
|
274
|
+
"required": false,
|
|
275
|
+
"optional": false,
|
|
276
|
+
"docs": {
|
|
277
|
+
"tags": [],
|
|
278
|
+
"text": "Client custom styling via url content"
|
|
279
|
+
},
|
|
280
|
+
"attribute": "client-styling-url",
|
|
281
|
+
"reflect": false,
|
|
282
|
+
"defaultValue": "''"
|
|
283
|
+
},
|
|
284
|
+
"translationUrl": {
|
|
285
|
+
"type": "string",
|
|
286
|
+
"mutable": false,
|
|
287
|
+
"complexType": {
|
|
288
|
+
"original": "string",
|
|
289
|
+
"resolved": "string",
|
|
290
|
+
"references": {}
|
|
291
|
+
},
|
|
292
|
+
"required": false,
|
|
293
|
+
"optional": false,
|
|
294
|
+
"docs": {
|
|
295
|
+
"tags": [],
|
|
296
|
+
"text": "The translationurl"
|
|
297
|
+
},
|
|
298
|
+
"attribute": "translation-url",
|
|
299
|
+
"reflect": false,
|
|
300
|
+
"defaultValue": "''"
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
static get states() {
|
|
305
|
+
return {
|
|
306
|
+
"message": {},
|
|
307
|
+
"isMinimized": {},
|
|
308
|
+
"isClosed": {},
|
|
309
|
+
"isLoading": {}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
static get watchers() {
|
|
313
|
+
return [{
|
|
314
|
+
"propName": "cmsEndpoint",
|
|
315
|
+
"methodName": "watchEndpoint"
|
|
316
|
+
}, {
|
|
317
|
+
"propName": "language",
|
|
318
|
+
"methodName": "watchEndpoint"
|
|
319
|
+
}, {
|
|
320
|
+
"propName": "clientStyling",
|
|
321
|
+
"methodName": "handleStylingChange"
|
|
322
|
+
}, {
|
|
323
|
+
"propName": "clientStylingUrl",
|
|
324
|
+
"methodName": "handleStylingUrlChange"
|
|
325
|
+
}, {
|
|
326
|
+
"propName": "translationUrl",
|
|
327
|
+
"methodName": "handleNewTranslations"
|
|
328
|
+
}];
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GeneralNewsNotification } from './general-news-notification';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/general-news-notification';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const TRANSLATIONS = {
|
|
3
|
+
en: {
|
|
4
|
+
loading: 'Is Loading ...',
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
export const getTranslations = (url) => {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
fetch(url)
|
|
10
|
+
.then((res) => res.json())
|
|
11
|
+
.then((data) => {
|
|
12
|
+
Object.keys(data).forEach((lang) => {
|
|
13
|
+
if (!TRANSLATIONS[lang]) {
|
|
14
|
+
TRANSLATIONS[lang] = {};
|
|
15
|
+
}
|
|
16
|
+
for (let key in data[lang]) {
|
|
17
|
+
TRANSLATIONS[lang][key] = data[lang][key];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
resolve(true);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export const translate = (key, customLang, values) => {
|
|
25
|
+
const lang = customLang;
|
|
26
|
+
let translation = TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
|
|
27
|
+
if (values !== undefined) {
|
|
28
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
29
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
30
|
+
translation = translation.replace(regex, value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return translation;
|
|
34
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function format(first, middle, last) {
|
|
2
|
+
return ((first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : ''));
|
|
3
|
+
}
|
|
4
|
+
export const getDevice = () => {
|
|
5
|
+
let userAgent = window.navigator.userAgent;
|
|
6
|
+
if (userAgent.toLowerCase().match(/android/i)) {
|
|
7
|
+
return 'Android';
|
|
8
|
+
}
|
|
9
|
+
if (userAgent.toLowerCase().match(/iphone/i)) {
|
|
10
|
+
return 'iPhone';
|
|
11
|
+
}
|
|
12
|
+
if (userAgent.toLowerCase().match(/ipad|ipod/i)) {
|
|
13
|
+
return 'iPad';
|
|
14
|
+
}
|
|
15
|
+
return 'PC';
|
|
16
|
+
};
|
|
17
|
+
export const getDevicePlatform = () => {
|
|
18
|
+
const device = getDevice();
|
|
19
|
+
if (device) {
|
|
20
|
+
if (device === 'PC') {
|
|
21
|
+
return 'dk';
|
|
22
|
+
}
|
|
23
|
+
else if (device === 'iPad' || device === 'iPhone') {
|
|
24
|
+
return 'ios';
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return 'mtWeb';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|