From 815c7462bbc4848939aa53cf375a0269d51b81fa Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 2 Sep 2006 00:29:04 +0000 Subject: update validators --- HISTORY | 1 + .../Web/Javascripts/js/compressed/validator.js | 13 +++++------ framework/Web/Javascripts/js/debug/validator.js | 25 +++++++++++----------- framework/Web/Javascripts/prado/validation3.js | 25 +++++++++++----------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/HISTORY b/HISTORY index f5fec0aa..e200ad70 100644 --- a/HISTORY +++ b/HISTORY @@ -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 * visible 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 * visible 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 -- cgit v1.2.3