summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorwei <>2006-05-13 00:21:16 +0000
committerwei <>2006-05-13 00:21:16 +0000
commitddc3ea15bbfd0235fe90f3b2211bf4cc605e25d6 (patch)
treee9eafa54b795bd1514944a4492554014dee169a8 /framework
parent0b792552008e99d3104f4153f7e95f5c17fdaf5c (diff)
Adding TCallbackOptions
Diffstat (limited to 'framework')
-rw-r--r--framework/Web/Javascripts/js/ajax.js3
-rw-r--r--framework/Web/Javascripts/prado/activecontrols3.js3
-rw-r--r--framework/Web/UI/ActiveControls/TActiveButton.php32
-rw-r--r--framework/Web/UI/ActiveControls/TAutoComplete.php37
-rw-r--r--framework/Web/UI/ActiveControls/TCallback.php32
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackOptions.php34
6 files changed, 131 insertions, 10 deletions
diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js
index 48b4689a..ba4bdbaf 100644
--- a/framework/Web/Javascripts/js/ajax.js
+++ b/framework/Web/Javascripts/js/ajax.js
@@ -192,4 +192,5 @@ this.editField=this.cached_selectTag;if(this.options.loadTextURL)this.loadExtern
{new Prado.CallbackRequest(options.EventTarget,options);Event.stop(event);}});Prado.WebUI.TActiveButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TAutoComplete=Class.extend(Autocompleter.Base,{initialize:function(options)
{this.options=options;this.baseInitialize(options.ID,options.ResultPanel,options);Object.extend(this.options,{onSuccess:this.onComplete.bind(this)});},getUpdatedChoices:function()
{Prado.Callback(this.options.EventTarget,this.getToken(),null,this.options);},onComplete:function(request,boundary)
-{result=Prado.Element.extractContent(request.responseText,boundary);this.updateChoices(result);}}); \ No newline at end of file
+{result=Prado.Element.extractContent(request.responseText,boundary);if(typeof(result)=="string"&&result.length>0)
+this.updateChoices(result);}}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js
index c22af98c..475eb938 100644
--- a/framework/Web/Javascripts/prado/activecontrols3.js
+++ b/framework/Web/Javascripts/prado/activecontrols3.js
@@ -38,6 +38,7 @@ Prado.WebUI.TAutoComplete = Class.extend(Autocompleter.Base,
onComplete : function(request, boundary)
{
result = Prado.Element.extractContent(request.responseText, boundary);
- this.updateChoices(result);
+ if(typeof(result) == "string" && result.length > 0)
+ this.updateChoices(result);
}
}); \ No newline at end of file
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