summaryrefslogtreecommitdiff
path: root/framework/Web/UI/TClientScriptManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI/TClientScriptManager.php')
-rw-r--r--framework/Web/UI/TClientScriptManager.php31
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.