diff options
author | wei <> | 2006-01-21 02:07:59 +0000 |
---|---|---|
committer | wei <> | 2006-01-21 02:07:59 +0000 |
commit | 407aa2ff5d56859fcd1f47b85b4c4180d035c428 (patch) | |
tree | 7c4442ad2652f3021a969391fd8a468ca9400100 /framework/Web/UI/TClientScriptManager.php | |
parent | f74267f8927d39b5cb3dc43203060488371127c9 (diff) |
Fixed DefaultButton and TLinkButton
Diffstat (limited to 'framework/Web/UI/TClientScriptManager.php')
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 535e85b2..be6611cd 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -1,6 +1,6 @@ <?php -class TPostBackOptions extends TComponent +/*class TPostBackOptions extends TComponent { public $_actionUrl=''; public $_autoPostBack=false; @@ -69,7 +69,7 @@ class TPostBackOptions extends TComponent $this->_trackFocus=$value; } } - +*/ Prado::using('System.Web.Javascripts.*'); class TClientScriptManager extends TComponent @@ -133,6 +133,33 @@ class TClientScriptManager extends TComponent return $options->toJavascript(); } + /** + * Register a default button to panel. When the $panel is in focus and + * the 'enter' key is pressed, the $button will be clicked. + * @param TControl panel to register the default button action + * @param TControl button to trigger a postback + */ + public function registerDefaultButton($panel, $button) + { + $serializer = new TJavascriptSerializer( + $this->getDefaultButtonOptions($panel, $button)); + $options = $serializer->toJavascript(); + $code = "new Prado.WebUI.DefaultButton($options);"; + $scripts = $this->_page->getClientScript(); + $scripts->registerEndScript("prado:".$panel->getClientID(), $code); + } + + /** + * @return array default button options. + */ + protected function getDefaultButtonOptions($panel, $button) + { + $options['Panel'] = $panel->getClientID(); + $options['Target'] = $button->getClientID(); + $options['Event'] = 'click'; + return $options; + } + /** * Register client scripts. |