From fd4861a425e72e1c48a7ec27a007629667219e2f Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Tue, 19 Dec 2023 16:29:37 +0200 Subject: [PATCH 1/6] Load recaptcha related files on focus of the form fields. --- .../view/frontend/web/js/reCaptcha.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 4fdca404..105a0979 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -28,7 +28,17 @@ define( */ initialize: function () { this._super(); - this._loadApi(); + + this.attachFocusEvent(); + }, + + attachFocusEvent: function () { + let parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); + let self = this; + + parentForm.find('input, select').on('focus', function () { + self._loadApi(); + }); }, /** @@ -59,9 +69,7 @@ define( * @returns {Boolean} */ getIsInvisibleRecaptcha: function () { - if (this.settings === - - void 0) { + if (this.settings === void 0) { return false; } @@ -95,9 +103,7 @@ define( widgetId, parameters; - if (this.captchaInitialized || this.settings === - - void 0) { + if (this.captchaInitialized || this.settings === void 0) { return; } From 68ec0e4b31b01aa10312f86bd995b762beca0472 Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Wed, 20 Dec 2023 09:44:22 +0200 Subject: [PATCH 2/6] Update ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js Co-authored-by: Dan Wallis --- ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 105a0979..8f6628dd 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -33,7 +33,7 @@ define( }, attachFocusEvent: function () { - let parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); + const $parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); let self = this; parentForm.find('input, select').on('focus', function () { From 1c516e7af67efdeebf3c53f5ff44aa65633f17ca Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Wed, 20 Dec 2023 09:44:30 +0200 Subject: [PATCH 3/6] Update ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js Co-authored-by: Dan Wallis --- ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 8f6628dd..7a368291 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -34,7 +34,7 @@ define( attachFocusEvent: function () { const $parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); - let self = this; + const self = this; parentForm.find('input, select').on('focus', function () { self._loadApi(); From 6975569f209d5b02b2375296a092de47374b6587 Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Wed, 20 Dec 2023 09:49:31 +0200 Subject: [PATCH 4/6] apply suggesions from @freden --- ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 7a368291..044c43f6 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -36,7 +36,7 @@ define( const $parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); const self = this; - parentForm.find('input, select').on('focus', function () { + $parentForm.find('input, select').on('focus', function () { self._loadApi(); }); }, From d33620f2bd00b63500cc76272615ee5bcdf7d791 Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Wed, 20 Dec 2023 12:30:33 +0200 Subject: [PATCH 5/6] fix static tests. --- ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 044c43f6..31e1b47b 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -33,8 +33,7 @@ define( }, attachFocusEvent: function () { - const $parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); - const self = this; + const self = this, $parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); $parentForm.find('input, select').on('focus', function () { self._loadApi(); From a44a67afc5e6a486cfd863b4814f55f9a9a64456 Mon Sep 17 00:00:00 2001 From: Kostadin Bashev Date: Fri, 10 May 2024 09:14:48 +0300 Subject: [PATCH 6/6] Update ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js Co-authored-by: Ihor Sviziev --- ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 31e1b47b..dbca57cd 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -35,7 +35,7 @@ define( attachFocusEvent: function () { const self = this, $parentForm = $('#' + this.getReCaptchaId() + '-container').parents('form'); - $parentForm.find('input, select').on('focus', function () { + $parentForm.one('focus', 'input, select, textarea', function () { self._loadApi(); }); },