renderScriptBlock() public static method

Renders javascript block
public static renderScriptBlock ( $script ) : string
return string rendering result
Ejemplo n.º 1
0
 /**
  * @return string header template with "Copy code" link.
  */
 protected function getHeaderTemplate()
 {
     $id = $this->getClientID();
     return TJavaScript::renderScriptBlock("new Prado.WebUI.TTextHighlighter('{$id}');");
 }
Ejemplo n.º 2
0
 public function renderContents($writer)
 {
     $readyscript = 'jQuery(document).trigger(' . TJavaScript::quoteString('captchaready:' . $this->getClientID()) . ')';
     $cs = $this->Page->ClientScript;
     $id = $this->getClientID();
     $divid = $id . '_1_recaptchadiv';
     $writer->write('<div id="' . htmlspecialchars($divid) . '">');
     if (!$this->Page->IsCallback) {
         $writer->write(TJavaScript::renderScriptBlock('var RecaptchaOptions = ' . TJavaScript::jsonEncode($this->getClientSideOptions()) . ';'));
         $html = $this->recaptcha_get_html($this->getPublicKey());
         /*
         reCAPTCHA currently does not support multiple validations per page
         $html = str_replace(
         	array(self::ChallengeFieldName,self::ResponseFieldName),
         	array($this->getChallengeFieldName(),$this->getResponseFieldName()),
         	$html
         );
         */
         $writer->write($html);
         $cs->registerEndScript('ReCaptcha::EventScript', 'jQuery(document).ready(function() { ' . $readyscript . '; } );');
     } else {
         $options = $this->getClientSideOptions();
         $options['callback'] = new TJavaScriptLiteral('function() { ' . $readyscript . '; ' . $this->getCallbackScript() . '; }');
         $cs->registerScriptFile('ReCaptcha::AjaxScript', self::RECAPTCHA_JS);
         $cs->registerEndScript('ReCaptcha::CreateScript::' . $id, implode(' ', array('if (!jQuery(' . TJavaScript::quoteString('#' . $this->getResponseFieldName()) . '))', '{', 'Recaptcha.destroy();', 'Recaptcha.create(', TJavaScript::quoteString($this->getPublicKey()) . ', ', TJavaScript::quoteString($divid) . ', ', TJavaScript::encode($options), ');', '}')));
     }
     $writer->write('</div>');
 }