/** * Registers the relevant JavaScript. */ protected function registerClientScript() { $id = $this->getClientID(); $options = TJavaScript::encode($this->getClientOptions()); $className = $this->getClientClassName(); $page = $this->getPage(); $cs = $page->getClientScript(); $cs->registerPradoScript('accordion'); $code = "new {$className}({$options});"; $cs->registerEndScript("prado:{$id}", $code); // ensure an item is always active and visible $index = $this->getActiveViewIndex(); if (!$this->getViews()->itemAt($index)->Visible) { $index = 0; } $cs->registerHiddenField($id . '_1', $index); $page->registerRequiresPostData($this); $page->registerRequiresPostData($id . "_1"); }
public function registerDefaultButton($panel, $button) { $panelID = is_string($panel) ? $panel : $panel->getUniqueID(); if (is_string($button)) { $buttonID = $button; } else { $button->setIsDefaultButton(true); $buttonID = $button->getUniqueID(); } $options = TJavaScript::encode($this->getDefaultButtonOptions($panelID, $buttonID)); $code = "new Prado.WebUI.DefaultButton({$options});"; $this->_endScripts['prado:' . $panelID] = $code; $this->_hiddenFields[TPage::FIELD_POSTBACK_TARGET] = ''; $this->registerPradoScriptInternal('prado'); $params = array($panelID, $buttonID); $this->_page->registerCachingAction('Page.ClientScript', 'registerDefaultButton', $params); }
/** * Registers the editor javascript file and code to initialize the editor. */ protected function registerEditorClientScript($writer) { $this->loadJavascriptLibrary(); $scripts = $this->getPage()->getClientScript(); $options = array('EditorOptions' => $this->getEditorOptions()); if ($this->getEnableCompression()) { $options['CompressionOptions'] = $this->getCompressionOptions(); } $options = TJavaScript::encode($options, true, true); $script = "new Prado.WebUI.THtmlArea({$options})"; $scripts->registerEndScript('prado:THtmlArea' . $this->ClientID, $script); }
protected function renderClientControlScript($writer) { if ($this->getShowCalendar()) { $cs = $this->getPage()->getClientScript(); if (!$cs->isEndScriptRegistered('TDatePicker.spacer')) { $spacer = $this->getAssetUrl('spacer.gif'); $code = "Prado.WebUI.TDatePicker.spacer = '{$spacer}';"; $cs->registerEndScript('TDatePicker.spacer', $code); } $options = TJavaScript::encode($this->getDatePickerOptions()); $code = "new Prado.WebUI.TDatePicker({$options});"; $cs->registerEndScript("prado:" . $this->getClientID(), $code); } }
/** * Registers the editor javascript file and code to initialize the editor. */ protected function registerEditorClientScript($writer) { $this->loadJavascriptLibrary(); $scripts = $this->getPage()->getClientScript(); $options = array('EditorOptions' => $this->getEditorOptions()); $options = TJavaScript::encode($options, true, true); $script = "new {$this->getClientClassName()}({$options})"; $scripts->registerEndScript('prado:THtmlArea4' . $this->ClientID, $script); }
/** * Register the callback clientscripts and sets the post loader IDs. */ protected function renderCallbackClientScripts() { $cs = $this->getPage()->getClientScript(); $key = 'Prado.CallbackRequest.addPostLoaders'; if (!$cs->isEndScriptRegistered($key)) { $data = $this->getPage()->getPostDataLoaders(); if (count($data) > 0) { $options = TJavaScript::encode($data, false); $script = "Prado.CallbackRequest.addPostLoaders({$options});"; $cs->registerEndScript($key, $script); } } }
/** * Registers the editor javascript file and code to initialize the editor. */ protected function registerEditorClientScript($writer) { $scripts = $this->getPage()->getClientScript(); $options = TJavaScript::encode($this->getEditorOptions(), true, true); // Force encoding of empty strings $script = "if(typeof(tinyMCE)!='undefined'){ tinyMCE.init({$options}); }"; $scripts->registerEndScript('prado:THtmlArea' . $this->ClientID, $script); }
/** * @return array list of callback options. */ protected function getPostBackOptions() { //disallow page state update ? //$this->getActiveControl()->getClientSide()->setEnablePageStateUpdate(false); $options = array(); if (strlen($string = $this->getSeparator())) { $string = strtr($string, array('\\t' => "\t", '\\n' => "\n", '\\r' => "\r")); $token = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY); $options['tokens'] = TJavaScript::encode($token, false); } if ($this->getAutoPostBack()) { $options = array_merge($options, parent::getPostBackOptions()); $options['AutoPostBack'] = true; } if (strlen($select = $this->getTextCssClass())) { $options['select'] = $select; } $options['ResultPanel'] = $this->getResultPanel()->getClientID(); $options['ID'] = $this->getClientID(); $options['EventTarget'] = $this->getUniqueID(); if (($minchars = $this->getMinChars()) !== '') { $options['minChars'] = $minchars; } if (($frequency = $this->getFrequency()) !== '') { $options['frequency'] = $frequency; } $options['CausesValidation'] = $this->getCausesValidation(); $options['ValidationGroup'] = $this->getValidationGroup(); return $options; }
/** * Registers the individual validator client-side javascript code. */ protected function registerClientScriptValidator() { $key = 'prado:' . $this->getClientID(); if (!$this->getPage()->getClientScript()->isEndScriptRegistered($key)) { $options = TJavaScript::encode($this->getClientScriptOptions()); $script = 'new ' . $this->getClientClassName() . '(' . $options . ');'; $this->getPage()->getClientScript()->registerEndScript($key, $script); } }
/** * Render the javascript for validation summary. * @param array list of options for validation summary. */ protected function renderJsSummary() { if (!$this->getEnabled(true) || !$this->getEnableClientScript()) { return; } $cs = $this->getPage()->getClientScript(); $cs->registerPradoScript('validator'); //need to register the validation manager is validation summary is alone. $formID = $this->getPage()->getForm()->getClientID(); $scriptKey = "TBaseValidator:{$formID}"; if ($this->getEnableClientScript() && !$cs->isEndScriptRegistered($scriptKey)) { $manager['FormID'] = $formID; $options = TJavaScript::encode($manager); $cs->registerPradoScript('validator'); $cs->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});"); } $options = TJavaScript::encode($this->getClientScriptOptions()); $script = "new Prado.WebUI.TValidationSummary({$options});"; $cs->registerEndScript($this->getClientID(), $script); }
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 = 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', 'http://www.google.com/recaptcha/api/js/recaptcha_ajax.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>'); }
/** * Registers the relevant JavaScript. */ protected function registerClientScript() { $id = $this->getClientID(); $options = TJavaScript::encode($this->getClientOptions()); $className = $this->getClientClassName(); $page = $this->getPage(); $cs = $page->getClientScript(); $cs->registerPradoScript('tabpanel'); $code = "new {$className}({$options});"; $cs->registerEndScript("prado:{$id}", $code); $cs->registerHiddenField($id . '_1', $this->getActiveViewIndex()); $page->registerRequiresPostData($this); $page->registerRequiresPostData($id . "_1"); }
/** * Registers the editor javascript file and code to initialize the editor. */ protected function registerEditorClientScript($writer) { $scripts = $this->getPage()->getClientScript(); $options = TJavaScript::encode($this->getEditorOptions()); $script = "new CSHtmlArea({$options});"; $scripts->registerEndScript('CSHtmlArea:' . $this->getClientID(), $script); }
/** * Registers the relevant JavaScript. */ protected function registerClientScript() { $options = TJavaScript::encode($this->getClientOptions()); $className = $this->getClientClassName(); $cs = $this->getPage()->getClientScript(); $cs->registerPradoScript('keyboard'); $cs->registerEndScript('prado:' . $this->getClientID(), "new {$className}({$options});"); }
/** * @param string callback requestion options as javascript code. */ public function getJsCallbackOptions() { return TJavaScript::encode($this->getClientSideOptions()); }
/** * Publish the color picker assets. */ protected function publishColorPickerAssets() { $cs = $this->getPage()->getClientScript(); $key = "prado:" . get_class($this); $imgs['button.gif'] = $this->getAssetUrl('button.gif'); $imgs['background.png'] = $this->getAssetUrl('background.png'); $options = TJavaScript::encode($imgs); $code = "Prado.WebUI.TColorPicker.UIImages = {$options};"; $cs->registerEndScript($key, $code); $cs->registerPradoScript("colorpicker"); $url = $this->getAssetUrl($this->getColorPickerStyle() . '.css'); if (!$cs->isStyleSheetFileRegistered($url)) { $cs->registerStyleSheetFile($url, $url); } }
protected function registerClientScript() { $path = 'javascripts' . DIRECTORY_SEPARATOR; $cs = $this->getPage()->getClientScript(); //$cs->registerBeginScript('PWCInitJS','var PWCInitJS="";'); if (!$cs->isScriptFileRegistered('PWCWindow')) { $cs->registerPradoScript('effects'); $cs->registerScriptFile('PWCWindow', $this->publishAsset($path . 'window.js')); //$cs->registerScriptFile('PWCPrado',$this->publishAsset($path.'pwc-prado.js')); } $options = $this->getClientOptions(); switch ($this->getMode()) { case 'Existing': $endJS2 = "Prado.Registry.get('{$this->ClientID}').setContent('{$this->Content}',{$this->AutoResize},{$this->AutoPosition});\";"; break; case 'Url': $options['url'] = $this->getContent(); $endJS2 = '"'; break; case 'HTML': $escaped = str_replace(array('"', "\n", "\r", "\t"), array('\\"'), $this->Content); $endJS2 = "Prado.Registry.get('{$this->ClientID}').setHTMLContent('{$escaped}');\";"; break; default: $endJS2 = '"'; break; } $options = TJavaScript::encode($options); $endJS = "Windows.codes['{$this->ClientID}']=\"Prado.Registry.set('{$this->ClientID}', new Window('{$this->ClientID}',{$options}));" . $endJS2; $cs->registerEndScript('PWCCode:' . $this->getClientID(), $endJS); }