From b7f95ce37ae577e95a81e64aa2aaf3e2e698109d Mon Sep 17 00:00:00 2001 From: xue <> Date: Sat, 5 Aug 2006 21:34:30 +0000 Subject: merge from 3.0 branch till 1329. --- .../protected/pages/Advanced/Themes.page | 3 ++ .../Samples/TClientSideValidator/Home.page | 41 ++++++++++++++++++++++ .../Controls/Samples/TClientSideValidator/Home.php | 23 ++++++++++++ .../protected/pages/Controls/Validation.page | 35 ++++++++++++++++++ demos/quickstart/protected/pages/Search.php | 10 +++--- 5 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php (limited to 'demos/quickstart/protected/pages') diff --git a/demos/quickstart/protected/pages/Advanced/Themes.page b/demos/quickstart/protected/pages/Advanced/Themes.page index 5ba0a121..07435928 100644 --- a/demos/quickstart/protected/pages/Advanced/Themes.page +++ b/demos/quickstart/protected/pages/Advanced/Themes.page @@ -28,6 +28,9 @@ This will apply the 'Blue' skin to the button. Note, the initial property values

To use the Javascript files and CSS files contained in a theme, a THead control must be placed on the page template. This is because the theme will register those files with the page and THead is the right place to load those files.

+

+It is possible to specify media types of CSS files contained in a theme. By default, a CSS file applies to all media types. If the CSS file is named like mystyle.print.css, it will be applied only to print media type. As another example, mystyle.screen.css applies to screen media only, and mystyle.css applies to all media types. +

Theme Storage

diff --git a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page new file mode 100644 index 00000000..e96e7c12 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page @@ -0,0 +1,41 @@ + +

Validator Toggle - Server and Client Side

+ + + +
+ +
+ + + + + + + Event.OnLoad(function() + { + Event.observe("<%= $this->check1->ClientID %>", "click", function(ev) + { + $("<%= $this->panel1->ClientID %>").toggle(); + }); + }); + + \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php new file mode 100644 index 00000000..c5440996 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php @@ -0,0 +1,23 @@ +Enabled = $this->check1->Checked; + } + + function validate2_onPostValidate($sender, $param) + { + $sender->Enabled = true; + } + + function onPreRender($param) + { + parent::onPreRender($param); + $this->panel1->Style = + $this->check1->Checked ? "display:block" : "display:none"; + } +} + +?> \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Validation.page b/demos/quickstart/protected/pages/Controls/Validation.page index 12836b8c..2241f346 100644 --- a/demos/quickstart/protected/pages/Controls/Validation.page +++ b/demos/quickstart/protected/pages/Controls/Validation.page @@ -151,4 +151,39 @@ The summary can be displayed as a list, a bulleted list, or a single paragraph b

+

Client and Server Side Conditional Validation

+

+ All validators contains the following events. +

    +
  • The OnValidate event is raise before the validator validation functions are called.
  • +
  • The OnSuccess event is raised after the validator has successfully validate the control.
  • +
  • The OnError event is raised after the validator fails validation.
  • +
+ The corresponding events for the client side is available as sub-properties + of the ClientSide property of the validator. +

+

The following example pop-up a message saying "hello" when the validator fails on the client-side. + +<com:TRequiredFieldValidator ... > + <prop:ClientSide.OnError> + alert("hello"); + </prop:ClientSide.OnError> +</com:TRequiredFieldValidator> + +The resulting client-side event callback function is of the following form. + +function onErrorHandler(validator, sender) +{ + alert("hello"); +} + +Where validator is the current client-side validator and sender +is the control that invoked the validator. +

+

Conditional Validation Example

+

+The following example show the use of client-side and server side validator events. The example +demonstrates conditional validation. + +

\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Search.php b/demos/quickstart/protected/pages/Search.php index f1d07ffa..d2dfa7da 100644 --- a/demos/quickstart/protected/pages/Search.php +++ b/demos/quickstart/protected/pages/Search.php @@ -13,11 +13,11 @@ class Search extends TPage $hits_1 = $quickstart->find($text); $this->quickstart_results->setDataSource($hits_1); $this->quickstart_results->dataBind(); - + $this->emptyResult->setVisible(!count($hits_1)); } } - + public function highlightSearch($text) { $words = str_word_count($text, 1); @@ -33,7 +33,7 @@ class Search extends TPage break; } } - + $min = $where - 15 < 0 ? 0 : $where - 15; $max = $where + 15 > $t ? $t : $where + 15; $subtext = array_splice($words, $min, $max-$min); @@ -41,13 +41,13 @@ class Search extends TPage $suffix = $max == $t ? '' : '...'; return $prefix.implode(' ', $subtext).$suffix; } - + protected function containsKeys($word, $keys) { foreach($keys as $key) { if(is_int(strpos($word, $key))) - return true; + return true; } return false; } -- cgit v1.2.3