diff options
author | wei <> | 2006-08-26 12:27:37 +0000 |
---|---|---|
committer | wei <> | 2006-08-26 12:27:37 +0000 |
commit | 5a47e8d5c472bfbe07abb464cdcc5bbc721f8d59 (patch) | |
tree | 8e074600b4cba0ef8c5a250f00e125d8b1c3b7d4 /framework/Web/UI/TClientScriptManager.php | |
parent | f29e7b34891d2bb10da8cd1beb55a1b336484d22 (diff) |
MINOR BC BREAK (javascript related). Update javascript effect library to 1.6.2, unify javascript event handler function signatures.
Diffstat (limited to 'framework/Web/UI/TClientScriptManager.php')
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 75effa50..54bf2aa4 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -477,4 +477,81 @@ 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 as <code>function(sender, parameter){ //code }</code>. + */ + protected function ensureFunction($javascript) + { + return "function(sender, parameter){ {$javascript} }"; + } +} + ?>
\ No newline at end of file |