diff options
author | wei <> | 2006-09-02 00:29:04 +0000 |
---|---|---|
committer | wei <> | 2006-09-02 00:29:04 +0000 |
commit | 815c7462bbc4848939aa53cf375a0269d51b81fa (patch) | |
tree | 6fa4977ce42f8e28fa71fe32c1e9d07d43d01797 | |
parent | 215c1294d356e35b7717b05892a45b9f0b76a847 (diff) |
update validators
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/compressed/validator.js | 13 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/debug/validator.js | 25 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/validation3.js | 25 |
4 files changed, 32 insertions, 32 deletions
@@ -11,6 +11,7 @@ ENH: Uses uncompressed javascript in debug mode. (Wei) ENH: Cells in TDataGrid rows can now be accessed via the corresponding column IDs (Qiang) ENH: Input controls in some datagrid columns can now be accessed in a named fashion (Qiang) ENH: Prado::fatalError() now displays function parameter information (Qiang) +CHG: Validator the error message visibility before raising events OnError and OnSuccess (Wei) CHG: Unify all client-side javascript event handler syntax. (Wei) CHG: Added more conditions in the requirement checker (Qiang) CHG: TControl::findControlsByType() now only returns objects of the specified type (Qiang) diff --git a/framework/Web/Javascripts/js/compressed/validator.js b/framework/Web/Javascripts/js/compressed/validator.js index d3d8c53e..c173014c 100644 --- a/framework/Web/Javascripts/js/compressed/validator.js +++ b/framework/Web/Javascripts/js/compressed/validator.js @@ -82,13 +82,14 @@ this.messages.show();this.visible=true;},formats:function(type) {case"List":output+=messages[i]+"\n";break;case"BulletList":default:output+=" - "+messages[i]+"\n";break;case"SingleParagraph":output+=messages[i]+" ";break;}} return output;}};Prado.WebUI.TBaseValidator=Class.create();Prado.WebUI.TBaseValidator.prototype={enabled:true,visible:false,isValid:true,options:{},_isObserving:{},group:null,manager:null,message:null,initialize:function(options) {this.options=options;this.control=$(options.ControlToValidate);this.message=$(options.ID);this.group=options.ValidationGroup;this.manager=Prado.Validation.addValidator(options.FormID,this);},getErrorMessage:function() -{return this.options.ErrorMessage;},updateControl:function() -{if(this.message) +{return this.options.ErrorMessage;},updateControl:function(focus) +{this.refreshControlAndMessage();if(this.options.FocusOnError&&!this.isValid) +Prado.Element.focus(this.options.FocusElementID);},refreshControlAndMessage:function() +{this.visible=true;if(this.message) {if(this.options.Display=="Dynamic") this.isValid?this.message.hide():this.message.show();this.message.style.visibility=this.isValid?"hidden":"visible";} if(this.control) -this.updateControlCssClass(this.control,this.isValid);if(this.options.FocusOnError&&!this.isValid) -Prado.Element.focus(this.options.FocusElementID);this.visible=true;},updateControlCssClass:function(control,valid) +this.updateControlCssClass(this.control,this.isValid);},updateControlCssClass:function(control,valid) {var CssClass=this.options.ControlCssClass;if(typeof(CssClass)=="string"&&CssClass.length>0) {if(valid) control.removeClassName(CssClass);else @@ -99,12 +100,12 @@ this.options.OnValidate(this,invoker);if(this.enabled) this.isValid=this.evaluateIsValid();else this.isValid=true;if(this.isValid) {if(typeof(this.options.OnSuccess)=="function") -{this.visible=true;this.message.style.visibility="visible";this.updateControlCssClass(this.control,this.isValid);this.options.OnSuccess(this,invoker);} +{this.refreshControlAndMessage();this.options.OnSuccess(this,invoker);} else this.updateControl();} else {if(typeof(this.options.OnError)=="function") -{this.visible=true;this.message.style.visibility="visible";this.updateControlCssClass(this.control,this.isValid);this.options.OnError(this,invoker);} +{this.refreshControlAndMessage();this.options.OnError(this,invoker);} else this.updateControl();} this.observeChanges(this.control);return this.isValid;},observeChanges:function(control) diff --git a/framework/Web/Javascripts/js/debug/validator.js b/framework/Web/Javascripts/js/debug/validator.js index 7a963f82..d0293cbd 100644 --- a/framework/Web/Javascripts/js/debug/validator.js +++ b/framework/Web/Javascripts/js/debug/validator.js @@ -593,22 +593,25 @@ Prado.WebUI.TBaseValidator.prototype = * element. Updating the validator control will set the validator
* <tt>visible</tt> property to true.
*/
- updateControl: function()
+ updateControl: function(focus)
{
+ this.refreshControlAndMessage();
+
+ if(this.options.FocusOnError && !this.isValid )
+ Prado.Element.focus(this.options.FocusElementID);
+ },
+
+ refreshControlAndMessage : function()
+ {
+ this.visible = true;
if(this.message)
{
if(this.options.Display == "Dynamic")
this.isValid ? this.message.hide() : this.message.show();
this.message.style.visibility = this.isValid ? "hidden" : "visible";
}
-
if(this.control)
this.updateControlCssClass(this.control, this.isValid);
-
- if(this.options.FocusOnError && !this.isValid)
- Prado.Element.focus(this.options.FocusElementID);
-
- this.visible = true;
},
/**
@@ -659,9 +662,7 @@ Prado.WebUI.TBaseValidator.prototype = {
if(typeof(this.options.OnSuccess) == "function")
{
- this.visible = true;
- this.message.style.visibility = "visible";
- this.updateControlCssClass(this.control, this.isValid);
+ this.refreshControlAndMessage();
this.options.OnSuccess(this, invoker);
}
else
@@ -671,9 +672,7 @@ Prado.WebUI.TBaseValidator.prototype = {
if(typeof(this.options.OnError) == "function")
{
- this.visible = true;
- this.message.style.visibility = "visible";
- this.updateControlCssClass(this.control, this.isValid);
+ this.refreshControlAndMessage();
this.options.OnError(this, invoker);
}
else
diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js index 6e9dfc0a..67d490e3 100644 --- a/framework/Web/Javascripts/prado/validation3.js +++ b/framework/Web/Javascripts/prado/validation3.js @@ -593,22 +593,25 @@ Prado.WebUI.TBaseValidator.prototype = * element. Updating the validator control will set the validator
* <tt>visible</tt> property to true.
*/
- updateControl: function()
+ updateControl: function(focus)
{
+ this.refreshControlAndMessage();
+
+ if(this.options.FocusOnError && !this.isValid )
+ Prado.Element.focus(this.options.FocusElementID);
+ },
+
+ refreshControlAndMessage : function()
+ {
+ this.visible = true;
if(this.message)
{
if(this.options.Display == "Dynamic")
this.isValid ? this.message.hide() : this.message.show();
this.message.style.visibility = this.isValid ? "hidden" : "visible";
}
-
if(this.control)
this.updateControlCssClass(this.control, this.isValid);
-
- if(this.options.FocusOnError && !this.isValid)
- Prado.Element.focus(this.options.FocusElementID);
-
- this.visible = true;
},
/**
@@ -659,9 +662,7 @@ Prado.WebUI.TBaseValidator.prototype = {
if(typeof(this.options.OnSuccess) == "function")
{
- this.visible = true;
- this.message.style.visibility = "visible";
- this.updateControlCssClass(this.control, this.isValid);
+ this.refreshControlAndMessage();
this.options.OnSuccess(this, invoker);
}
else
@@ -671,9 +672,7 @@ Prado.WebUI.TBaseValidator.prototype = {
if(typeof(this.options.OnError) == "function")
{
- this.visible = true;
- this.message.style.visibility = "visible";
- this.updateControlCssClass(this.control, this.isValid);
+ this.refreshControlAndMessage();
this.options.OnError(this, invoker);
}
else
|