@internetstiftelsen/styleguide 2.26.18 → 2.26.19
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
CHANGED
package/src/app.scss
CHANGED
|
@@ -29,13 +29,6 @@ export default class Form {
|
|
|
29
29
|
this.errors = {};
|
|
30
30
|
this.validationRules = null;
|
|
31
31
|
|
|
32
|
-
this.recaptcha = this.element.getAttribute('data-recaptcha');
|
|
33
|
-
|
|
34
|
-
if (this.recaptcha) {
|
|
35
|
-
window.captchaCallback = this.captchaCallback;
|
|
36
|
-
this.renderCaptchaForm();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
32
|
if (this.validation) {
|
|
40
33
|
this.parseValidationRules();
|
|
41
34
|
}
|
|
@@ -48,14 +41,6 @@ export default class Form {
|
|
|
48
41
|
this.inputs = this.element.querySelectorAll('input');
|
|
49
42
|
}
|
|
50
43
|
|
|
51
|
-
renderCaptchaForm() {
|
|
52
|
-
const s = document.createElement('script');
|
|
53
|
-
s.defer = true;
|
|
54
|
-
s.setAttribute('data-origin', this.recaptcha);
|
|
55
|
-
s.setAttribute('src', 'https://www.google.com/recaptcha/api.js?onload=captchaCallback&render=6LdtNnkUAAAAACYo0vISI-z9tOyr3djjZore-6wY&hl=sv');
|
|
56
|
-
document.body.appendChild(s);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
44
|
parseValidationRules() {
|
|
60
45
|
const validationsStr = this.validation.getAttribute('content');
|
|
61
46
|
const validations = validationsStr.split('|');
|
|
@@ -142,10 +127,6 @@ export default class Form {
|
|
|
142
127
|
this.clearFieldErrors();
|
|
143
128
|
|
|
144
129
|
if (this.validate()) {
|
|
145
|
-
if (this.recaptcha) {
|
|
146
|
-
this.captchaCallback();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
130
|
this.send();
|
|
150
131
|
} else {
|
|
151
132
|
this.displayError({ message: this.i18n('Alla fält måste vara ifyllda') });
|
|
@@ -281,16 +262,6 @@ export default class Form {
|
|
|
281
262
|
this.events.emit('success', json);
|
|
282
263
|
};
|
|
283
264
|
|
|
284
|
-
captchaCallback = () => {
|
|
285
|
-
if (typeof window.grecaptcha !== 'undefined' && process.env.RECAPTCHA_KEY !== undefined) {
|
|
286
|
-
/* global grecaptcha */
|
|
287
|
-
grecaptcha.execute(process.env.RECAPTCHA_KEY, { action: this.recaptcha })
|
|
288
|
-
.then((token) => {
|
|
289
|
-
this.token = token;
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
|
|
294
265
|
reset = () => {
|
|
295
266
|
this.element.reset();
|
|
296
267
|
this.hideMessages();
|