From 47d05516b1d1c465217c59732bf8442ab0cfd497 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 5 May 2006 06:58:04 +0000 Subject: Added prioritize callback and enabled viewstate update on callback return. --- framework/Web/UI/WebControls/TBaseValidator.php | 73 +++++++--------------- framework/Web/UI/WebControls/TCheckBox.php | 2 +- .../Web/UI/WebControls/TValidationSummary.php | 63 ++++++------------- 3 files changed, 42 insertions(+), 96 deletions(-) (limited to 'framework/Web/UI/WebControls') diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index ea1a5836..c39db85a 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -80,9 +80,9 @@ abstract class TBaseValidator extends TLabel implements IValidator */ private $_registered=false; /** - * @var TValidatorClientScript validator client-script options. + * @var TClientSideValidatorOptions validator client-script options. */ - private $_clientScript; + private $_clientSide; /** * Constructor. @@ -154,14 +154,14 @@ abstract class TBaseValidator extends TLabel implements IValidator $options['ControlCssClass'] = $this->getControlCssClass(); $options['ControlType'] = get_class($control); - if(!is_null($this->_clientScript)) - $options = array_merge($options,$this->_clientScript->getOptions()); + if(!is_null($this->_clientSide)) + $options = array_merge($options,$this->_clientSide->getOptions()->toArray()); return $options; } /** - * Gets the TValidatorClientScript that allows modification of the client- + * Gets the TClientSideValidatorOptions that allows modification of the client- * side validator events. * * The client-side validator supports the following events. @@ -174,21 +174,21 @@ abstract class TBaseValidator extends TLabel implements IValidator * * You can attach custom javascript code to each of these events * - * @return TValidatorClientScript javascript validator event options. + * @return TClientSideValidatorOptions javascript validator event options. */ public function getClientSide() { - if(is_null($this->_clientScript)) - $this->_clientScript = $this->createClientScript(); - return $this->_clientScript; + if(is_null($this->_clientSide)) + $this->_clientSide = $this->createClientSideOptions(); + return $this->_clientSide; } /** - * @return TValidatorClientScript javascript validator event options. + * @return TClientSideValidatorOptions javascript validator event options. */ - protected function createClientScript() + protected function createClientSideOptions() { - return new TValidatorClientScript; + return new TClientSideValidatorOptions; } /** @@ -491,11 +491,11 @@ abstract class TBaseValidator extends TLabel implements IValidator } /** - * TValidatorClientScript class. + * TClientSideValidatorOptions class. * * Client-side validator events can be modified through the {@link * TBaseValidator::getClientSide ClientSide} property of a validator. The - * subproperties of ClientSide are those of the TValidatorClientScript + * subproperties of ClientSide are those of the TClientSideValidatorOptions * properties. The client-side validator supports the following events. * * The OnValidate event is raise before the validator validation @@ -513,27 +513,14 @@ abstract class TBaseValidator extends TLabel implements IValidator * @package System.Web.UI.WebControls * @since 3.0 */ -class TValidatorClientScript extends TComponent +class TClientSideValidatorOptions extends TClientSideOptions { - /** - * @var TMap client-side validator event javascript code. - */ - private $_options; - - /** - * Constructor. - */ - public function __construct() - { - $this->_options = new TMap; - } - /** * @return string javascript code for client-side OnValidate event. */ public function getOnValidate() { - return $this->_options->itemAt['OnValidate']; + return $this->getOption('OnValidate'); } /** @@ -543,7 +530,7 @@ class TValidatorClientScript extends TComponent */ public function setOnValidate($javascript) { - $this->_options->add('OnValidate', $this->ensureFunction($javascript)); + $this->setFunction('OnValidate', $javascript); } /** @@ -553,7 +540,7 @@ class TValidatorClientScript extends TComponent */ public function setOnSuccess($javascript) { - $this->_options->add('OnSuccess', $this->ensureFunction($javascript)); + $this->setFunction('OnSuccess', $javascript); } /** @@ -561,7 +548,7 @@ class TValidatorClientScript extends TComponent */ public function getOnSuccess() { - return $this->_options->itemAt('OnSuccess'); + return $this->getOption('OnSuccess'); } /** @@ -571,7 +558,7 @@ class TValidatorClientScript extends TComponent */ public function setOnError($javascript) { - $this->_options->add('OnError', $this->ensureFunction($javascript)); + $this->setFunction('OnError', $javascript); } /** @@ -579,15 +566,7 @@ class TValidatorClientScript extends TComponent */ public function getOnError() { - return $this->_options->itemAt('OnError'); - } - - /** - * @return array list of client-side event code. - */ - public function getOptions() - { - return $this->_options->toArray(); + return $this->getOption('OnError'); } /** @@ -597,15 +576,9 @@ class TValidatorClientScript extends TComponent * @param string javascript code. * @return string javascript function code. */ - private function ensureFunction($javascript) + protected function ensureFunction($javascript) { - if(TJavascript::isFunction($javascript)) - return $javascript; - else - { - $code = "function(validator, sender){ {$javascript} }"; - return TJavascript::quoteFunction($code); - } + return "function(validator, sender){ {$javascript} }"; } } diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index 681c8748..da389948 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -378,4 +378,4 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl } -?> +?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php index 87821292..8148036b 100644 --- a/framework/Web/UI/WebControls/TValidationSummary.php +++ b/framework/Web/UI/WebControls/TValidationSummary.php @@ -37,9 +37,9 @@ class TValidationSummary extends TWebControl { /** - * @var TValidatorClientScript validator client-script options. + * @var TClientSideValidationSummaryOptions validation client side options. */ - private $_clientScript; + private $_clientSide; /** * Constructor. @@ -248,30 +248,30 @@ class TValidationSummary extends TWebControl $options['ValidationGroup'] = $this->getValidationGroup(); $options['Display'] = $this->getDisplay(); - if(!is_null($this->_clientScript)) - $options = array_merge($options,$this->_clientScript->getOptions()); + if(!is_null($this->_clientSide)) + $options = array_merge($options,$this->_clientSide->getOptions()->toArray()); return $options; } /** - * @return TValidationSummaryClientScript client-side validation summary + * @return TClientSideValidationSummaryOptions client-side validation summary * event options. */ public function getClientSide() { - if(is_null($this->_clientScript)) - $this->_clientScript = $this->createClientScript(); - return $this->_clientScript; + if(is_null($this->_clientSide)) + $this->_clientSide = $this->createClientScript(); + return $this->_clientSide; } /** - * @return TValidationSummaryClientScript javascript validation summary + * @return TClientSideValidationSummaryOptions javascript validation summary * event options. */ protected function createClientScript() { - return new TValidationSummaryClientScript; + return new TClientSideValidationSummaryOptions; } /** * Get the list of validation error messages. @@ -372,7 +372,7 @@ class TValidationSummary extends TWebControl } /** - * TValidationSummaryClientScript class. + * TClientSideValidationSummaryOptions class. * * Client-side validation summary events such as {@link setOnHideSummary * OnHideSummary} and {@link setOnShowSummary OnShowSummary} can be modified @@ -392,27 +392,14 @@ class TValidationSummary extends TWebControl * @package System.Web.UI.WebControls * @since 3.0 */ -class TValidationSummaryClientScript extends TComponent +class TClientSideValidationSummaryOptions extends TClientSideOptions { - /** - * @var TMap client-side validation summary event javascript code. - */ - private $_options; - - /** - * Constructor. - */ - public function __construct() - { - $this->_options = new TMap; - } - /** * @return string javascript code for client-side OnHideSummary event. */ public function getOnHideSummary() { - return $this->_options->itemAt['OnHideSummary']; + return $this->getOption('OnHideSummary'); } /** @@ -423,7 +410,7 @@ class TValidationSummaryClientScript extends TComponent */ public function setOnHideSummary($javascript) { - $this->_options->add('OnHideSummary', $this->ensureFunction($javascript)); + $this->setFunction('OnHideSummary', $javascript); } /** @@ -434,7 +421,7 @@ class TValidationSummaryClientScript extends TComponent */ public function setOnShowSummary($javascript) { - $this->_options->add('OnShowSummary', $this->ensureFunction($javascript)); + $this->setFunction('OnShowSummary', $javascript); } /** @@ -442,15 +429,7 @@ class TValidationSummaryClientScript extends TComponent */ public function getOnShowSummary() { - return $this->_options->itemAt('OnShowSummary'); - } - - /** - * @return array list of client-side event code. - */ - public function getOptions() - { - return $this->_options->toArray(); + return $this->getOption('OnShowSummary'); } /** @@ -460,15 +439,9 @@ class TValidationSummaryClientScript extends TComponent * @param string javascript code. * @return string javascript function code. */ - private function ensureFunction($javascript) + protected function ensureFunction($javascript) { - if(TJavascript::isFunction($javascript)) - return $javascript; - else - { - $code = "function(summary, validators){ {$javascript} }"; - return TJavascript::quoteFunction($code); - } + return "function(summary, validators){ {$javascript} }"; } } -- cgit v1.2.3