homeflowjs 0.13.54 → 0.13.55
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/app/recaptcha.js
CHANGED
@@ -60,46 +60,65 @@ export default () => {
|
|
60
60
|
}
|
61
61
|
}
|
62
62
|
|
63
|
-
|
64
|
-
const invisibleRecaptcha = document.createElement('div');
|
65
|
-
invisibleRecaptcha.classList.add('g-recaptcha');
|
66
|
-
invisibleRecaptcha.dataset.sitekey = '6Lf16S0UAAAAAL0YaWCLRhChd4Uk77b-4Ai0ZdRY';
|
67
|
-
invisibleRecaptcha.dataset.callback = 'submitRecaptchaForm';
|
68
|
-
invisibleRecaptcha.dataset.size = 'invisible';
|
69
|
-
|
63
|
+
const appendRecaptchaScript = () => {
|
70
64
|
const recaptchaScript = document.createElement('script');
|
71
65
|
recaptchaScript.src = 'https://www.google.com/recaptcha/api.js';
|
72
66
|
recaptchaScript.id = 'recaptcha-script';
|
73
67
|
|
68
|
+
document.body.appendChild(recaptchaScript);
|
69
|
+
}
|
70
|
+
|
71
|
+
const onRecaptchaReady = (formSelectors) => {
|
72
|
+
if (window.recaptchaLoadingScriptInterval) {
|
73
|
+
clearTimeout(window.recaptchaLoadingScriptInterval);
|
74
|
+
window.recaptchaLoadingScriptInterval = undefined;
|
75
|
+
}
|
76
|
+
|
74
77
|
const forms = document.querySelectorAll(formSelectors.join(', '));
|
75
|
-
forms.forEach((form) => {
|
76
|
-
form.appendChild(invisibleRecaptcha);
|
77
|
-
});
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
79
|
+
forms.forEach((form, i) => {
|
80
|
+
const formRecaptchaWrapper = document.createElement('div');
|
81
|
+
formRecaptchaWrapper.id = `recaptcha-wrapper-${i}`;
|
82
|
+
|
83
|
+
form.appendChild(formRecaptchaWrapper);
|
84
|
+
|
85
|
+
const onRecaptchaSubmit = () => {
|
86
|
+
form.submit();
|
87
|
+
Homeflow.kickEvent('after_successful_recaptcha', form);
|
88
|
+
}
|
89
|
+
|
90
|
+
const widget = window.grecaptcha.render(`recaptcha-wrapper-${i}`, {
|
91
|
+
sitekey: '6Lf16S0UAAAAAL0YaWCLRhChd4Uk77b-4Ai0ZdRY',
|
92
|
+
callback: onRecaptchaSubmit,
|
93
|
+
size: 'invisible',
|
88
94
|
});
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
window.widgetIds = window.widgetIds
|
97
|
+
? [...window.widgetIds, widget]
|
98
|
+
: [widget]
|
99
|
+
|
100
|
+
form.addEventListener('submit', (e) => {
|
101
|
+
if (e.target.classList.contains('hfjs-form-invalid')) {
|
102
|
+
return;
|
103
|
+
}
|
104
|
+
|
105
|
+
e.preventDefault();
|
106
|
+
Homeflow.set('submitted_form', e.target);
|
107
|
+
grecaptcha.execute(widget);
|
101
108
|
});
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
function addRecaptchaV2(formSelectors) {
|
113
|
+
if (!document.getElementById('recaptcha-script')) {
|
114
|
+
appendRecaptchaScript();
|
102
115
|
}
|
116
|
+
|
117
|
+
window.recaptchaLoadingScriptInterval = setInterval(() => {
|
118
|
+
if (window.grecaptcha?.render) {
|
119
|
+
onRecaptchaReady(formSelectors)
|
120
|
+
}
|
121
|
+
}, 300);
|
103
122
|
}
|
104
123
|
|
105
124
|
if (Homeflow.get('recaptcha_version') === 3) {
|
package/package.json
CHANGED
@@ -28,8 +28,13 @@ const UserRegisterForm = (props) => {
|
|
28
28
|
|
29
29
|
const handleSubmit = (e) => {
|
30
30
|
e.preventDefault();
|
31
|
+
const { body } = Object.fromEntries(new FormData(e.target));
|
32
|
+
const formData = {
|
33
|
+
...localUser,
|
34
|
+
body,
|
35
|
+
};
|
31
36
|
|
32
|
-
const userParams = doNotContact ? { ...
|
37
|
+
const userParams = doNotContact ? { ...formData, do_not_contact: 1 } : formData;
|
33
38
|
userParams.marketing_preferences = {
|
34
39
|
...localUser.marketing_preferences, opt_in_marketing_statement: marketingStatement,
|
35
40
|
};
|
@@ -58,6 +63,11 @@ const UserRegisterForm = (props) => {
|
|
58
63
|
|
59
64
|
return (
|
60
65
|
<form onSubmit={handleSubmit} {...otherProps}>
|
66
|
+
<input
|
67
|
+
type="text"
|
68
|
+
name="body"
|
69
|
+
style={{ height: 0, width: 0, opacity: 0 }}
|
70
|
+
/>
|
61
71
|
{children}
|
62
72
|
</form>
|
63
73
|
);
|