diff options
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveButton.php | 32 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TAutoComplete.php | 37 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TCallback.php | 32 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TCallbackOptions.php | 34 |
4 files changed, 127 insertions, 8 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveButton.php b/framework/Web/UI/ActiveControls/TActiveButton.php index db4fa85d..da5ec5ad 100644 --- a/framework/Web/UI/ActiveControls/TActiveButton.php +++ b/framework/Web/UI/ActiveControls/TActiveButton.php @@ -101,7 +101,33 @@ class TActiveButton extends TButton implements ICallbackEventHandler */
protected function createClientSideOptions()
{
- return new TCallbackClientSideOptions;
+ if(($id=$this->getCallbackOptions())!=='' && ($control=$this->findControl($id))!==null)
+ {
+ if($control instanceof TCallbackOptions)
+ return clone($control->getClientSide());
+ }
+ return new TCallbackClientSideOptions;
+ }
+
+ /**
+ * 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','');
}
/**
@@ -117,7 +143,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler /**
* @return array list of callback options.
*/
- protected function getCallbackOptions()
+ protected function getCallbackClientSideOptions()
{
return array_merge($this->getPostBackOptions(),
$this->getClientSide()->getOptions()->toArray());
@@ -134,7 +160,7 @@ class TActiveButton extends TButton implements ICallbackEventHandler {
$client = $this->getPage()->getClientScript();
$object = is_null($control) ? $this : $control;
- return $client->getCallbackReference($object, $this->getPostBackOptions());
+ return $client->getCallbackReference($object, $this->getCallbackClientSideOptions());
}
}
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()
diff --git a/framework/Web/UI/ActiveControls/TCallback.php b/framework/Web/UI/ActiveControls/TCallback.php index f42b3143..7bb4ee21 100644 --- a/framework/Web/UI/ActiveControls/TCallback.php +++ b/framework/Web/UI/ActiveControls/TCallback.php @@ -97,10 +97,36 @@ class TCallback extends TControl implements ICallbackEventHandler */
protected function createClientSideOptions()
{
- return new TCallbackClientSideOptions;
+ if(($id=$this->getCallbackOptions())!=='' && ($control=$this->findControl($id))!==null)
+ {
+ if($control instanceof TCallbackOptions)
+ return clone($control->getClientSide());
+ }
+ return new TCallbackClientSideOptions;
+ }
+
+ /**
+ * 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','');
+ }
+
+ /**
* @return boolean whether to perform validation if the callback is
* requested.
*/
@@ -146,7 +172,7 @@ class TCallback extends TControl implements ICallbackEventHandler /**
* @return array list of callback javascript options.
*/
- protected function getCallbackOptions()
+ protected function getCallbackClientSideOptions()
{
$validate = $this->getCausesValidation();
$options['CausesValidation']= $validate ? '' : false;
@@ -165,7 +191,7 @@ class TCallback extends TControl implements ICallbackEventHandler {
$client = $this->getPage()->getClientScript();
$object = is_null($control) ? $this : $control;
- return $client->getCallbackReference($object, $this->getCallbackOptions());
+ return $client->getCallbackReference($object, $this->getCallbackClientSideOptions());
}
}
diff --git a/framework/Web/UI/ActiveControls/TCallbackOptions.php b/framework/Web/UI/ActiveControls/TCallbackOptions.php new file mode 100644 index 00000000..e9c48c43 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TCallbackOptions.php @@ -0,0 +1,34 @@ +<?php
+/*
+ * Created on 12/05/2006
+ */
+
+class TCallbackOptions extends TControl
+{
+ private $_clientSide;
+
+ /**
+ * Callback client-side options can be set by setting the properties of
+ * the ClientSide property. E.g. <com:TCallback ClientSide.OnSuccess="..." />
+ * See {@link TCallbackClientSideOptions} for details on the properties of
+ * ClientSide.
+ * @return TCallbackClientSideOptions client-side callback options.
+ */
+ public function getClientSide()
+ {
+ if(is_null($this->_clientSide))
+ $this->_clientSide = $this->createClientSideOptions();
+ return $this->_clientSide;
+ }
+
+ /**
+ * @return TCallbackClientSideOptions callback client-side options.
+ */
+ protected function createClientSideOptions()
+ {
+ return new TCallbackClientSideOptions;
+ }
+
+}
+
+?>
\ No newline at end of file |