diff options
author | wei <> | 2006-05-05 06:58:04 +0000 |
---|---|---|
committer | wei <> | 2006-05-05 06:58:04 +0000 |
commit | 47d05516b1d1c465217c59732bf8442ab0cfd497 (patch) | |
tree | c8c8fce4eb2c4ca9580b87a7c410fb7606ce1af4 /framework/Web/UI/TClientScriptManager.php | |
parent | f21d3433721308f5d0693f44bbfed56f7b2ecc2d (diff) |
Added prioritize callback and enabled viewstate update on callback return.
Diffstat (limited to 'framework/Web/UI/TClientScriptManager.php')
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 89 |
1 files changed, 82 insertions, 7 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 46203b0b..20612ce2 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -1,6 +1,6 @@ <?php /** - * TClientScriptManager class file + * TClientScriptManager and TClientSideOptions class file. * * @author Qiang Xue <qiang.xue@gmail.com> * @link http://www.pradosoft.com/ @@ -164,15 +164,12 @@ class TClientScriptManager extends TApplicationComponent } } - public function getCallbackReference($callbackHandler, $options=null) + public function getCallbackReference(ICallbackEventHandler $callbackHandler, $options=null) { $options = !is_array($options) ? array() : $options; $class = new TReflectionClass($callbackHandler); - if($class->hasMethod('getClientSide')) - { - $clientSide = $callbackHandler->getClientSide(); - $options = array_merge($options, $clientSide->getOptions()->toArray()); - } + $clientSide = $callbackHandler->getClientSide(); + $options = array_merge($options, $clientSide->getOptions()->toArray()); $optionString = TJavascript::encode($options); $this->registerPradoScriptInternal('ajax'); $id = $callbackHandler->getUniqueID(); @@ -532,4 +529,82 @@ class TClientScriptManager extends TApplicationComponent } } +/** + * TClientSideOptions abstract class. + * + * TClientSideOptions manages client-side options for components that have + * common client-side javascript behaviours and client-side events such as + * between ActiveControls and validators. + * + * @author <weizhuo[at]gmail[dot]com> + * @version $Revision: $ $Date: $ + * @package System.Web.UI + * @since 3.0 + */ +abstract class TClientSideOptions extends TComponent +{ + /** + * @var TMap list of client-side options. + */ + private $_options; + + /** + * Constructor, initialize the options list. + */ + public function __construct() + { + $this->_options = Prado::createComponent('System.Collections.TMap'); + } + + /** + * Adds on client-side event handler by wrapping the code within a + * javascript function block. If the code begins with "javascript:", the + * code is assumed to be a javascript function block rather than arbiturary + * javascript statements. + * @param string option name + * @param string javascript statements. + */ + protected function setFunction($name, $code) + { + if(!TJavascript::isFunction($code)) + $code = TJavascript::quoteFunction($this->ensureFunction($code)); + $this->setOption($name, $code); + } + + /** + * @return string gets a particular option, null if not set. + */ + protected function getOption($name) + { + return $this->_options->itemAt($name); + } + + /** + * @param string option name + * @param mixed option value. + */ + protected function setOption($name, $value) + { + $this->_options->add($name, $value); + } + + /** + * @return TMap gets the list of options as TMap + */ + public function getOptions() + { + return $this->_options; + } + + /** + * Ensure that the javascript statements are wrapped in a javascript + * function block. Default has no wrapping. Override this method to + * customize the wrapping javascript function block. + */ + protected function ensureFunction($javascript) + { + return $javascript; + } +} + ?>
\ No newline at end of file |