From ddc3ea15bbfd0235fe90f3b2211bf4cc605e25d6 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 13 May 2006 00:21:16 +0000 Subject: Adding TCallbackOptions --- framework/Web/UI/ActiveControls/TAutoComplete.php | 37 +++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'framework/Web/UI/ActiveControls/TAutoComplete.php') diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php index 2ebba495..025a7977 100644 --- a/framework/Web/UI/ActiveControls/TAutoComplete.php +++ b/framework/Web/UI/ActiveControls/TAutoComplete.php @@ -59,11 +59,42 @@ class TAutoComplete extends TActiveTextBox implements ICallbackEventHandler, INa */ protected function createClientSideOptions() { + if(($id=$this->getCallbackOptions())!=='' && ($control=$this->findControl($id))!==null) + { + if($control instanceof TCallbackOptions) + { + $options = clone($control->getClientSide()); + $options->setEnablePageStateUpdate(false); + return $options; + } + } $options = new TAutoCompleteClientSideOptions; $options->setEnablePageStateUpdate(false); return $options; } + /** + * Sets the ID of a TCallbackOptions component to duplicate the client-side + * options for this control. The {@link getClientSide ClientSide} + * subproperties has precendent over the CallbackOptions property. + * @param string ID of a TCallbackOptions control from which ClientSide + * options are cloned. + */ + public function setCallbackOptions($value) + { + $this->setViewState('CallbackOptions', $value,''); + } + + /** + * @return string ID of a TCallbackOptions control from which ClientSide + * options are cloned. + */ + public function getCallbackOptions() + { + return $this->getViewState('CallbackOptions',''); + } + + public function renderEndTag($writer) { $this->getPage()->getClientScript()->registerPradoScript('effects'); @@ -91,9 +122,11 @@ class TAutoComplete extends TActiveTextBox implements ICallbackEventHandler, INa /** * @return array list of callback options. */ - protected function getCallbackOptions() + protected function getCallbackClientSideOptions() { $options = $this->getClientSide()->getOptions()->toArray(); + if(isset($options['tokens'])) + $options['tokens'] = TJavascript::encode($options['tokens'],false); if($this->getAutoPostBack()) $options = array_merge($options,$this->getPostBackOptions()); $options['ResultPanel'] = $this->getResultPanel()->getClientID(); @@ -132,7 +165,7 @@ class TAutoCompleteClientSideOptions extends TCallbackClientSideOptions public function setSeparator($value) { - $this->setOption('tokens', $chars = preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY)); + $this->setOption('tokens', preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY)); } public function getFrequency() -- cgit v1.2.3