@everymatrix/player-user-consents 1.31.2 → 1.33.0
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/{index-28f85617.js → index-e77a2edf.js} +37 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/player-user-consents.cjs.entry.js +112 -27
- package/dist/cjs/player-user-consents.cjs.js +2 -2
- package/dist/collection/components/player-user-consents/player-user-consents.css +12 -2
- package/dist/collection/components/player-user-consents/player-user-consents.js +61 -58
- package/dist/collection/utils/utils.js +83 -3
- package/dist/components/player-user-consents.js +113 -28
- package/dist/esm/{index-6f67dd59.js → index-b34076ff.js} +37 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/player-user-consents.entry.js +112 -27
- package/dist/esm/player-user-consents.js +2 -2
- package/dist/player-user-consents/p-6a20deb9.entry.js +1 -0
- package/dist/player-user-consents/p-b1139724.js +1 -0
- package/dist/player-user-consents/player-user-consents.esm.js +1 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/player-user-consents/.stencil/packages/player-user-consents/stencil.config.d.ts +2 -0
- package/dist/types/components/player-user-consents/player-user-consents.d.ts +13 -10
- package/dist/types/components.d.ts +12 -12
- package/dist/types/utils/utils.d.ts +2 -1
- package/package.json +1 -1
- package/dist/player-user-consents/p-0dbe810e.entry.js +0 -1
- package/dist/player-user-consents/p-cf852ecd.js +0 -1
- package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/player-user-consents/.stencil/packages/player-user-consents/stencil.config.d.ts +0 -2
|
@@ -591,6 +591,11 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
591
591
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
592
592
|
const instance = hostRef.$lazyInstance$ ;
|
|
593
593
|
let promise;
|
|
594
|
+
if (isInitialLoad) {
|
|
595
|
+
{
|
|
596
|
+
promise = safeCall(instance, 'componentWillLoad');
|
|
597
|
+
}
|
|
598
|
+
}
|
|
594
599
|
endSchedule();
|
|
595
600
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
596
601
|
};
|
|
@@ -767,6 +772,7 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
|
|
|
767
772
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
768
773
|
// check our new property value against our internal value
|
|
769
774
|
const hostRef = getHostRef(ref);
|
|
775
|
+
const elm = hostRef.$hostElement$ ;
|
|
770
776
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
771
777
|
const flags = hostRef.$flags$;
|
|
772
778
|
const instance = hostRef.$lazyInstance$ ;
|
|
@@ -779,6 +785,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
779
785
|
// set our new value!
|
|
780
786
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
781
787
|
if (instance) {
|
|
788
|
+
// get an array of method names of watch functions to call
|
|
789
|
+
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
790
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
791
|
+
if (watchMethods) {
|
|
792
|
+
// this instance is watching for when this property changed
|
|
793
|
+
watchMethods.map((watchMethodName) => {
|
|
794
|
+
try {
|
|
795
|
+
// fire off each of the watch methods that are watching this property
|
|
796
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
797
|
+
}
|
|
798
|
+
catch (e) {
|
|
799
|
+
consoleError(e, elm);
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
}
|
|
782
804
|
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
783
805
|
// looks like this value actually changed, so we've got work to do!
|
|
784
806
|
// but only if we've already rendered, otherwise just chill out
|
|
@@ -791,6 +813,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
791
813
|
};
|
|
792
814
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
793
815
|
if (cmpMeta.$members$) {
|
|
816
|
+
if (Cstr.watchers) {
|
|
817
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
818
|
+
}
|
|
794
819
|
// It's better to have a const than two Object.entries()
|
|
795
820
|
const members = Object.entries(cmpMeta.$members$);
|
|
796
821
|
const prototype = Cstr.prototype;
|
|
@@ -898,6 +923,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
898
923
|
endLoad();
|
|
899
924
|
}
|
|
900
925
|
if (!Cstr.isProxied) {
|
|
926
|
+
// we've never proxied this Constructor before
|
|
927
|
+
// let's add the getters/setters to its prototype before
|
|
928
|
+
// the first time we create an instance of the implementation
|
|
929
|
+
{
|
|
930
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
931
|
+
}
|
|
901
932
|
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
902
933
|
Cstr.isProxied = true;
|
|
903
934
|
}
|
|
@@ -921,6 +952,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
921
952
|
{
|
|
922
953
|
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
923
954
|
}
|
|
955
|
+
{
|
|
956
|
+
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
957
|
+
}
|
|
924
958
|
endNewInstance();
|
|
925
959
|
}
|
|
926
960
|
if (Cstr.style) {
|
|
@@ -1023,6 +1057,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1023
1057
|
{
|
|
1024
1058
|
cmpMeta.$attrsToReflect$ = [];
|
|
1025
1059
|
}
|
|
1060
|
+
{
|
|
1061
|
+
cmpMeta.$watchers$ = {};
|
|
1062
|
+
}
|
|
1026
1063
|
const tagName = cmpMeta.$tagName$;
|
|
1027
1064
|
const HostElement = class extends HTMLElement {
|
|
1028
1065
|
// StencilLazyHost
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-e77a2edf.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["player-user-consents.cjs",[[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"
|
|
17
|
+
return index.bootstrapLazy([["player-user-consents.cjs",[[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -2,14 +2,102 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-e77a2edf.js');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
8
|
+
const TRANSLATIONS = {
|
|
9
|
+
en: {
|
|
10
|
+
termsandconditions1: "I accept the ",
|
|
11
|
+
termsandconditions2: ", I have read and understood the ",
|
|
12
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
13
|
+
tc: "Terms and Conditions",
|
|
14
|
+
privacy: "Privacy Policy",
|
|
15
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
16
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
17
|
+
},
|
|
18
|
+
ro: {
|
|
19
|
+
termsandconditions1: "I accept the ",
|
|
20
|
+
termsandconditions2: ", I have read and understood the ",
|
|
21
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
22
|
+
tc: "Terms and Conditions",
|
|
23
|
+
privacy: "Privacy Policy",
|
|
24
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
25
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
26
|
+
},
|
|
27
|
+
hr: {
|
|
28
|
+
termsandconditions1: "I accept the ",
|
|
29
|
+
termsandconditions2: ", I have read and understood the ",
|
|
30
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
31
|
+
tc: "Terms and Conditions",
|
|
32
|
+
privacy: "Privacy Policy",
|
|
33
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
34
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
35
|
+
},
|
|
36
|
+
fr: {
|
|
37
|
+
termsandconditions1: "I accept the ",
|
|
38
|
+
termsandconditions2: ", I have read and understood the ",
|
|
39
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
40
|
+
tc: "Terms and Conditions",
|
|
41
|
+
privacy: "Privacy Policy",
|
|
42
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
43
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
44
|
+
},
|
|
45
|
+
cs: {
|
|
46
|
+
termsandconditions1: "I accept the ",
|
|
47
|
+
termsandconditions2: ", I have read and understood the ",
|
|
48
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
49
|
+
tc: "Terms and Conditions",
|
|
50
|
+
privacy: "Privacy Policy",
|
|
51
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
52
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
53
|
+
},
|
|
54
|
+
de: {
|
|
55
|
+
termsandconditions1: "I accept the ",
|
|
56
|
+
termsandconditions2: ", I have read and understood the ",
|
|
57
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
58
|
+
tc: "Terms and Conditions",
|
|
59
|
+
privacy: "Privacy Policy",
|
|
60
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
61
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
const getTranslations = (url) => {
|
|
65
|
+
// fetch url, get the data, replace the TRANSLATIONS content
|
|
66
|
+
return new Promise((resolve) => {
|
|
67
|
+
fetch(url)
|
|
68
|
+
.then((res) => res.json())
|
|
69
|
+
.then((data) => {
|
|
70
|
+
Object.keys(data).forEach((item) => {
|
|
71
|
+
for (let key in data[item]) {
|
|
72
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
resolve(true);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const translate = (key, customLang, values) => {
|
|
80
|
+
const lang = customLang;
|
|
81
|
+
let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
|
|
82
|
+
if (values !== undefined) {
|
|
83
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
84
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
85
|
+
translation = translation.replace(regex, value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return translation;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const playerUserConsentsCss = ":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.UserConsent:hover{cursor:pointer}.UserConsent{display:flex;align-items:baseline}.MandatoryItem{color:#f00;font-size:1.2rem}.ConsentLink{text-decoration:underline;color:var(--emfe-w-color-primary);font-weight:bold}";
|
|
8
92
|
|
|
9
93
|
const PlayerUserConsents = class {
|
|
10
94
|
constructor(hostRef) {
|
|
11
95
|
index.registerInstance(this, hostRef);
|
|
12
96
|
this.userLegislationConsent = index.createEvent(this, "userLegislationConsent", 7);
|
|
97
|
+
/**
|
|
98
|
+
* Language
|
|
99
|
+
*/
|
|
100
|
+
this.lang = 'en';
|
|
13
101
|
/**
|
|
14
102
|
* 'true' when parent expects component to emit it's current value
|
|
15
103
|
*/
|
|
@@ -26,44 +114,34 @@ const PlayerUserConsents = class {
|
|
|
26
114
|
* the title of the consent to be displayed
|
|
27
115
|
*/
|
|
28
116
|
this.consentTitle = '';
|
|
29
|
-
/**
|
|
30
|
-
* link to the t&c page
|
|
31
|
-
*/
|
|
32
|
-
this.tcLink = '#';
|
|
33
|
-
/**
|
|
34
|
-
* link to privacy policy page
|
|
35
|
-
*/
|
|
36
|
-
this.privacyLink = '#';
|
|
37
117
|
/**
|
|
38
118
|
* Client custom styling via inline style
|
|
39
119
|
*/
|
|
40
120
|
this.clientStyling = '';
|
|
121
|
+
/**
|
|
122
|
+
* Translation url
|
|
123
|
+
*/
|
|
124
|
+
this.translationUrl = '';
|
|
41
125
|
/**
|
|
42
126
|
* the text content to be rendered by the component. Determined at runtime
|
|
43
127
|
*/
|
|
44
128
|
this.textContent = '';
|
|
45
129
|
this.limitStylingAppends = false;
|
|
46
|
-
|
|
47
|
-
this.
|
|
48
|
-
termsandconditions1: "I accept the ",
|
|
49
|
-
termsandconditions2: ", I have read and understood the ",
|
|
50
|
-
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
51
|
-
tc: "Terms and Conditions",
|
|
52
|
-
privacy: "Privacy Policy",
|
|
53
|
-
sms: "I consent to receive marketing communication via SMS.",
|
|
54
|
-
emailmarketing: "I consent to receive marketing communication via Email."
|
|
55
|
-
};
|
|
130
|
+
this.goToTermsAndConditions = () => window.postMessage({ type: 'GoToTermsAndConditions' });
|
|
131
|
+
this.goToPrivacyPolicy = () => window.postMessage({ type: 'GoToPrivacyPolicy' });
|
|
56
132
|
this.setClientStyling = () => {
|
|
57
133
|
let sheet = document.createElement('style');
|
|
58
134
|
sheet.innerHTML = this.clientStyling;
|
|
59
135
|
this.stylingContainer.prepend(sheet);
|
|
60
136
|
};
|
|
61
137
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
138
|
+
handleNewTranslations() {
|
|
139
|
+
getTranslations(this.translationUrl);
|
|
140
|
+
}
|
|
141
|
+
async componentWillLoad() {
|
|
142
|
+
if (this.translationUrl.length > 2) {
|
|
143
|
+
await getTranslations(this.translationUrl);
|
|
144
|
+
}
|
|
67
145
|
}
|
|
68
146
|
userLegislationConsentHandler() {
|
|
69
147
|
this.userLegislationConsent.emit({
|
|
@@ -80,13 +158,20 @@ const PlayerUserConsents = class {
|
|
|
80
158
|
}
|
|
81
159
|
// end custom styling area
|
|
82
160
|
}
|
|
161
|
+
determineTextContent() {
|
|
162
|
+
return this.consentType === 'termsandconditions' ?
|
|
163
|
+
index.h("p", null, translate('termsandconditions1', this.lang), index.h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate('tc', this.lang)), translate('termsandconditions2', this.lang), index.h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate('privacy', this.lang)), translate('termsandconditions3', this.lang))
|
|
164
|
+
: index.h("p", null, translate('consentType', this.lang));
|
|
165
|
+
}
|
|
83
166
|
render() {
|
|
84
167
|
if (this.queried) {
|
|
85
168
|
this.userLegislationConsentHandler();
|
|
86
169
|
}
|
|
87
|
-
this.
|
|
88
|
-
return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("p", { class: "ConsentTitle" }, this.consentTitle), index.h("label", { class: "userConsent", htmlFor: "userConsent" }, index.h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.textContent, this.mandatory && index.h("span", { class: "MandatoryItem" }, "*"))));
|
|
170
|
+
return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("p", { class: "ConsentTitle" }, this.consentTitle), index.h("label", { class: "UserConsent", htmlFor: "userConsent" }, index.h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.determineTextContent(), this.mandatory && index.h("span", { class: "MandatoryItem" }, "*"))));
|
|
89
171
|
}
|
|
172
|
+
static get watchers() { return {
|
|
173
|
+
"translationUrl": ["handleNewTranslations"]
|
|
174
|
+
}; }
|
|
90
175
|
};
|
|
91
176
|
PlayerUserConsents.style = playerUserConsentsCss;
|
|
92
177
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./index-
|
|
3
|
+
const index = require('./index-e77a2edf.js');
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["player-user-consents.cjs",[[1,"player-user-consents",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"
|
|
18
|
+
return index.bootstrapLazy([["player-user-consents.cjs",[[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -7,12 +7,22 @@
|
|
|
7
7
|
font-weight: 600;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.
|
|
11
|
-
border-bottom: 1px solid #000;
|
|
10
|
+
.UserConsent:hover {
|
|
12
11
|
cursor: pointer;
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
.UserConsent {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: baseline;
|
|
17
|
+
}
|
|
18
|
+
|
|
15
19
|
.MandatoryItem {
|
|
16
20
|
color: #f00;
|
|
17
21
|
font-size: 1.2rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ConsentLink {
|
|
25
|
+
text-decoration: underline;
|
|
26
|
+
color: var(--emfe-w-color-primary);
|
|
27
|
+
font-weight: bold;
|
|
18
28
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { Component, h, Event, Prop, State } from '@stencil/core';
|
|
1
|
+
import { Component, h, Event, Prop, State, Watch } from '@stencil/core';
|
|
2
|
+
import { getTranslations, translate } from '../../utils/utils';
|
|
2
3
|
export class PlayerUserConsents {
|
|
3
4
|
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* Language
|
|
7
|
+
*/
|
|
8
|
+
this.lang = 'en';
|
|
4
9
|
/**
|
|
5
10
|
* 'true' when parent expects component to emit it's current value
|
|
6
11
|
*/
|
|
@@ -17,49 +22,34 @@ export class PlayerUserConsents {
|
|
|
17
22
|
* the title of the consent to be displayed
|
|
18
23
|
*/
|
|
19
24
|
this.consentTitle = '';
|
|
20
|
-
/**
|
|
21
|
-
* link to the t&c page
|
|
22
|
-
*/
|
|
23
|
-
this.tcLink = '#';
|
|
24
|
-
/**
|
|
25
|
-
* link to privacy policy page
|
|
26
|
-
*/
|
|
27
|
-
this.privacyLink = '#';
|
|
28
25
|
/**
|
|
29
26
|
* Client custom styling via inline style
|
|
30
27
|
*/
|
|
31
28
|
this.clientStyling = '';
|
|
29
|
+
/**
|
|
30
|
+
* Translation url
|
|
31
|
+
*/
|
|
32
|
+
this.translationUrl = '';
|
|
32
33
|
/**
|
|
33
34
|
* the text content to be rendered by the component. Determined at runtime
|
|
34
35
|
*/
|
|
35
36
|
this.textContent = '';
|
|
36
37
|
this.limitStylingAppends = false;
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
termsandconditions1: "I accept the ",
|
|
40
|
-
termsandconditions2: ", I have read and understood the ",
|
|
41
|
-
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
42
|
-
tc: "Terms and Conditions",
|
|
43
|
-
privacy: "Privacy Policy",
|
|
44
|
-
sms: "I consent to receive marketing communication via SMS.",
|
|
45
|
-
emailmarketing: "I consent to receive marketing communication via Email."
|
|
46
|
-
};
|
|
38
|
+
this.goToTermsAndConditions = () => window.postMessage({ type: 'GoToTermsAndConditions' });
|
|
39
|
+
this.goToPrivacyPolicy = () => window.postMessage({ type: 'GoToPrivacyPolicy' });
|
|
47
40
|
this.setClientStyling = () => {
|
|
48
41
|
let sheet = document.createElement('style');
|
|
49
42
|
sheet.innerHTML = this.clientStyling;
|
|
50
43
|
this.stylingContainer.prepend(sheet);
|
|
51
44
|
};
|
|
52
45
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.stringVariants['termsandconditions3'])
|
|
61
|
-
: h("span", null, this.stringVariants[this.consentType]);
|
|
62
|
-
return result;
|
|
46
|
+
handleNewTranslations() {
|
|
47
|
+
getTranslations(this.translationUrl);
|
|
48
|
+
}
|
|
49
|
+
async componentWillLoad() {
|
|
50
|
+
if (this.translationUrl.length > 2) {
|
|
51
|
+
await getTranslations(this.translationUrl);
|
|
52
|
+
}
|
|
63
53
|
}
|
|
64
54
|
userLegislationConsentHandler() {
|
|
65
55
|
this.userLegislationConsent.emit({
|
|
@@ -76,16 +66,25 @@ export class PlayerUserConsents {
|
|
|
76
66
|
}
|
|
77
67
|
// end custom styling area
|
|
78
68
|
}
|
|
69
|
+
determineTextContent() {
|
|
70
|
+
return this.consentType === 'termsandconditions' ?
|
|
71
|
+
h("p", null,
|
|
72
|
+
translate('termsandconditions1', this.lang),
|
|
73
|
+
h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate('tc', this.lang)),
|
|
74
|
+
translate('termsandconditions2', this.lang),
|
|
75
|
+
h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate('privacy', this.lang)),
|
|
76
|
+
translate('termsandconditions3', this.lang))
|
|
77
|
+
: h("p", null, translate('consentType', this.lang));
|
|
78
|
+
}
|
|
79
79
|
render() {
|
|
80
80
|
if (this.queried) {
|
|
81
81
|
this.userLegislationConsentHandler();
|
|
82
82
|
}
|
|
83
|
-
this.textContent = this.determineTextContent();
|
|
84
83
|
return (h("div", { ref: el => this.stylingContainer = el },
|
|
85
84
|
h("p", { class: "ConsentTitle" }, this.consentTitle),
|
|
86
|
-
h("label", { class: "
|
|
85
|
+
h("label", { class: "UserConsent", htmlFor: "userConsent" },
|
|
87
86
|
h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }),
|
|
88
|
-
this.
|
|
87
|
+
this.determineTextContent(),
|
|
89
88
|
this.mandatory && h("span", { class: "MandatoryItem" }, "*"))));
|
|
90
89
|
}
|
|
91
90
|
static get is() { return "player-user-consents"; }
|
|
@@ -97,6 +96,24 @@ export class PlayerUserConsents {
|
|
|
97
96
|
"$": ["player-user-consents.css"]
|
|
98
97
|
}; }
|
|
99
98
|
static get properties() { return {
|
|
99
|
+
"lang": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"mutable": true,
|
|
102
|
+
"complexType": {
|
|
103
|
+
"original": "string",
|
|
104
|
+
"resolved": "string",
|
|
105
|
+
"references": {}
|
|
106
|
+
},
|
|
107
|
+
"required": false,
|
|
108
|
+
"optional": false,
|
|
109
|
+
"docs": {
|
|
110
|
+
"tags": [],
|
|
111
|
+
"text": "Language"
|
|
112
|
+
},
|
|
113
|
+
"attribute": "lang",
|
|
114
|
+
"reflect": true,
|
|
115
|
+
"defaultValue": "'en'"
|
|
116
|
+
},
|
|
100
117
|
"queried": {
|
|
101
118
|
"type": "boolean",
|
|
102
119
|
"mutable": false,
|
|
@@ -169,7 +186,7 @@ export class PlayerUserConsents {
|
|
|
169
186
|
"reflect": true,
|
|
170
187
|
"defaultValue": "''"
|
|
171
188
|
},
|
|
172
|
-
"
|
|
189
|
+
"clientStyling": {
|
|
173
190
|
"type": "string",
|
|
174
191
|
"mutable": false,
|
|
175
192
|
"complexType": {
|
|
@@ -181,13 +198,13 @@ export class PlayerUserConsents {
|
|
|
181
198
|
"optional": false,
|
|
182
199
|
"docs": {
|
|
183
200
|
"tags": [],
|
|
184
|
-
"text": "
|
|
201
|
+
"text": "Client custom styling via inline style"
|
|
185
202
|
},
|
|
186
|
-
"attribute": "
|
|
187
|
-
"reflect":
|
|
188
|
-
"defaultValue": "'
|
|
203
|
+
"attribute": "client-styling",
|
|
204
|
+
"reflect": false,
|
|
205
|
+
"defaultValue": "''"
|
|
189
206
|
},
|
|
190
|
-
"
|
|
207
|
+
"translationUrl": {
|
|
191
208
|
"type": "string",
|
|
192
209
|
"mutable": false,
|
|
193
210
|
"complexType": {
|
|
@@ -199,28 +216,10 @@ export class PlayerUserConsents {
|
|
|
199
216
|
"optional": false,
|
|
200
217
|
"docs": {
|
|
201
218
|
"tags": [],
|
|
202
|
-
"text": "
|
|
219
|
+
"text": "Translation url"
|
|
203
220
|
},
|
|
204
|
-
"attribute": "
|
|
221
|
+
"attribute": "translation-url",
|
|
205
222
|
"reflect": true,
|
|
206
|
-
"defaultValue": "'#'"
|
|
207
|
-
},
|
|
208
|
-
"clientStyling": {
|
|
209
|
-
"type": "string",
|
|
210
|
-
"mutable": false,
|
|
211
|
-
"complexType": {
|
|
212
|
-
"original": "string",
|
|
213
|
-
"resolved": "string",
|
|
214
|
-
"references": {}
|
|
215
|
-
},
|
|
216
|
-
"required": false,
|
|
217
|
-
"optional": false,
|
|
218
|
-
"docs": {
|
|
219
|
-
"tags": [],
|
|
220
|
-
"text": "Client custom styling via inline style"
|
|
221
|
-
},
|
|
222
|
-
"attribute": "client-styling",
|
|
223
|
-
"reflect": false,
|
|
224
223
|
"defaultValue": "''"
|
|
225
224
|
}
|
|
226
225
|
}; }
|
|
@@ -244,4 +243,8 @@ export class PlayerUserConsents {
|
|
|
244
243
|
"references": {}
|
|
245
244
|
}
|
|
246
245
|
}]; }
|
|
246
|
+
static get watchers() { return [{
|
|
247
|
+
"propName": "translationUrl",
|
|
248
|
+
"methodName": "handleNewTranslations"
|
|
249
|
+
}]; }
|
|
247
250
|
}
|
|
@@ -1,3 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const TRANSLATIONS = {
|
|
3
|
+
en: {
|
|
4
|
+
termsandconditions1: "I accept the ",
|
|
5
|
+
termsandconditions2: ", I have read and understood the ",
|
|
6
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
7
|
+
tc: "Terms and Conditions",
|
|
8
|
+
privacy: "Privacy Policy",
|
|
9
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
10
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
11
|
+
},
|
|
12
|
+
ro: {
|
|
13
|
+
termsandconditions1: "I accept the ",
|
|
14
|
+
termsandconditions2: ", I have read and understood the ",
|
|
15
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
16
|
+
tc: "Terms and Conditions",
|
|
17
|
+
privacy: "Privacy Policy",
|
|
18
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
19
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
20
|
+
},
|
|
21
|
+
hr: {
|
|
22
|
+
termsandconditions1: "I accept the ",
|
|
23
|
+
termsandconditions2: ", I have read and understood the ",
|
|
24
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
25
|
+
tc: "Terms and Conditions",
|
|
26
|
+
privacy: "Privacy Policy",
|
|
27
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
28
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
29
|
+
},
|
|
30
|
+
fr: {
|
|
31
|
+
termsandconditions1: "I accept the ",
|
|
32
|
+
termsandconditions2: ", I have read and understood the ",
|
|
33
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
34
|
+
tc: "Terms and Conditions",
|
|
35
|
+
privacy: "Privacy Policy",
|
|
36
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
37
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
38
|
+
},
|
|
39
|
+
cs: {
|
|
40
|
+
termsandconditions1: "I accept the ",
|
|
41
|
+
termsandconditions2: ", I have read and understood the ",
|
|
42
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
43
|
+
tc: "Terms and Conditions",
|
|
44
|
+
privacy: "Privacy Policy",
|
|
45
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
46
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
47
|
+
},
|
|
48
|
+
de: {
|
|
49
|
+
termsandconditions1: "I accept the ",
|
|
50
|
+
termsandconditions2: ", I have read and understood the ",
|
|
51
|
+
termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
|
|
52
|
+
tc: "Terms and Conditions",
|
|
53
|
+
privacy: "Privacy Policy",
|
|
54
|
+
sms: "I consent to receive marketing communication via SMS.",
|
|
55
|
+
emailmarketing: "I consent to receive marketing communication via Email."
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
export const getTranslations = (url) => {
|
|
59
|
+
// fetch url, get the data, replace the TRANSLATIONS content
|
|
60
|
+
return new Promise((resolve) => {
|
|
61
|
+
fetch(url)
|
|
62
|
+
.then((res) => res.json())
|
|
63
|
+
.then((data) => {
|
|
64
|
+
Object.keys(data).forEach((item) => {
|
|
65
|
+
for (let key in data[item]) {
|
|
66
|
+
TRANSLATIONS[item][key] = data[item][key];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
resolve(true);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
export const translate = (key, customLang, values) => {
|
|
74
|
+
const lang = customLang;
|
|
75
|
+
let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
|
|
76
|
+
if (values !== undefined) {
|
|
77
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
78
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
79
|
+
translation = translation.replace(regex, value);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return translation;
|
|
83
|
+
};
|