@gudhub/ssg-web-components-library 1.0.118 → 1.0.119
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/package.json +1 -1
- package/src/components/get-in-touch-form/get-in-touch-form.html +3 -0
- package/src/components/get-in-touch-form/get-in-touch-form.js +72 -16
- package/src/components/get-in-touch-form/get-in-touch-form.scss +15 -0
- package/src/config.js +1 -0
- package/src/components/liqpay-payment-button/config.js +0 -6
- package/src/components/liqpay-payment-button/liqpay-payment-button.html +0 -5
- package/src/components/liqpay-payment-button/liqpay-payment-button.js +0 -23
- package/src/components/liqpay-payment-button/liqpay-payment-button.json +0 -4
- package/src/components/liqpay-payment-button/liqpay-payment-button.md +0 -0
- package/src/components/liqpay-payment-button/liqpay-payment-button.scss +0 -7
package/package.json
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
<button type="submit" class="btn">${buttonText ? buttonText : 'Get in touch'}</button>
|
|
11
11
|
<div class="loader"></div>
|
|
12
12
|
</div>
|
|
13
|
+
<div class="recaptcha-notice">
|
|
14
|
+
This site is protected by reCAPTCHA.
|
|
15
|
+
</div>
|
|
13
16
|
</form>
|
|
14
17
|
<div class="overflow success">
|
|
15
18
|
<div class="icon_wrapper">
|
|
@@ -5,6 +5,7 @@ import defaultConfigs from './get-in-touch-form-data.json';
|
|
|
5
5
|
import { checkInputsValidations } from './inputsValidation.js';
|
|
6
6
|
|
|
7
7
|
let recaptchaPromise = null;
|
|
8
|
+
let recaptchaBadgeObserver = null;
|
|
8
9
|
|
|
9
10
|
function loadRecaptcha(siteKey) {
|
|
10
11
|
if (!siteKey) {
|
|
@@ -35,16 +36,41 @@ function loadRecaptcha(siteKey) {
|
|
|
35
36
|
return recaptchaPromise;
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
function hideRecaptchaBadge() {
|
|
40
|
+
const badge = document.querySelector('.grecaptcha-badge');
|
|
41
|
+
|
|
42
|
+
if (!badge) return;
|
|
43
|
+
|
|
44
|
+
badge.style.setProperty('visibility', 'hidden', 'important');
|
|
45
|
+
badge.style.setProperty('opacity', '0', 'important');
|
|
46
|
+
badge.style.setProperty('pointer-events', 'none', 'important');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function observeRecaptchaBadge() {
|
|
50
|
+
hideRecaptchaBadge();
|
|
51
|
+
|
|
52
|
+
if (recaptchaBadgeObserver) return;
|
|
53
|
+
|
|
54
|
+
recaptchaBadgeObserver = new MutationObserver(() => {
|
|
55
|
+
hideRecaptchaBadge();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
recaptchaBadgeObserver.observe(document.body, {
|
|
59
|
+
childList: true,
|
|
60
|
+
subtree: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
38
64
|
class GetInTouchForm extends GHComponent {
|
|
39
65
|
constructor() {
|
|
40
66
|
super();
|
|
41
67
|
|
|
42
|
-
this.formId = this.getAttribute(
|
|
68
|
+
this.formId = this.getAttribute('data-form-id');
|
|
43
69
|
this.defaultConfigs = defaultConfigs;
|
|
44
70
|
|
|
45
71
|
this.generateInput = this.generateInput;
|
|
46
72
|
this.isFormSubmitted = false;
|
|
47
|
-
|
|
73
|
+
|
|
48
74
|
this.placement = 'main';
|
|
49
75
|
this.config = window.getConfig()?.componentsConfigs?.formConfig || window.getConfig()?.formConfig;
|
|
50
76
|
|
|
@@ -66,7 +92,11 @@ class GetInTouchForm extends GHComponent {
|
|
|
66
92
|
this.attachEventListeners();
|
|
67
93
|
|
|
68
94
|
if (this.recaptcha_site_key) {
|
|
69
|
-
loadRecaptcha(this.recaptcha_site_key)
|
|
95
|
+
loadRecaptcha(this.recaptcha_site_key)
|
|
96
|
+
.then(() => {
|
|
97
|
+
observeRecaptchaBadge();
|
|
98
|
+
})
|
|
99
|
+
.catch(console.error);
|
|
70
100
|
}
|
|
71
101
|
}
|
|
72
102
|
}
|
|
@@ -76,15 +106,26 @@ class GetInTouchForm extends GHComponent {
|
|
|
76
106
|
super.render(html);
|
|
77
107
|
this.attachEventListeners();
|
|
78
108
|
|
|
79
|
-
|
|
109
|
+
if (this.recaptcha_site_key) {
|
|
110
|
+
loadRecaptcha(this.recaptcha_site_key)
|
|
111
|
+
.then(() => {
|
|
112
|
+
observeRecaptchaBadge();
|
|
113
|
+
})
|
|
114
|
+
.catch(console.error);
|
|
115
|
+
}
|
|
80
116
|
}
|
|
81
117
|
|
|
82
118
|
attachEventListeners() {
|
|
83
|
-
this.getElementsByTagName('form')[0]
|
|
84
|
-
|
|
119
|
+
const form = this.getElementsByTagName('form')[0];
|
|
120
|
+
const restartButton = this.getElementsByClassName('restart_button')[0];
|
|
85
121
|
|
|
86
|
-
|
|
87
|
-
.addEventListener('
|
|
122
|
+
if (form) {
|
|
123
|
+
form.addEventListener('submit', (e) => this.handleSubmit(e));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (restartButton) {
|
|
127
|
+
restartButton.addEventListener('click', () => this.hideFail());
|
|
128
|
+
}
|
|
88
129
|
}
|
|
89
130
|
|
|
90
131
|
onParentPopupClose() {
|
|
@@ -99,7 +140,7 @@ class GetInTouchForm extends GHComponent {
|
|
|
99
140
|
initConfig(formConfigs) {
|
|
100
141
|
try {
|
|
101
142
|
this.config = formConfigs.find(({ id }) => id === this.formId);
|
|
102
|
-
if (!this.config) throw new Error(
|
|
143
|
+
if (!this.config) throw new Error('Config not found');
|
|
103
144
|
} catch {
|
|
104
145
|
const defaultId = this.isInPopup ? 'default popup' : 'default';
|
|
105
146
|
this.config = defaultConfigs.find(({ id }) => id === defaultId);
|
|
@@ -107,7 +148,7 @@ class GetInTouchForm extends GHComponent {
|
|
|
107
148
|
|
|
108
149
|
this.titleName = this.getAttribute('data-form-title') || this.config.title;
|
|
109
150
|
this.subtitleName = this.getAttribute('data-form-subtitle') || this.config.subtitle;
|
|
110
|
-
this.placement = this.getAttribute('data-form-placement') ||
|
|
151
|
+
this.placement = this.getAttribute('data-form-placement') || 'main';
|
|
111
152
|
this.buttonText = this.getAttribute('data-form-button-text') || this.config.button_text;
|
|
112
153
|
}
|
|
113
154
|
|
|
@@ -121,6 +162,8 @@ class GetInTouchForm extends GHComponent {
|
|
|
121
162
|
|
|
122
163
|
return new Promise((resolve, reject) => {
|
|
123
164
|
grecaptcha.ready(() => {
|
|
165
|
+
hideRecaptchaBadge();
|
|
166
|
+
|
|
124
167
|
grecaptcha.execute(this.recaptcha_site_key, { action })
|
|
125
168
|
.then(resolve)
|
|
126
169
|
.catch(reject);
|
|
@@ -146,7 +189,6 @@ class GetInTouchForm extends GHComponent {
|
|
|
146
189
|
}
|
|
147
190
|
|
|
148
191
|
this.handleSuccessFormValidation(form, token);
|
|
149
|
-
|
|
150
192
|
} catch (error) {
|
|
151
193
|
console.error(error);
|
|
152
194
|
this.showFail();
|
|
@@ -179,7 +221,7 @@ class GetInTouchForm extends GHComponent {
|
|
|
179
221
|
inputsValidation = async (form) => {
|
|
180
222
|
const inputs = Array.from(form.querySelectorAll('input'));
|
|
181
223
|
return checkInputsValidations(inputs);
|
|
182
|
-
}
|
|
224
|
+
};
|
|
183
225
|
|
|
184
226
|
verifyRecaptcha = async (recaptchaToken) => {
|
|
185
227
|
const response = await fetch('/api/verify-recaptcha', {
|
|
@@ -200,7 +242,7 @@ class GetInTouchForm extends GHComponent {
|
|
|
200
242
|
}
|
|
201
243
|
|
|
202
244
|
return data;
|
|
203
|
-
}
|
|
245
|
+
};
|
|
204
246
|
|
|
205
247
|
createDataObject(form, placement, recaptchaToken) {
|
|
206
248
|
const inputs = {};
|
|
@@ -230,13 +272,24 @@ class GetInTouchForm extends GHComponent {
|
|
|
230
272
|
|
|
231
273
|
addLoader() {
|
|
232
274
|
this.classList.add('loading');
|
|
233
|
-
|
|
275
|
+
|
|
276
|
+
const btn = this.querySelector('button[type="submit"]');
|
|
277
|
+
|
|
278
|
+
if (btn) {
|
|
279
|
+
btn.disabled = true;
|
|
280
|
+
}
|
|
234
281
|
}
|
|
235
282
|
|
|
236
283
|
removeLoader() {
|
|
237
284
|
this.classList.remove('loading');
|
|
285
|
+
|
|
238
286
|
const btn = this.querySelector('button[type="submit"]');
|
|
239
|
-
|
|
287
|
+
|
|
288
|
+
if (btn) {
|
|
289
|
+
setTimeout(() => {
|
|
290
|
+
btn.disabled = false;
|
|
291
|
+
}, 500);
|
|
292
|
+
}
|
|
240
293
|
}
|
|
241
294
|
|
|
242
295
|
showSuccess({ email, phone }) {
|
|
@@ -278,6 +331,9 @@ class GetInTouchForm extends GHComponent {
|
|
|
278
331
|
|
|
279
332
|
hideFail() {
|
|
280
333
|
const el = this.querySelector('.overflow.fail');
|
|
334
|
+
|
|
335
|
+
if (!el) return;
|
|
336
|
+
|
|
281
337
|
el.style.opacity = 0;
|
|
282
338
|
|
|
283
339
|
setTimeout(() => {
|
|
@@ -315,4 +371,4 @@ class GetInTouchForm extends GHComponent {
|
|
|
315
371
|
|
|
316
372
|
if (!customElements.get('get-in-touch-form')) {
|
|
317
373
|
customElements.define('get-in-touch-form', GetInTouchForm);
|
|
318
|
-
}
|
|
374
|
+
}
|
|
@@ -271,6 +271,15 @@ get-in-touch-form {
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
+
|
|
275
|
+
.recaptcha-notice {
|
|
276
|
+
margin-top: 20px;
|
|
277
|
+
font-size: 12px;
|
|
278
|
+
line-height: 1.4;
|
|
279
|
+
opacity: 0.7;
|
|
280
|
+
text-align: center;
|
|
281
|
+
}
|
|
282
|
+
|
|
274
283
|
&[data-in-popup] {
|
|
275
284
|
.get-in-touch-form {
|
|
276
285
|
padding-top: 0;
|
|
@@ -368,4 +377,10 @@ popup-container[data-position="bottom-right"] {
|
|
|
368
377
|
}
|
|
369
378
|
}
|
|
370
379
|
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
body .grecaptcha-badge {
|
|
383
|
+
visibility: hidden !important;
|
|
384
|
+
opacity: 0 !important;
|
|
385
|
+
pointer-events: none !important;
|
|
371
386
|
}
|
package/src/config.js
CHANGED
|
@@ -67,6 +67,7 @@ export { GoogleAnalytics } from './components/google-analytics/config.js';
|
|
|
67
67
|
export { GoogleTag } from './components/google-tag/config.js';
|
|
68
68
|
export { cookiesPopup } from './components/cookies-popup/config.js';
|
|
69
69
|
export { infoTable } from './components/info-table/config.js';
|
|
70
|
+
export { liqpayComponent } from './components/liqpay-component/config.js';
|
|
70
71
|
export { faqComponent } from './components/faq-component/config.js';
|
|
71
72
|
export { videoSlider } from './components/video-slider/config.js';
|
|
72
73
|
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import html from './liqpay-payment-button.html';
|
|
2
|
-
import './liqpay-payment-button.scss';
|
|
3
|
-
import jsonTemplate from './liqpay-payment-button.json';
|
|
4
|
-
|
|
5
|
-
class liqpayPaymentButton extends window.GHComponent {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
super.setDefaultData(jsonTemplate);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async onServerRender() {
|
|
12
|
-
this.ghId = this.getAttribute('data-gh-id') || null;
|
|
13
|
-
this.json = await super.getGhData(this.ghId, 'areas');
|
|
14
|
-
|
|
15
|
-
console.log("AAAAAAAAAAAAAAAAAAAAAAAA", this.json);
|
|
16
|
-
|
|
17
|
-
if (this.json) {
|
|
18
|
-
super.render(html);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
window.customElements.define('liqpay-payment-button', liqpayPaymentButton);
|
|
File without changes
|