Skip to content
Code-Schnipsel Gruppen Projekte
Commit a2fce670 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

fix: load multiple Google reCAPTCHA controls on one page

Übergeordneter 6497fecd
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -14,7 +14,7 @@ use QUI\Captcha\Handler;
QUI::$Ajax->registerFunction(
'package_quiqqer_captcha_ajax_getCurrentCaptchaControl',
function () {
return Handler::getCaptchaControl()->create();
return Handler::getDefaultCaptchaModuleControl()->create();
},
array()
);
......@@ -41,10 +41,29 @@ define('package/quiqqer/captcha/bin/controls/modules/Google', [
* event: onImport
*/
$onImport: function () {
var self = this;
this.Loader.inject(this.$Elm);
this.Loader.show();
if (window.loadingGoogleReCaptcha) {
var waitForGoogleReCaptcha = setInterval(function() {
if (typeof grecaptcha !== 'undefined') {
clearInterval(waitForGoogleReCaptcha);
self.$onGoogleCaptchaLoaded();
}
}, 200);
return;
}
if (typeof grecaptcha !== 'undefined') {
this.$onGoogleCaptchaLoaded();
return;
}
window.$onGoogleCaptchaLoaded = this.$onGoogleCaptchaLoaded;
window.loadingGoogleReCaptcha = true;
new Element('script', {
src : 'https://www.google.com/recaptcha/api.js?onload=$onGoogleCaptchaLoaded&render=explicit',
......@@ -57,6 +76,8 @@ define('package/quiqqer/captcha/bin/controls/modules/Google', [
* Callback function for Google api.js
*/
$onGoogleCaptchaLoaded: function () {
window.loadingGoogleReCaptcha = false;
var self = this;
this.Loader.hide();
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren