diff options
author | ctrlaltca <> | 2013-01-07 15:45:07 +0000 |
---|---|---|
committer | ctrlaltca <> | 2013-01-07 15:45:07 +0000 |
commit | 13c82d976c4ac5f03ab4f76f6886b78802e35d81 (patch) | |
tree | bc514117af108712189c55f8b956abe90e13a6e5 /framework/Web | |
parent | 57311df5b3b0ae9db1fffb7cacfad57f65abd7fe (diff) |
reworked fix for #431
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/UI/WebControls/TReCaptcha.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/framework/Web/UI/WebControls/TReCaptcha.php b/framework/Web/UI/WebControls/TReCaptcha.php index c6cf4185..31fcf1ca 100644 --- a/framework/Web/UI/WebControls/TReCaptcha.php +++ b/framework/Web/UI/WebControls/TReCaptcha.php @@ -217,7 +217,12 @@ class TReCaptcha extends TWebControl implements IValidatable // if we're in a callback, then schedule re-rendering of the control // if not, don't do anything, because a new challenge will be rendered anyway if ($this->Page->IsCallback) - $this->Page->ClientScript->registerEndScript($this->getClientID().'::refresh','Recaptcha.reload();'); + $this->Page->ClientScript->registerEndScript($this->getClientID().'::refresh', implode(' ', array( + // work-around for "ReCaptchaState is undefined" bug + // (if there's no previous instance yet, regenerating the token is not needed anyway) + 'if (typeof ReCaptchaState != "undefined") '. + ' Recaptcha.reload();', + ))); } public function renderContents($writer) @@ -244,7 +249,7 @@ class TReCaptcha extends TWebControl implements IValidatable ); */ $writer->write($html); - + $cs->registerEndScript('ReCaptcha::EventScript', 'Event.observe(document, "dom:loaded", function() { '.$readyscript.'; } );'); } else @@ -254,11 +259,14 @@ class TReCaptcha extends TWebControl implements IValidatable $cs->registerScriptFile('ReCaptcha::AjaxScript', 'http://www.google.com/recaptcha/api/js/recaptcha_ajax.js'); $cs->registerEndScript('ReCaptcha::CreateScript::'.$id, implode(' ', array( 'if (!$('.TJavaScript::quoteString($this->getResponseFieldName()).'))', + '{', + 'Recaptcha.destroy();', 'Recaptcha.create(', TJavaScript::quoteString($this->getPublicKey()).', ', TJavaScript::quoteString($divid).', ', TJavaScript::encode($options), ');', + '}', ))); } |