From 0ccf3763474a18b72b6a166399fc1cf569b867f8 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 23 Sep 2006 00:05:08 +0000 Subject: Fixed #389 and add OnPreDispatch for TCallbackClientSide --- .../Web/UI/ActiveControls/TCallbackClientSide.php | 17 ++++++++++++++++ .../UI/ActiveControls/TTimeTriggeredCallback.php | 23 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/ActiveControls/TCallbackClientSide.php b/framework/Web/UI/ActiveControls/TCallbackClientSide.php index ac5e32c8..ff347659 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientSide.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientSide.php @@ -16,6 +16,7 @@ * The following client side events are executing in order if the callback * request and response are send and received successfuly. * + * - onPreDispatch executed before a request is dispatched. * - onUninitialized executed when callback request is uninitialized. * - onLoading executed when callback request is initiated * - onLoaded executed when callback request begins. @@ -59,6 +60,22 @@ class TCallbackClientSide extends TClientSideOptions return "function(sender, parameter){ {$javascript} }"; } + /** + * @param string javascript code to be executed before a request is dispatched. + */ + public function setOnPreDispatch($javascript) + { + $this->setFunction('onPreDispatch', $javascript); + } + + /** + * @return string javascript code to be executed before a request is dispatched. + */ + public function getOnPreDispatch() + { + return $this->getOption('onPreDispatch'); + } + /** * @return string javascript code for client-side onUninitialized event */ diff --git a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php index ea0c942c..10923d03 100644 --- a/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php +++ b/framework/Web/UI/ActiveControls/TTimeTriggeredCallback.php @@ -21,6 +21,10 @@ Prado::using('System.Web.UI.ActiveControls.TCallback'); * TTimeTriggeredCallback sends callback request every {@link setInterval Interval} seconds. * Upon each callback request, the {@link onCallback OnCallback} event is raised. * + * The timer can be started by calling {@link startTimer()} and stopped using + * {@link stopTimer()}. The timer can be automatically started when + * {@link setStartTimerOnLoad StartTimerOnLoad} is true. + * * The intervals between each request can be increased when the browser is inactive * by changing the {@link setDecayRate DecayRate} to a positive number. The * default decay rate, {@link setDecayType DecayType}, is linear and can be changed to @@ -112,6 +116,23 @@ class TTimeTriggeredCallback extends TCallback $cs->registerEndScript("{$id}:stop", $code); } + /** + * @param boolean true to start the timer when page loads. + */ + public function setStartTimerOnLoad($value) + { + $this->setViewState('StartTimerOnLoad', + TPropertyValue::ensureBoolean($value), false); + } + + /** + * @return boolean true to start the timer when page loads. + */ + public function getStartTimerOnLoad() + { + return $this->getViewState('StartTimerOnLoad', false); + } + /** * @return array list of timer options for client-side. */ @@ -134,6 +155,8 @@ class TTimeTriggeredCallback extends TCallback parent::render($writer); $this->getActiveControl()->registerCallbackClientScript( $this->getClientClassName(), $this->getTriggerOptions()); + if($this->getStartTimerOnLoad()) + $this->startTimer(); } /** -- cgit v1.2.3