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 --- .gitattributes | 4 ++ .../pages/ActiveControls/ActiveHyperLink.page | 15 +++++ .../protected/pages/ActiveControls/Home.page | 2 +- .../Samples/TActiveHyperLink/Home.page | 70 +++++++++++++++++++++ .../Samples/TActiveHyperLink/Home.php | 26 ++++++++ .../Samples/TActiveHyperLink/hello_world.gif | Bin 0 -> 1602 bytes framework/Web/Javascripts/js/compressed/ajax.js | 3 +- framework/Web/Javascripts/js/debug/ajax.js | 3 + framework/Web/Javascripts/prado/ajax3.js | 3 + .../Web/UI/ActiveControls/TCallbackClientSide.php | 17 +++++ .../UI/ActiveControls/TTimeTriggeredCallback.php | 23 +++++++ 11 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 demos/quickstart/protected/pages/ActiveControls/ActiveHyperLink.page create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/hello_world.gif diff --git a/.gitattributes b/.gitattributes index f40827f9..f7221a5d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -769,6 +769,7 @@ demos/quickstart/protected/index/quickstart/segments -text demos/quickstart/protected/pages/ActiveControls/ActiveButton.page -text demos/quickstart/protected/pages/ActiveControls/ActiveCheckBox.page -text demos/quickstart/protected/pages/ActiveControls/ActiveCustomValidator.page -text +demos/quickstart/protected/pages/ActiveControls/ActiveHyperLink.page -text demos/quickstart/protected/pages/ActiveControls/Home.page -text demos/quickstart/protected/pages/ActiveControls/Introduction.page -text demos/quickstart/protected/pages/ActiveControls/Samples/TActiveButton/Home.page -text @@ -777,6 +778,9 @@ demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.pag demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCheckBox/Home.php -text demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page -text demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.php -text +demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page -text +demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php -text +demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/hello_world.gif -text demos/quickstart/protected/pages/ActiveControls/Samples/config.xml -text demos/quickstart/protected/pages/ActiveControls/TActiveButtonClass.png -text demos/quickstart/protected/pages/ActiveControls/TActiveButtonClass.vsd -text diff --git a/demos/quickstart/protected/pages/ActiveControls/ActiveHyperLink.page b/demos/quickstart/protected/pages/ActiveControls/ActiveHyperLink.page new file mode 100644 index 00000000..e8298ee1 --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/ActiveHyperLink.page @@ -0,0 +1,15 @@ + + +

TActiveHyperLink

+ + +

+The active control counterpart of THyperLink +component. During a callback request, changes to the Text, ImageUrl, +NavigateUrl and Target properties on the server side will also +change the corresponding attributes and content on the client-side. +

+ + + +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Home.page b/demos/quickstart/protected/pages/ActiveControls/Home.page index eabb62c9..38fee25d 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Home.page @@ -37,7 +37,7 @@ TActiveButton control.

  • - * TActiveHyperLink + TActiveHyperLink represents a hyperlink on a Web page.
  • diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page new file mode 100644 index 00000000..9a314493 --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.page @@ -0,0 +1,70 @@ + + +

    TActiveHyperLink Samples

    + + + + + + + + + + + + + + + + + + + +
    +A regular hyperlink: + +Welcome to +. + + +
    +A text hyperlink with css style: + +Welcome to +. + + +
    +An image hyperlink: + + + Text="Hello World" />. + + +
    +A hyerplink with body contents as link text: + + +Body contents + + + +
    + +
    \ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php new file mode 100644 index 00000000..c125d902 --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/Home.php @@ -0,0 +1,26 @@ +link1->NavigateUrl = 'http://www.google.com'; + } + + function button2_clicked($sender, $param) + { + $this->link2->Target = '_self'; + } + + function button3_clicked($sender, $param) + { + $this->link3->Text = 'PradoSoft.com'; + } + + function button4_clicked($sender, $param) + { + $img = $this->publishFilePath(dirname(__FILE__).'/hello_world.gif'); + $this->link4->ImageUrl = $img; + } +} +?> \ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/hello_world.gif b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/hello_world.gif new file mode 100644 index 00000000..bc81443c Binary files /dev/null and b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveHyperLink/hello_world.gif differ diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js index 32893e07..6bbb7a7c 100644 --- a/framework/Web/Javascripts/js/compressed/ajax.js +++ b/framework/Web/Javascripts/js/compressed/ajax.js @@ -94,7 +94,8 @@ Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackReque tinyMCE.triggerSave();Object.extend(this.options,{postBody:this._getPostData(),parameters:''});if(this.options.CausesValidation&&typeof(Prado.Validation)!="undefined") {var form=this.options.Form||Prado.Validation.getForm();if(Prado.Validation.validate(form,this.options.ValidationGroup,this)==false) return false;} -if(this.options.HasPriority) +if(this.options.onPreDispatch) +this.options.onPreDispatch(this,null);if(this.options.HasPriority) return Prado.CallbackRequest.dispatchPriorityRequest(this);else return Prado.CallbackRequest.dispatchNormalRequest(this);},_getPostData:function() {var data={};var callback=Prado.CallbackRequest;if(this.options.PostInputs!=false) diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js index 76c7e52a..a6c8db82 100644 --- a/framework/Web/Javascripts/js/debug/ajax.js +++ b/framework/Web/Javascripts/js/debug/ajax.js @@ -763,6 +763,9 @@ Prado.CallbackRequest.prototype = return false; } + if(this.options.onPreDispatch) + this.options.onPreDispatch(this,null); + if(this.options.HasPriority) return Prado.CallbackRequest.dispatchPriorityRequest(this); else diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js index 3b6a1d31..6e1b7d38 100644 --- a/framework/Web/Javascripts/prado/ajax3.js +++ b/framework/Web/Javascripts/prado/ajax3.js @@ -475,6 +475,9 @@ Prado.CallbackRequest.prototype = return false; } + if(this.options.onPreDispatch) + this.options.onPreDispatch(this,null); + if(this.options.HasPriority) return Prado.CallbackRequest.dispatchPriorityRequest(this); else 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