diff options
author | ctrlaltca <> | 2013-01-07 15:46:31 +0000 |
---|---|---|
committer | ctrlaltca <> | 2013-01-07 15:46:31 +0000 |
commit | cc486177d7379ddb116cb3a319192befad7fa182 (patch) | |
tree | 2493b8a77e0878152882598d7824575aaa5c1d6c | |
parent | 4af5784e5c51536e074ea51eacea7e6c79efee15 (diff) |
backported r3243 to trunk/
-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), ');', + '}', ))); } |