a:68:{s:9:"#provides";s:28:"dijit.form.ValidationTextBox";s:9:"#resource";s:25:"form/ValidationTextBox.js";s:9:"#requires";a:3:{i:0;a:3:{i:0;s:6:"common";i:1;s:9:"dojo.i18n";i:2;s:4:"dojo";}i:1;a:2:{i:0;s:6:"common";i:1;s:18:"dijit.form.TextBox";}i:2;a:2:{i:0;s:6:"common";i:1;s:13:"dijit.Tooltip";}}s:28:"dijit.form.ValidationTextBox";a:5:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:18:"dijit.form.TextBox";}s:4:"call";a:1:{i:0;s:18:"dijit.form.TextBox";}}s:7:"summary";s:127:"Base class for textbox widgets with the ability to validate content of various types and provide user feedback.
tags:
protected";s:6:"source";s:25:" this.constraints = {};";s:9:"classlike";b:1;}s:41:"dijit.form.ValidationTextBox.templatePath";a:2:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:7:"summary";s:0:"";}s:38:"dijit.form.ValidationTextBox.baseClass";a:2:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:7:"summary";s:0:"";}s:37:"dijit.form.ValidationTextBox.required";a:4:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:7:"Boolean";s:7:"summary";s:47:"User is required to enter data into this field.";}s:42:"dijit.form.ValidationTextBox.promptMessage";a:3:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:6:"String";s:7:"summary";s:255:"If defined, display this hint string immediately on focus to the textbox, if empty.
Think of this like a tooltip that tells the user what to do, not an error message
that tells the user what they've done wrong.
Message disappears when user starts typing.";}s:43:"dijit.form.ValidationTextBox.invalidMessage";a:4:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:6:"String";s:7:"summary";s:43:"The message to display if value is invalid.";}s:40:"dijit.form.ValidationTextBox.constraints";a:4:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:6:"Object";s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:7:"summary";s:0:"";}s:35:"dijit.form.ValidationTextBox.regExp";a:5:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:4:"tags";a:2:{i:0;s:9:"extension";i:1;s:9:"protected";}s:4:"type";s:6:"String";s:7:"summary";s:93:"regular expression string used to validate the input
Do not specify both regExp and regExpGen";}s:38:"dijit.form.ValidationTextBox.regExpGen";a:7:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:11:"constraints";a:1:{s:4:"type";s:42:"dijit.form.ValidationTextBox.__Constraints";}}s:6:"source";s:36:" return this.regExp; // String";s:7:"summary";s:117:"Overridable function used to generate regExp when dependent on constraints.
Do not specify both regExp and regExpGen.";s:4:"tags";s:19:"extension protected";s:7:"returns";s:6:"String";}s:34:"dijit.form.ValidationTextBox.state";a:5:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:4:"tags";a:1:{i:0;s:8:"readonly";}s:4:"type";s:6:"String";s:7:"summary";s:80:"Shows current state (ie, validation result) of input (Normal, Warning, or Error)";}s:44:"dijit.form.ValidationTextBox.tooltipPosition";a:3:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:7:"String[";s:7:"summary";s:81:"See description of `dijit.Tooltip.defaultPosition` for details on this parameter.";}s:42:"dijit.form.ValidationTextBox._setValueAttr";a:5:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:6:"source";s:62:" this.inherited(arguments);
this.validate(this._focused);";s:7:"summary";s:33:"Hook so attr('value', ...) works.";s:7:"private";b:1;}s:38:"dijit.form.ValidationTextBox.validator";a:6:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:5:"value";a:1:{s:4:"type";s:8:"anything";}s:11:"constraints";a:1:{s:4:"type";s:42:"dijit.form.ValidationTextBox.__Constraints";}}s:6:"source";s:244:" return (new RegExp("^(?:" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) &&
(!this.required || !this._isEmpty(value)) &&
(this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean";s:7:"summary";s:84:"Overridable function used to validate the text input against the regular expression.";s:4:"tags";s:9:"protected";}s:43:"dijit.form.ValidationTextBox._isValidSubset";a:5:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:6:"source";s:58:" return this.textbox.value.search(this._partialre) == 0;";s:7:"summary";s:163:"Returns true if the value is either already valid or could be made valid by appending characters.
This is used for validation while the user [may be] still typing.";s:7:"private";b:1;}s:36:"dijit.form.ValidationTextBox.isValid";a:6:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"isFocused";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:63:" return this.validator(this.textbox.value, this.constraints);";s:7:"summary";s:74:"Tests if value is valid.
Can override with your own routine in a subclass.";s:4:"tags";s:9:"protected";}s:37:"dijit.form.ValidationTextBox._isEmpty";a:7:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:5:"value";a:1:{s:4:"type";s:0:"";}}s:6:"source";s:41:" return /^\s*$/.test(value); // Boolean";s:7:"summary";s:21:"Checks for whitespace";s:7:"returns";s:7:"Boolean";s:7:"private";b:1;}s:44:"dijit.form.ValidationTextBox.getErrorMessage";a:7:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"isFocused";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:40:" return this.invalidMessage; // String";s:7:"summary";s:46:"Return an error message to show if appropriate";s:4:"tags";s:9:"protected";s:7:"returns";s:6:"String";}s:45:"dijit.form.ValidationTextBox.getPromptMessage";a:7:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"isFocused";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:39:" return this.promptMessage; // String";s:7:"summary";s:58:"Return a hint message to show when widget is first focused";s:4:"tags";s:9:"protected";s:7:"returns";s:6:"String";}s:50:"dijit.form.ValidationTextBox._maskValidSubsetError";a:4:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:7:"private";b:1;s:7:"summary";s:0:"";}s:37:"dijit.form.ValidationTextBox.validate";a:7:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"isFocused";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:809:" var message = "";
var isValid = this.disabled || this.isValid(isFocused);
if(isValid){ this._maskValidSubsetError = true; }
var isValidSubset = !isValid && isFocused && this._isValidSubset();
var isEmpty = this._isEmpty(this.textbox.value);
this.state = (isValid || (!this._hasBeenBlurred && isEmpty) || isValidSubset) ? "" : "Error";
if(this.state == "Error"){ this._maskValidSubsetError = false; }
this._setStateClass();
dijit.setWaiState(this.focusNode, "invalid", isValid ? "false" : "true");
if(isFocused){
if(isEmpty){
message = this.getPromptMessage(true);
}
if(!message && (this.state == "Error" || (isValidSubset && !this._maskValidSubsetError))){
message = this.getErrorMessage(true);
}
}
this.displayMessage(message);
return isValid;";s:7:"summary";s:41:"Called by oninit, onblur, and onkeypress.";s:11:"description";s:77:"Show missing or invalid messages if appropriate, and highlight textbox field.";s:4:"tags";s:9:"protected";}s:37:"dijit.form.ValidationTextBox._message";a:5:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:6:"String";s:7:"summary";s:27:"Currently displayed message";s:7:"private";b:1;}s:43:"dijit.form.ValidationTextBox.displayMessage";a:6:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:7:"message";a:1:{s:4:"type";s:6:"String";}}s:6:"source";s:195:" if(this._message == message){ return; }
this._message = message;
dijit.hideTooltip(this.domNode);
if(message){
dijit.showTooltip(message, this.domNode, this.tooltipPosition);
}";s:7:"summary";s:81:"Overridable method to display validation errors/hints.
By default uses a tooltip.";s:4:"tags";s:9:"extension";}s:42:"dijit.form.ValidationTextBox._refreshState";a:6:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:6:"source";s:5746:"dojo.provide("dijit.form.ValidationTextBox");
dojo.require("dojo.i18n");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.Tooltip");
dojo.requireLocalization("dijit.form", "validate");
dijit.form.ValidationTextBox.__Constraints = function(){
// locale: String
// locale used for validation, picks up value from this widget's lang attribute
// _flags_: anything
// various flags passed to regExpGen function
this.locale = "";
this._flags_ = "";
}
dojo.declare(
"dijit.form.ValidationTextBox",
dijit.form.TextBox,
{
// summary:
// Base class for textbox widgets with the ability to validate content of various types and provide user feedback.
// tags:
// protected
templatePath: dojo.moduleUrl("dijit.form", "templates/ValidationTextBox.html"),
baseClass: "dijitTextBox",
// required: Boolean
// User is required to enter data into this field.
required: false,
// promptMessage: String
// If defined, display this hint string immediately on focus to the textbox, if empty.
// Think of this like a tooltip that tells the user what to do, not an error message
// that tells the user what they've done wrong.
//
// Message disappears when user starts typing.
promptMessage: "",
// invalidMessage: String
// The message to display if value is invalid.
invalidMessage: "$_unset_$", // read from the message file if not overridden
// constraints: dijit.form.ValidationTextBox.__Constraints
// user-defined object needed to pass parameters to the validator functions
constraints: {},
// regExp: [extension protected] String
// regular expression string used to validate the input
// Do not specify both regExp and regExpGen
regExp: ".*",
regExpGen: function(/*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to generate regExp when dependent on constraints.
// Do not specify both regExp and regExpGen.
// tags:
// extension protected
return this.regExp; // String
},
// state: [readonly] String
// Shows current state (ie, validation result) of input (Normal, Warning, or Error)
state: "",
// tooltipPosition: String[]
// See description of `dijit.Tooltip.defaultPosition` for details on this parameter.
tooltipPosition: [],
_setValueAttr: function(){
// summary:
// Hook so attr('value', ...) works.
this.inherited(arguments);
this.validate(this._focused);
},
validator: function(/*anything*/value, /*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to validate the text input against the regular expression.
// tags:
// protected
return (new RegExp("^(?:" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) &&
(!this.required || !this._isEmpty(value)) &&
(this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean
},
_isValidSubset: function(){
// summary:
// Returns true if the value is either already valid or could be made valid by appending characters.
// This is used for validation while the user [may be] still typing.
return this.textbox.value.search(this._partialre) == 0;
},
isValid: function(/*Boolean*/ isFocused){
// summary:
// Tests if value is valid.
// Can override with your own routine in a subclass.
// tags:
// protected
return this.validator(this.textbox.value, this.constraints);
},
_isEmpty: function(value){
// summary:
// Checks for whitespace
return /^\s*$/.test(value); // Boolean
},
getErrorMessage: function(/*Boolean*/ isFocused){
// summary:
// Return an error message to show if appropriate
// tags:
// protected
return this.invalidMessage; // String
},
getPromptMessage: function(/*Boolean*/ isFocused){
// summary:
// Return a hint message to show when widget is first focused
// tags:
// protected
return this.promptMessage; // String
},
_maskValidSubsetError: true,
validate: function(/*Boolean*/ isFocused){
// summary:
// Called by oninit, onblur, and onkeypress.
// description:
// Show missing or invalid messages if appropriate, and highlight textbox field.
// tags:
// protected
var message = "";
var isValid = this.disabled || this.isValid(isFocused);
if(isValid){ this._maskValidSubsetError = true; }
var isValidSubset = !isValid && isFocused && this._isValidSubset();
var isEmpty = this._isEmpty(this.textbox.value);
this.state = (isValid || (!this._hasBeenBlurred && isEmpty) || isValidSubset) ? "" : "Error";
if(this.state == "Error"){ this._maskValidSubsetError = false; }
this._setStateClass();
dijit.setWaiState(this.focusNode, "invalid", isValid ? "false" : "true");
if(isFocused){
if(isEmpty){
message = this.getPromptMessage(true);
}
if(!message && (this.state == "Error" || (isValidSubset && !this._maskValidSubsetError))){
message = this.getErrorMessage(true);
}
}
this.displayMessage(message);
return isValid;
},
// _message: String
// Currently displayed message
_message: "",
displayMessage: function(/*String*/ message){
// summary:
// Overridable method to display validation errors/hints.
// By default uses a tooltip.
// tags:
// extension
if(this._message == message){ return; }
this._message = message;
dijit.hideTooltip(this.domNode);
if(message){
dijit.showTooltip(message, this.domNode, this.tooltipPosition);
}
},
_refreshState: function(){
// Overrides TextBox._refreshState()
this.validate(this._focused);
this.inherited(arguments);";s:7:"returns";s:14:"String|Boolean";s:7:"private";b:1;s:7:"summary";s:0:"";}s:48:"dijit.form.ValidationTextBox.postMixInProperties";a:4:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:6:"source";s:1352:" this.inherited(arguments);
this.constraints.locale = this.lang;
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang);
if(this.invalidMessage == "$_unset_$"){ this.invalidMessage = this.messages.invalidMessage; }
var p = this.regExpGen(this.constraints);
this.regExp = p;
var partialre = "";
// parse the regexp and produce a new regexp that matches valid subsets
// if the regexp is .* then there's no use in matching subsets since everything is valid
if(p != ".*"){ this.regExp.replace(/\\.|\[\]|\[.*?[^\\]{1}\]|\{.*?\}|\(\?[=:!]|./g,
function (re){
switch(re.charAt(0)){
case '{':
case '+':
case '?':
case '*':
case '^':
case '$':
case '|':
case '(': partialre += re; break;
case ")": partialre += "|$)"; break;
default: partialre += "(?:"+re+"|$)"; break;
}
}
);}
try{ // this is needed for now since the above regexp parsing needs more test verification
"".search(partialre);
}catch(e){ // should never be here unless the original RE is bad or the parsing is bad
partialre = this.regExp;
console.warn('RegExp error in ' + this.declaredClass + ': ' + this.regExp);
} // should never be here unless the original RE is bad or the parsing is bad
this._partialre = "^(?:" + partialre + ")$";";s:7:"summary";s:0:"";}s:45:"dijit.form.ValidationTextBox._setDisabledAttr";a:6:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:5:"value";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:162:" this.inherited(arguments); // call FormValueWidget._setDisabledAttr()
if(this.valueNode){
this.valueNode.disabled = value;
}
this._refreshState();";s:7:"private";b:1;s:7:"summary";s:0:"";}s:45:"dijit.form.ValidationTextBox._setRequiredAttr";a:6:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:5:"value";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:110:" this.required = value;
dijit.setWaiState(this.focusNode,"required", value);
this._refreshState(); ";s:7:"private";b:1;s:7:"summary";s:0:"";}s:39:"dijit.form.ValidationTextBox.postCreate";a:4:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:4:"type";s:8:"Function";s:6:"source";s:274:" if(dojo.isIE){ // IE INPUT tag fontFamily has to be set directly using STYLE
var s = dojo.getComputedStyle(this.focusNode);
if(s){
var ff = s.fontFamily;
if(ff){
this.focusNode.style.fontFamily = ff;
}
}
}
this.inherited(arguments);";s:7:"summary";s:0:"";}s:34:"dijit.form.ValidationTextBox.reset";a:2:{s:9:"prototype";s:28:"dijit.form.ValidationTextBox";s:7:"summary";s:0:"";}s:47:"dijit.form.ValidationTextBox.constraints.locale";a:2:{s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:7:"summary";s:0:"";}s:37:"dijit.form.ValidationTextBox.messages";a:2:{s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:7:"summary";s:0:"";}s:39:"dijit.form.ValidationTextBox._partialre";a:3:{s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:7:"private";b:1;s:7:"summary";s:0:"";}s:47:"dijit.form.ValidationTextBox.valueNode.disabled";a:2:{s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:7:"summary";s:0:"";}s:55:"dijit.form.ValidationTextBox.focusNode.style.fontFamily";a:2:{s:8:"instance";s:28:"dijit.form.ValidationTextBox";s:7:"summary";s:0:"";}s:24:"dijit.form.MappedTextBox";a:5:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:28:"dijit.form.ValidationTextBox";}s:4:"call";a:1:{i:0;s:28:"dijit.form.ValidationTextBox";}}s:7:"summary";s:211:"A dijit.form.ValidationTextBox subclass which provides a base class for widgets that have
a visible formatted display value, and a serializable
value in a hidden input field which is actually sent to the server.";s:11:"description";s:329:"The visible display may
be locale-dependent and interactive. The value sent to the server is stored in a hidden
input field which uses the `name` attribute declared by the original widget. That value sent
to the server is defined by the dijit.form.MappedTextBox.serialize method and is typically
locale-neutral.
tags:
protected";s:9:"classlike";b:1;}s:44:"dijit.form.MappedTextBox.postMixInProperties";a:4:{s:9:"prototype";s:24:"dijit.form.MappedTextBox";s:4:"type";s:8:"Function";s:6:"source";s:232:" this.inherited(arguments);
// we want the name attribute to go to the hidden , not the displayed ,
// so override _FormWidget.postMixInProperties() setting of nameAttrSetting
this.nameAttrSetting = "";";s:7:"summary";s:0:"";}s:34:"dijit.form.MappedTextBox.serialize";a:7:{s:9:"prototype";s:24:"dijit.form.MappedTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:3:"val";a:1:{s:4:"type";s:8:"anything";}s:7:"options";a:2:{s:8:"optional";b:1;s:4:"type";s:6:"Object";}}s:6:"source";s:55:" return val.toString ? val.toString() : ""; // String";s:7:"summary";s:210:"Overridable function used to convert the attr('value') result to a canonical
(non-localized) string. For example, will print dates in ISO format, and
numbers the same way as they are represented in javascript.";s:4:"tags";s:19:"protected extension";s:7:"returns";s:6:"String";}s:33:"dijit.form.MappedTextBox.toString";a:6:{s:9:"prototype";s:24:"dijit.form.MappedTextBox";s:4:"type";s:8:"Function";s:6:"source";s:229:" var val = this.filter(this.attr('value')); // call filter in case value is nonstring and filter has been customized
return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String";s:7:"summary";s:61:"Returns widget as a printable string using the widget's value";s:4:"tags";s:9:"protected";s:7:"returns";s:6:"String";}s:33:"dijit.form.MappedTextBox.validate";a:5:{s:9:"prototype";s:24:"dijit.form.MappedTextBox";s:4:"type";s:8:"Function";s:6:"source";s:10097:"dojo.provide("dijit.form.ValidationTextBox");
dojo.require("dojo.i18n");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.Tooltip");
dojo.requireLocalization("dijit.form", "validate");
dijit.form.ValidationTextBox.__Constraints = function(){
// locale: String
// locale used for validation, picks up value from this widget's lang attribute
// _flags_: anything
// various flags passed to regExpGen function
this.locale = "";
this._flags_ = "";
}
dojo.declare(
"dijit.form.ValidationTextBox",
dijit.form.TextBox,
{
// summary:
// Base class for textbox widgets with the ability to validate content of various types and provide user feedback.
// tags:
// protected
templatePath: dojo.moduleUrl("dijit.form", "templates/ValidationTextBox.html"),
baseClass: "dijitTextBox",
// required: Boolean
// User is required to enter data into this field.
required: false,
// promptMessage: String
// If defined, display this hint string immediately on focus to the textbox, if empty.
// Think of this like a tooltip that tells the user what to do, not an error message
// that tells the user what they've done wrong.
//
// Message disappears when user starts typing.
promptMessage: "",
// invalidMessage: String
// The message to display if value is invalid.
invalidMessage: "$_unset_$", // read from the message file if not overridden
// constraints: dijit.form.ValidationTextBox.__Constraints
// user-defined object needed to pass parameters to the validator functions
constraints: {},
// regExp: [extension protected] String
// regular expression string used to validate the input
// Do not specify both regExp and regExpGen
regExp: ".*",
regExpGen: function(/*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to generate regExp when dependent on constraints.
// Do not specify both regExp and regExpGen.
// tags:
// extension protected
return this.regExp; // String
},
// state: [readonly] String
// Shows current state (ie, validation result) of input (Normal, Warning, or Error)
state: "",
// tooltipPosition: String[]
// See description of `dijit.Tooltip.defaultPosition` for details on this parameter.
tooltipPosition: [],
_setValueAttr: function(){
// summary:
// Hook so attr('value', ...) works.
this.inherited(arguments);
this.validate(this._focused);
},
validator: function(/*anything*/value, /*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to validate the text input against the regular expression.
// tags:
// protected
return (new RegExp("^(?:" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) &&
(!this.required || !this._isEmpty(value)) &&
(this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean
},
_isValidSubset: function(){
// summary:
// Returns true if the value is either already valid or could be made valid by appending characters.
// This is used for validation while the user [may be] still typing.
return this.textbox.value.search(this._partialre) == 0;
},
isValid: function(/*Boolean*/ isFocused){
// summary:
// Tests if value is valid.
// Can override with your own routine in a subclass.
// tags:
// protected
return this.validator(this.textbox.value, this.constraints);
},
_isEmpty: function(value){
// summary:
// Checks for whitespace
return /^\s*$/.test(value); // Boolean
},
getErrorMessage: function(/*Boolean*/ isFocused){
// summary:
// Return an error message to show if appropriate
// tags:
// protected
return this.invalidMessage; // String
},
getPromptMessage: function(/*Boolean*/ isFocused){
// summary:
// Return a hint message to show when widget is first focused
// tags:
// protected
return this.promptMessage; // String
},
_maskValidSubsetError: true,
validate: function(/*Boolean*/ isFocused){
// summary:
// Called by oninit, onblur, and onkeypress.
// description:
// Show missing or invalid messages if appropriate, and highlight textbox field.
// tags:
// protected
var message = "";
var isValid = this.disabled || this.isValid(isFocused);
if(isValid){ this._maskValidSubsetError = true; }
var isValidSubset = !isValid && isFocused && this._isValidSubset();
var isEmpty = this._isEmpty(this.textbox.value);
this.state = (isValid || (!this._hasBeenBlurred && isEmpty) || isValidSubset) ? "" : "Error";
if(this.state == "Error"){ this._maskValidSubsetError = false; }
this._setStateClass();
dijit.setWaiState(this.focusNode, "invalid", isValid ? "false" : "true");
if(isFocused){
if(isEmpty){
message = this.getPromptMessage(true);
}
if(!message && (this.state == "Error" || (isValidSubset && !this._maskValidSubsetError))){
message = this.getErrorMessage(true);
}
}
this.displayMessage(message);
return isValid;
},
// _message: String
// Currently displayed message
_message: "",
displayMessage: function(/*String*/ message){
// summary:
// Overridable method to display validation errors/hints.
// By default uses a tooltip.
// tags:
// extension
if(this._message == message){ return; }
this._message = message;
dijit.hideTooltip(this.domNode);
if(message){
dijit.showTooltip(message, this.domNode, this.tooltipPosition);
}
},
_refreshState: function(){
// Overrides TextBox._refreshState()
this.validate(this._focused);
this.inherited(arguments);
},
//////////// INITIALIZATION METHODS ///////////////////////////////////////
constructor: function(){
this.constraints = {};
},
postMixInProperties: function(){
this.inherited(arguments);
this.constraints.locale = this.lang;
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang);
if(this.invalidMessage == "$_unset_$"){ this.invalidMessage = this.messages.invalidMessage; }
var p = this.regExpGen(this.constraints);
this.regExp = p;
var partialre = "";
// parse the regexp and produce a new regexp that matches valid subsets
// if the regexp is .* then there's no use in matching subsets since everything is valid
if(p != ".*"){ this.regExp.replace(/\\.|\[\]|\[.*?[^\\]{1}\]|\{.*?\}|\(\?[=:!]|./g,
function (re){
switch(re.charAt(0)){
case '{':
case '+':
case '?':
case '*':
case '^':
case '$':
case '|':
case '(': partialre += re; break;
case ")": partialre += "|$)"; break;
default: partialre += "(?:"+re+"|$)"; break;
}
}
);}
try{ // this is needed for now since the above regexp parsing needs more test verification
"".search(partialre);
}catch(e){ // should never be here unless the original RE is bad or the parsing is bad
partialre = this.regExp;
console.warn('RegExp error in ' + this.declaredClass + ': ' + this.regExp);
} // should never be here unless the original RE is bad or the parsing is bad
this._partialre = "^(?:" + partialre + ")$";
},
_setDisabledAttr: function(/*Boolean*/ value){
this.inherited(arguments); // call FormValueWidget._setDisabledAttr()
if(this.valueNode){
this.valueNode.disabled = value;
}
this._refreshState();
},
_setRequiredAttr: function(/*Boolean*/ value){
this.required = value;
dijit.setWaiState(this.focusNode,"required", value);
this._refreshState();
},
postCreate: function(){
if(dojo.isIE){ // IE INPUT tag fontFamily has to be set directly using STYLE
var s = dojo.getComputedStyle(this.focusNode);
if(s){
var ff = s.fontFamily;
if(ff){
this.focusNode.style.fontFamily = ff;
}
}
}
this.inherited(arguments);
},
reset:function(){
// Overrides dijit.form.TextBox.reset() by also
// hiding errors about partial matches
this._maskValidSubsetError = true;
this.inherited(arguments);
}
}
);
dojo.declare(
"dijit.form.MappedTextBox",
dijit.form.ValidationTextBox,
{
// summary:
// A dijit.form.ValidationTextBox subclass which provides a base class for widgets that have
// a visible formatted display value, and a serializable
// value in a hidden input field which is actually sent to the server.
// description:
// The visible display may
// be locale-dependent and interactive. The value sent to the server is stored in a hidden
// input field which uses the `name` attribute declared by the original widget. That value sent
// to the server is defined by the dijit.form.MappedTextBox.serialize method and is typically
// locale-neutral.
// tags:
// protected
postMixInProperties: function(){
this.inherited(arguments);
// we want the name attribute to go to the hidden , not the displayed ,
// so override _FormWidget.postMixInProperties() setting of nameAttrSetting
this.nameAttrSetting = "";
},
serialize: function(/*anything*/val, /*Object?*/options){
// summary:
// Overridable function used to convert the attr('value') result to a canonical
// (non-localized) string. For example, will print dates in ISO format, and
// numbers the same way as they are represented in javascript.
// tags:
// protected extension
return val.toString ? val.toString() : ""; // String
},
toString: function(){
// summary:
// Returns widget as a printable string using the widget's value
// tags:
// protected
var val = this.filter(this.attr('value')); // call filter in case value is nonstring and filter has been customized
return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String
},
validate: function(){
// Overrides `dijit.form.TextBox.validate`
this.valueNode.value = this.toString();
return this.inherited(arguments);";s:7:"returns";s:14:"String|Boolean";s:7:"summary";s:0:"";}s:39:"dijit.form.MappedTextBox.buildRendering";a:5:{s:9:"prototype";s:24:"dijit.form.MappedTextBox";s:4:"type";s:8:"Function";s:6:"source";s:10483:"dojo.provide("dijit.form.ValidationTextBox");
dojo.require("dojo.i18n");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.Tooltip");
dojo.requireLocalization("dijit.form", "validate");
dijit.form.ValidationTextBox.__Constraints = function(){
// locale: String
// locale used for validation, picks up value from this widget's lang attribute
// _flags_: anything
// various flags passed to regExpGen function
this.locale = "";
this._flags_ = "";
}
dojo.declare(
"dijit.form.ValidationTextBox",
dijit.form.TextBox,
{
// summary:
// Base class for textbox widgets with the ability to validate content of various types and provide user feedback.
// tags:
// protected
templatePath: dojo.moduleUrl("dijit.form", "templates/ValidationTextBox.html"),
baseClass: "dijitTextBox",
// required: Boolean
// User is required to enter data into this field.
required: false,
// promptMessage: String
// If defined, display this hint string immediately on focus to the textbox, if empty.
// Think of this like a tooltip that tells the user what to do, not an error message
// that tells the user what they've done wrong.
//
// Message disappears when user starts typing.
promptMessage: "",
// invalidMessage: String
// The message to display if value is invalid.
invalidMessage: "$_unset_$", // read from the message file if not overridden
// constraints: dijit.form.ValidationTextBox.__Constraints
// user-defined object needed to pass parameters to the validator functions
constraints: {},
// regExp: [extension protected] String
// regular expression string used to validate the input
// Do not specify both regExp and regExpGen
regExp: ".*",
regExpGen: function(/*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to generate regExp when dependent on constraints.
// Do not specify both regExp and regExpGen.
// tags:
// extension protected
return this.regExp; // String
},
// state: [readonly] String
// Shows current state (ie, validation result) of input (Normal, Warning, or Error)
state: "",
// tooltipPosition: String[]
// See description of `dijit.Tooltip.defaultPosition` for details on this parameter.
tooltipPosition: [],
_setValueAttr: function(){
// summary:
// Hook so attr('value', ...) works.
this.inherited(arguments);
this.validate(this._focused);
},
validator: function(/*anything*/value, /*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to validate the text input against the regular expression.
// tags:
// protected
return (new RegExp("^(?:" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) &&
(!this.required || !this._isEmpty(value)) &&
(this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean
},
_isValidSubset: function(){
// summary:
// Returns true if the value is either already valid or could be made valid by appending characters.
// This is used for validation while the user [may be] still typing.
return this.textbox.value.search(this._partialre) == 0;
},
isValid: function(/*Boolean*/ isFocused){
// summary:
// Tests if value is valid.
// Can override with your own routine in a subclass.
// tags:
// protected
return this.validator(this.textbox.value, this.constraints);
},
_isEmpty: function(value){
// summary:
// Checks for whitespace
return /^\s*$/.test(value); // Boolean
},
getErrorMessage: function(/*Boolean*/ isFocused){
// summary:
// Return an error message to show if appropriate
// tags:
// protected
return this.invalidMessage; // String
},
getPromptMessage: function(/*Boolean*/ isFocused){
// summary:
// Return a hint message to show when widget is first focused
// tags:
// protected
return this.promptMessage; // String
},
_maskValidSubsetError: true,
validate: function(/*Boolean*/ isFocused){
// summary:
// Called by oninit, onblur, and onkeypress.
// description:
// Show missing or invalid messages if appropriate, and highlight textbox field.
// tags:
// protected
var message = "";
var isValid = this.disabled || this.isValid(isFocused);
if(isValid){ this._maskValidSubsetError = true; }
var isValidSubset = !isValid && isFocused && this._isValidSubset();
var isEmpty = this._isEmpty(this.textbox.value);
this.state = (isValid || (!this._hasBeenBlurred && isEmpty) || isValidSubset) ? "" : "Error";
if(this.state == "Error"){ this._maskValidSubsetError = false; }
this._setStateClass();
dijit.setWaiState(this.focusNode, "invalid", isValid ? "false" : "true");
if(isFocused){
if(isEmpty){
message = this.getPromptMessage(true);
}
if(!message && (this.state == "Error" || (isValidSubset && !this._maskValidSubsetError))){
message = this.getErrorMessage(true);
}
}
this.displayMessage(message);
return isValid;
},
// _message: String
// Currently displayed message
_message: "",
displayMessage: function(/*String*/ message){
// summary:
// Overridable method to display validation errors/hints.
// By default uses a tooltip.
// tags:
// extension
if(this._message == message){ return; }
this._message = message;
dijit.hideTooltip(this.domNode);
if(message){
dijit.showTooltip(message, this.domNode, this.tooltipPosition);
}
},
_refreshState: function(){
// Overrides TextBox._refreshState()
this.validate(this._focused);
this.inherited(arguments);
},
//////////// INITIALIZATION METHODS ///////////////////////////////////////
constructor: function(){
this.constraints = {};
},
postMixInProperties: function(){
this.inherited(arguments);
this.constraints.locale = this.lang;
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang);
if(this.invalidMessage == "$_unset_$"){ this.invalidMessage = this.messages.invalidMessage; }
var p = this.regExpGen(this.constraints);
this.regExp = p;
var partialre = "";
// parse the regexp and produce a new regexp that matches valid subsets
// if the regexp is .* then there's no use in matching subsets since everything is valid
if(p != ".*"){ this.regExp.replace(/\\.|\[\]|\[.*?[^\\]{1}\]|\{.*?\}|\(\?[=:!]|./g,
function (re){
switch(re.charAt(0)){
case '{':
case '+':
case '?':
case '*':
case '^':
case '$':
case '|':
case '(': partialre += re; break;
case ")": partialre += "|$)"; break;
default: partialre += "(?:"+re+"|$)"; break;
}
}
);}
try{ // this is needed for now since the above regexp parsing needs more test verification
"".search(partialre);
}catch(e){ // should never be here unless the original RE is bad or the parsing is bad
partialre = this.regExp;
console.warn('RegExp error in ' + this.declaredClass + ': ' + this.regExp);
} // should never be here unless the original RE is bad or the parsing is bad
this._partialre = "^(?:" + partialre + ")$";
},
_setDisabledAttr: function(/*Boolean*/ value){
this.inherited(arguments); // call FormValueWidget._setDisabledAttr()
if(this.valueNode){
this.valueNode.disabled = value;
}
this._refreshState();
},
_setRequiredAttr: function(/*Boolean*/ value){
this.required = value;
dijit.setWaiState(this.focusNode,"required", value);
this._refreshState();
},
postCreate: function(){
if(dojo.isIE){ // IE INPUT tag fontFamily has to be set directly using STYLE
var s = dojo.getComputedStyle(this.focusNode);
if(s){
var ff = s.fontFamily;
if(ff){
this.focusNode.style.fontFamily = ff;
}
}
}
this.inherited(arguments);
},
reset:function(){
// Overrides dijit.form.TextBox.reset() by also
// hiding errors about partial matches
this._maskValidSubsetError = true;
this.inherited(arguments);
}
}
);
dojo.declare(
"dijit.form.MappedTextBox",
dijit.form.ValidationTextBox,
{
// summary:
// A dijit.form.ValidationTextBox subclass which provides a base class for widgets that have
// a visible formatted display value, and a serializable
// value in a hidden input field which is actually sent to the server.
// description:
// The visible display may
// be locale-dependent and interactive. The value sent to the server is stored in a hidden
// input field which uses the `name` attribute declared by the original widget. That value sent
// to the server is defined by the dijit.form.MappedTextBox.serialize method and is typically
// locale-neutral.
// tags:
// protected
postMixInProperties: function(){
this.inherited(arguments);
// we want the name attribute to go to the hidden , not the displayed ,
// so override _FormWidget.postMixInProperties() setting of nameAttrSetting
this.nameAttrSetting = "";
},
serialize: function(/*anything*/val, /*Object?*/options){
// summary:
// Overridable function used to convert the attr('value') result to a canonical
// (non-localized) string. For example, will print dates in ISO format, and
// numbers the same way as they are represented in javascript.
// tags:
// protected extension
return val.toString ? val.toString() : ""; // String
},
toString: function(){
// summary:
// Returns widget as a printable string using the widget's value
// tags:
// protected
var val = this.filter(this.attr('value')); // call filter in case value is nonstring and filter has been customized
return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String
},
validate: function(){
// Overrides `dijit.form.TextBox.validate`
this.valueNode.value = this.toString();
return this.inherited(arguments);
},
buildRendering: function(){
// Overrides `dijit._Templated.buildRendering`
this.inherited(arguments);
// Create a hidden node with the serialized value used for submit
// (as opposed to the displayed value)
this.valueNode = dojo.create("input", {
style: { display: "none" },
type: this.type,
name: this.name
}, this.textbox, "after");";s:7:"returns";s:14:"String|Boolean";s:7:"summary";s:0:"";}s:41:"dijit.form.MappedTextBox._setDisabledAttr";a:6:{s:9:"prototype";s:24:"dijit.form.MappedTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:5:"value";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:78:" this.inherited(arguments);
dojo.attr(this.valueNode, 'disabled', value);";s:7:"private";b:1;s:7:"summary";s:0:"";}s:30:"dijit.form.MappedTextBox.reset";a:2:{s:9:"prototype";s:24:"dijit.form.MappedTextBox";s:7:"summary";s:0:"";}s:40:"dijit.form.MappedTextBox.nameAttrSetting";a:2:{s:8:"instance";s:24:"dijit.form.MappedTextBox";s:7:"summary";s:0:"";}s:40:"dijit.form.MappedTextBox.valueNode.value";a:2:{s:8:"instance";s:24:"dijit.form.MappedTextBox";s:7:"summary";s:0:"";}s:34:"dijit.form.MappedTextBox.valueNode";a:2:{s:8:"instance";s:24:"dijit.form.MappedTextBox";s:7:"summary";s:0:"";}s:28:"dijit.form.RangeBoundTextBox";a:4:{s:4:"type";s:8:"Function";s:6:"chains";a:2:{s:9:"prototype";a:1:{i:0;s:24:"dijit.form.MappedTextBox";}s:4:"call";a:1:{i:0;s:24:"dijit.form.MappedTextBox";}}s:7:"summary";s:74:"Base class for textbox form widgets which defines a range of valid values.";s:9:"classlike";b:1;}s:41:"dijit.form.RangeBoundTextBox.rangeMessage";a:4:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:8:"instance";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:6:"String";s:7:"summary";s:47:"The message to display if value is out-of-range";}s:40:"dijit.form.RangeBoundTextBox.constraints";a:3:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}s:39:"dijit.form.RangeBoundTextBox.rangeCheck";a:7:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:9:"primitive";a:1:{s:4:"type";s:6:"Number";}s:11:"constraints";a:1:{s:4:"type";s:42:"dijit.form.RangeBoundTextBox.__Constraints";}}s:6:"source";s:262:" var isMin = "min" in constraints;
var isMax = "max" in constraints;
if(isMin || isMax){
return (!isMin || this.compare(primitive,constraints.min) >= 0) &&
(!isMax || this.compare(primitive,constraints.max) <= 0);
}
return true; // Boolean";s:7:"summary";s:75:"Overridable function used to validate the range of the numeric input value.";s:4:"tags";s:9:"protected";s:7:"returns";s:7:"Boolean";}s:38:"dijit.form.RangeBoundTextBox.isInRange";a:6:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"isFocused";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:64:" return this.rangeCheck(this.attr('value'), this.constraints);";s:7:"summary";s:67:"Tests if the value is in the min/max range specified in constraints";s:4:"tags";s:9:"protected";}s:52:"dijit.form.RangeBoundTextBox._isDefinitelyOutOfRange";a:5:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:6:"source";s:546:" var val = this.attr('value');
var isTooLittle = false;
var isTooMuch = false;
if("min" in this.constraints){
var min = this.constraints.min;
val = this.compare(val, ((typeof min == "number") && min >= 0 && val !=0)? 0 : min);
isTooLittle = (typeof val == "number") && val < 0;
}
if("max" in this.constraints){
var max = this.constraints.max;
val = this.compare(val, ((typeof max != "number") || max > 0)? max : 0);
isTooMuch = (typeof val == "number") && val > 0;
}
return isTooLittle || isTooMuch;";s:7:"summary";s:109:"Returns true if the value is out of range and will remain
out of range even if the user types more characters";s:7:"private";b:1;}s:43:"dijit.form.RangeBoundTextBox._isValidSubset";a:5:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:6:"source";s:71:" return this.inherited(arguments) && !this._isDefinitelyOutOfRange();";s:7:"summary";s:172:"Overrides `dijit.form.ValidationTextBox._isValidSubset`.
Returns true if the input is syntactically valid, and either within
range or could be made in range by more typing.";s:7:"private";b:1;}s:36:"dijit.form.RangeBoundTextBox.isValid";a:6:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"isFocused";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:13517:"dojo.provide("dijit.form.ValidationTextBox");
dojo.require("dojo.i18n");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.Tooltip");
dojo.requireLocalization("dijit.form", "validate");
dijit.form.ValidationTextBox.__Constraints = function(){
// locale: String
// locale used for validation, picks up value from this widget's lang attribute
// _flags_: anything
// various flags passed to regExpGen function
this.locale = "";
this._flags_ = "";
}
dojo.declare(
"dijit.form.ValidationTextBox",
dijit.form.TextBox,
{
// summary:
// Base class for textbox widgets with the ability to validate content of various types and provide user feedback.
// tags:
// protected
templatePath: dojo.moduleUrl("dijit.form", "templates/ValidationTextBox.html"),
baseClass: "dijitTextBox",
// required: Boolean
// User is required to enter data into this field.
required: false,
// promptMessage: String
// If defined, display this hint string immediately on focus to the textbox, if empty.
// Think of this like a tooltip that tells the user what to do, not an error message
// that tells the user what they've done wrong.
//
// Message disappears when user starts typing.
promptMessage: "",
// invalidMessage: String
// The message to display if value is invalid.
invalidMessage: "$_unset_$", // read from the message file if not overridden
// constraints: dijit.form.ValidationTextBox.__Constraints
// user-defined object needed to pass parameters to the validator functions
constraints: {},
// regExp: [extension protected] String
// regular expression string used to validate the input
// Do not specify both regExp and regExpGen
regExp: ".*",
regExpGen: function(/*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to generate regExp when dependent on constraints.
// Do not specify both regExp and regExpGen.
// tags:
// extension protected
return this.regExp; // String
},
// state: [readonly] String
// Shows current state (ie, validation result) of input (Normal, Warning, or Error)
state: "",
// tooltipPosition: String[]
// See description of `dijit.Tooltip.defaultPosition` for details on this parameter.
tooltipPosition: [],
_setValueAttr: function(){
// summary:
// Hook so attr('value', ...) works.
this.inherited(arguments);
this.validate(this._focused);
},
validator: function(/*anything*/value, /*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to validate the text input against the regular expression.
// tags:
// protected
return (new RegExp("^(?:" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) &&
(!this.required || !this._isEmpty(value)) &&
(this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean
},
_isValidSubset: function(){
// summary:
// Returns true if the value is either already valid or could be made valid by appending characters.
// This is used for validation while the user [may be] still typing.
return this.textbox.value.search(this._partialre) == 0;
},
isValid: function(/*Boolean*/ isFocused){
// summary:
// Tests if value is valid.
// Can override with your own routine in a subclass.
// tags:
// protected
return this.validator(this.textbox.value, this.constraints);
},
_isEmpty: function(value){
// summary:
// Checks for whitespace
return /^\s*$/.test(value); // Boolean
},
getErrorMessage: function(/*Boolean*/ isFocused){
// summary:
// Return an error message to show if appropriate
// tags:
// protected
return this.invalidMessage; // String
},
getPromptMessage: function(/*Boolean*/ isFocused){
// summary:
// Return a hint message to show when widget is first focused
// tags:
// protected
return this.promptMessage; // String
},
_maskValidSubsetError: true,
validate: function(/*Boolean*/ isFocused){
// summary:
// Called by oninit, onblur, and onkeypress.
// description:
// Show missing or invalid messages if appropriate, and highlight textbox field.
// tags:
// protected
var message = "";
var isValid = this.disabled || this.isValid(isFocused);
if(isValid){ this._maskValidSubsetError = true; }
var isValidSubset = !isValid && isFocused && this._isValidSubset();
var isEmpty = this._isEmpty(this.textbox.value);
this.state = (isValid || (!this._hasBeenBlurred && isEmpty) || isValidSubset) ? "" : "Error";
if(this.state == "Error"){ this._maskValidSubsetError = false; }
this._setStateClass();
dijit.setWaiState(this.focusNode, "invalid", isValid ? "false" : "true");
if(isFocused){
if(isEmpty){
message = this.getPromptMessage(true);
}
if(!message && (this.state == "Error" || (isValidSubset && !this._maskValidSubsetError))){
message = this.getErrorMessage(true);
}
}
this.displayMessage(message);
return isValid;
},
// _message: String
// Currently displayed message
_message: "",
displayMessage: function(/*String*/ message){
// summary:
// Overridable method to display validation errors/hints.
// By default uses a tooltip.
// tags:
// extension
if(this._message == message){ return; }
this._message = message;
dijit.hideTooltip(this.domNode);
if(message){
dijit.showTooltip(message, this.domNode, this.tooltipPosition);
}
},
_refreshState: function(){
// Overrides TextBox._refreshState()
this.validate(this._focused);
this.inherited(arguments);
},
//////////// INITIALIZATION METHODS ///////////////////////////////////////
constructor: function(){
this.constraints = {};
},
postMixInProperties: function(){
this.inherited(arguments);
this.constraints.locale = this.lang;
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang);
if(this.invalidMessage == "$_unset_$"){ this.invalidMessage = this.messages.invalidMessage; }
var p = this.regExpGen(this.constraints);
this.regExp = p;
var partialre = "";
// parse the regexp and produce a new regexp that matches valid subsets
// if the regexp is .* then there's no use in matching subsets since everything is valid
if(p != ".*"){ this.regExp.replace(/\\.|\[\]|\[.*?[^\\]{1}\]|\{.*?\}|\(\?[=:!]|./g,
function (re){
switch(re.charAt(0)){
case '{':
case '+':
case '?':
case '*':
case '^':
case '$':
case '|':
case '(': partialre += re; break;
case ")": partialre += "|$)"; break;
default: partialre += "(?:"+re+"|$)"; break;
}
}
);}
try{ // this is needed for now since the above regexp parsing needs more test verification
"".search(partialre);
}catch(e){ // should never be here unless the original RE is bad or the parsing is bad
partialre = this.regExp;
console.warn('RegExp error in ' + this.declaredClass + ': ' + this.regExp);
} // should never be here unless the original RE is bad or the parsing is bad
this._partialre = "^(?:" + partialre + ")$";
},
_setDisabledAttr: function(/*Boolean*/ value){
this.inherited(arguments); // call FormValueWidget._setDisabledAttr()
if(this.valueNode){
this.valueNode.disabled = value;
}
this._refreshState();
},
_setRequiredAttr: function(/*Boolean*/ value){
this.required = value;
dijit.setWaiState(this.focusNode,"required", value);
this._refreshState();
},
postCreate: function(){
if(dojo.isIE){ // IE INPUT tag fontFamily has to be set directly using STYLE
var s = dojo.getComputedStyle(this.focusNode);
if(s){
var ff = s.fontFamily;
if(ff){
this.focusNode.style.fontFamily = ff;
}
}
}
this.inherited(arguments);
},
reset:function(){
// Overrides dijit.form.TextBox.reset() by also
// hiding errors about partial matches
this._maskValidSubsetError = true;
this.inherited(arguments);
}
}
);
dojo.declare(
"dijit.form.MappedTextBox",
dijit.form.ValidationTextBox,
{
// summary:
// A dijit.form.ValidationTextBox subclass which provides a base class for widgets that have
// a visible formatted display value, and a serializable
// value in a hidden input field which is actually sent to the server.
// description:
// The visible display may
// be locale-dependent and interactive. The value sent to the server is stored in a hidden
// input field which uses the `name` attribute declared by the original widget. That value sent
// to the server is defined by the dijit.form.MappedTextBox.serialize method and is typically
// locale-neutral.
// tags:
// protected
postMixInProperties: function(){
this.inherited(arguments);
// we want the name attribute to go to the hidden , not the displayed ,
// so override _FormWidget.postMixInProperties() setting of nameAttrSetting
this.nameAttrSetting = "";
},
serialize: function(/*anything*/val, /*Object?*/options){
// summary:
// Overridable function used to convert the attr('value') result to a canonical
// (non-localized) string. For example, will print dates in ISO format, and
// numbers the same way as they are represented in javascript.
// tags:
// protected extension
return val.toString ? val.toString() : ""; // String
},
toString: function(){
// summary:
// Returns widget as a printable string using the widget's value
// tags:
// protected
var val = this.filter(this.attr('value')); // call filter in case value is nonstring and filter has been customized
return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String
},
validate: function(){
// Overrides `dijit.form.TextBox.validate`
this.valueNode.value = this.toString();
return this.inherited(arguments);
},
buildRendering: function(){
// Overrides `dijit._Templated.buildRendering`
this.inherited(arguments);
// Create a hidden node with the serialized value used for submit
// (as opposed to the displayed value)
this.valueNode = dojo.create("input", {
style: { display: "none" },
type: this.type,
name: this.name
}, this.textbox, "after");
},
_setDisabledAttr: function(/*Boolean*/ value){
this.inherited(arguments);
dojo.attr(this.valueNode, 'disabled', value);
},
reset:function(){
// Overrides `dijit.form.ValidationTextBox.reset` to
// reset the hidden textbox value to ''
this.valueNode.value = '';
this.inherited(arguments);
}
}
);
dijit.form.RangeBoundTextBox.__Constraints = function(){
// min: Number
// Minimum signed value. Default is -Infinity
// max: Number
// Maximum signed value. Default is +Infinity
this.min = min;
this.max = max;
}
dojo.declare(
"dijit.form.RangeBoundTextBox",
dijit.form.MappedTextBox,
{
// summary:
// Base class for textbox form widgets which defines a range of valid values.
// rangeMessage: String
// The message to display if value is out-of-range
rangeMessage: "",
// constraints: dijit.form.RangeBoundTextBox.__Constraints
constraints: {},
rangeCheck: function(/*Number*/ primitive, /*dijit.form.RangeBoundTextBox.__Constraints*/ constraints){
// summary:
// Overridable function used to validate the range of the numeric input value.
// tags:
// protected
var isMin = "min" in constraints;
var isMax = "max" in constraints;
if(isMin || isMax){
return (!isMin || this.compare(primitive,constraints.min) >= 0) &&
(!isMax || this.compare(primitive,constraints.max) <= 0);
}
return true; // Boolean
},
isInRange: function(/*Boolean*/ isFocused){
// summary:
// Tests if the value is in the min/max range specified in constraints
// tags:
// protected
return this.rangeCheck(this.attr('value'), this.constraints);
},
_isDefinitelyOutOfRange: function(){
// summary:
// Returns true if the value is out of range and will remain
// out of range even if the user types more characters
var val = this.attr('value');
var isTooLittle = false;
var isTooMuch = false;
if("min" in this.constraints){
var min = this.constraints.min;
val = this.compare(val, ((typeof min == "number") && min >= 0 && val !=0)? 0 : min);
isTooLittle = (typeof val == "number") && val < 0;
}
if("max" in this.constraints){
var max = this.constraints.max;
val = this.compare(val, ((typeof max != "number") || max > 0)? max : 0);
isTooMuch = (typeof val == "number") && val > 0;
}
return isTooLittle || isTooMuch;
},
_isValidSubset: function(){
// summary:
// Overrides `dijit.form.ValidationTextBox._isValidSubset`.
// Returns true if the input is syntactically valid, and either within
// range or could be made in range by more typing.
return this.inherited(arguments) && !this._isDefinitelyOutOfRange();
},
isValid: function(/*Boolean*/ isFocused){
// Overrides dijit.form.ValidationTextBox.isValid to check that the value is also in range.
return this.inherited(arguments) &&
((this._isEmpty(this.textbox.value) && !this.required) || this.isInRange(isFocused)); // Boolean";s:7:"returns";s:14:"String|Boolean";s:7:"summary";s:0:"";}s:44:"dijit.form.RangeBoundTextBox.getErrorMessage";a:7:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:1:{s:9:"isFocused";a:1:{s:4:"type";s:7:"Boolean";}}s:6:"source";s:13863:"dojo.provide("dijit.form.ValidationTextBox");
dojo.require("dojo.i18n");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.Tooltip");
dojo.requireLocalization("dijit.form", "validate");
dijit.form.ValidationTextBox.__Constraints = function(){
// locale: String
// locale used for validation, picks up value from this widget's lang attribute
// _flags_: anything
// various flags passed to regExpGen function
this.locale = "";
this._flags_ = "";
}
dojo.declare(
"dijit.form.ValidationTextBox",
dijit.form.TextBox,
{
// summary:
// Base class for textbox widgets with the ability to validate content of various types and provide user feedback.
// tags:
// protected
templatePath: dojo.moduleUrl("dijit.form", "templates/ValidationTextBox.html"),
baseClass: "dijitTextBox",
// required: Boolean
// User is required to enter data into this field.
required: false,
// promptMessage: String
// If defined, display this hint string immediately on focus to the textbox, if empty.
// Think of this like a tooltip that tells the user what to do, not an error message
// that tells the user what they've done wrong.
//
// Message disappears when user starts typing.
promptMessage: "",
// invalidMessage: String
// The message to display if value is invalid.
invalidMessage: "$_unset_$", // read from the message file if not overridden
// constraints: dijit.form.ValidationTextBox.__Constraints
// user-defined object needed to pass parameters to the validator functions
constraints: {},
// regExp: [extension protected] String
// regular expression string used to validate the input
// Do not specify both regExp and regExpGen
regExp: ".*",
regExpGen: function(/*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to generate regExp when dependent on constraints.
// Do not specify both regExp and regExpGen.
// tags:
// extension protected
return this.regExp; // String
},
// state: [readonly] String
// Shows current state (ie, validation result) of input (Normal, Warning, or Error)
state: "",
// tooltipPosition: String[]
// See description of `dijit.Tooltip.defaultPosition` for details on this parameter.
tooltipPosition: [],
_setValueAttr: function(){
// summary:
// Hook so attr('value', ...) works.
this.inherited(arguments);
this.validate(this._focused);
},
validator: function(/*anything*/value, /*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to validate the text input against the regular expression.
// tags:
// protected
return (new RegExp("^(?:" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) &&
(!this.required || !this._isEmpty(value)) &&
(this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean
},
_isValidSubset: function(){
// summary:
// Returns true if the value is either already valid or could be made valid by appending characters.
// This is used for validation while the user [may be] still typing.
return this.textbox.value.search(this._partialre) == 0;
},
isValid: function(/*Boolean*/ isFocused){
// summary:
// Tests if value is valid.
// Can override with your own routine in a subclass.
// tags:
// protected
return this.validator(this.textbox.value, this.constraints);
},
_isEmpty: function(value){
// summary:
// Checks for whitespace
return /^\s*$/.test(value); // Boolean
},
getErrorMessage: function(/*Boolean*/ isFocused){
// summary:
// Return an error message to show if appropriate
// tags:
// protected
return this.invalidMessage; // String
},
getPromptMessage: function(/*Boolean*/ isFocused){
// summary:
// Return a hint message to show when widget is first focused
// tags:
// protected
return this.promptMessage; // String
},
_maskValidSubsetError: true,
validate: function(/*Boolean*/ isFocused){
// summary:
// Called by oninit, onblur, and onkeypress.
// description:
// Show missing or invalid messages if appropriate, and highlight textbox field.
// tags:
// protected
var message = "";
var isValid = this.disabled || this.isValid(isFocused);
if(isValid){ this._maskValidSubsetError = true; }
var isValidSubset = !isValid && isFocused && this._isValidSubset();
var isEmpty = this._isEmpty(this.textbox.value);
this.state = (isValid || (!this._hasBeenBlurred && isEmpty) || isValidSubset) ? "" : "Error";
if(this.state == "Error"){ this._maskValidSubsetError = false; }
this._setStateClass();
dijit.setWaiState(this.focusNode, "invalid", isValid ? "false" : "true");
if(isFocused){
if(isEmpty){
message = this.getPromptMessage(true);
}
if(!message && (this.state == "Error" || (isValidSubset && !this._maskValidSubsetError))){
message = this.getErrorMessage(true);
}
}
this.displayMessage(message);
return isValid;
},
// _message: String
// Currently displayed message
_message: "",
displayMessage: function(/*String*/ message){
// summary:
// Overridable method to display validation errors/hints.
// By default uses a tooltip.
// tags:
// extension
if(this._message == message){ return; }
this._message = message;
dijit.hideTooltip(this.domNode);
if(message){
dijit.showTooltip(message, this.domNode, this.tooltipPosition);
}
},
_refreshState: function(){
// Overrides TextBox._refreshState()
this.validate(this._focused);
this.inherited(arguments);
},
//////////// INITIALIZATION METHODS ///////////////////////////////////////
constructor: function(){
this.constraints = {};
},
postMixInProperties: function(){
this.inherited(arguments);
this.constraints.locale = this.lang;
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang);
if(this.invalidMessage == "$_unset_$"){ this.invalidMessage = this.messages.invalidMessage; }
var p = this.regExpGen(this.constraints);
this.regExp = p;
var partialre = "";
// parse the regexp and produce a new regexp that matches valid subsets
// if the regexp is .* then there's no use in matching subsets since everything is valid
if(p != ".*"){ this.regExp.replace(/\\.|\[\]|\[.*?[^\\]{1}\]|\{.*?\}|\(\?[=:!]|./g,
function (re){
switch(re.charAt(0)){
case '{':
case '+':
case '?':
case '*':
case '^':
case '$':
case '|':
case '(': partialre += re; break;
case ")": partialre += "|$)"; break;
default: partialre += "(?:"+re+"|$)"; break;
}
}
);}
try{ // this is needed for now since the above regexp parsing needs more test verification
"".search(partialre);
}catch(e){ // should never be here unless the original RE is bad or the parsing is bad
partialre = this.regExp;
console.warn('RegExp error in ' + this.declaredClass + ': ' + this.regExp);
} // should never be here unless the original RE is bad or the parsing is bad
this._partialre = "^(?:" + partialre + ")$";
},
_setDisabledAttr: function(/*Boolean*/ value){
this.inherited(arguments); // call FormValueWidget._setDisabledAttr()
if(this.valueNode){
this.valueNode.disabled = value;
}
this._refreshState();
},
_setRequiredAttr: function(/*Boolean*/ value){
this.required = value;
dijit.setWaiState(this.focusNode,"required", value);
this._refreshState();
},
postCreate: function(){
if(dojo.isIE){ // IE INPUT tag fontFamily has to be set directly using STYLE
var s = dojo.getComputedStyle(this.focusNode);
if(s){
var ff = s.fontFamily;
if(ff){
this.focusNode.style.fontFamily = ff;
}
}
}
this.inherited(arguments);
},
reset:function(){
// Overrides dijit.form.TextBox.reset() by also
// hiding errors about partial matches
this._maskValidSubsetError = true;
this.inherited(arguments);
}
}
);
dojo.declare(
"dijit.form.MappedTextBox",
dijit.form.ValidationTextBox,
{
// summary:
// A dijit.form.ValidationTextBox subclass which provides a base class for widgets that have
// a visible formatted display value, and a serializable
// value in a hidden input field which is actually sent to the server.
// description:
// The visible display may
// be locale-dependent and interactive. The value sent to the server is stored in a hidden
// input field which uses the `name` attribute declared by the original widget. That value sent
// to the server is defined by the dijit.form.MappedTextBox.serialize method and is typically
// locale-neutral.
// tags:
// protected
postMixInProperties: function(){
this.inherited(arguments);
// we want the name attribute to go to the hidden , not the displayed ,
// so override _FormWidget.postMixInProperties() setting of nameAttrSetting
this.nameAttrSetting = "";
},
serialize: function(/*anything*/val, /*Object?*/options){
// summary:
// Overridable function used to convert the attr('value') result to a canonical
// (non-localized) string. For example, will print dates in ISO format, and
// numbers the same way as they are represented in javascript.
// tags:
// protected extension
return val.toString ? val.toString() : ""; // String
},
toString: function(){
// summary:
// Returns widget as a printable string using the widget's value
// tags:
// protected
var val = this.filter(this.attr('value')); // call filter in case value is nonstring and filter has been customized
return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String
},
validate: function(){
// Overrides `dijit.form.TextBox.validate`
this.valueNode.value = this.toString();
return this.inherited(arguments);
},
buildRendering: function(){
// Overrides `dijit._Templated.buildRendering`
this.inherited(arguments);
// Create a hidden node with the serialized value used for submit
// (as opposed to the displayed value)
this.valueNode = dojo.create("input", {
style: { display: "none" },
type: this.type,
name: this.name
}, this.textbox, "after");
},
_setDisabledAttr: function(/*Boolean*/ value){
this.inherited(arguments);
dojo.attr(this.valueNode, 'disabled', value);
},
reset:function(){
// Overrides `dijit.form.ValidationTextBox.reset` to
// reset the hidden textbox value to ''
this.valueNode.value = '';
this.inherited(arguments);
}
}
);
dijit.form.RangeBoundTextBox.__Constraints = function(){
// min: Number
// Minimum signed value. Default is -Infinity
// max: Number
// Maximum signed value. Default is +Infinity
this.min = min;
this.max = max;
}
dojo.declare(
"dijit.form.RangeBoundTextBox",
dijit.form.MappedTextBox,
{
// summary:
// Base class for textbox form widgets which defines a range of valid values.
// rangeMessage: String
// The message to display if value is out-of-range
rangeMessage: "",
// constraints: dijit.form.RangeBoundTextBox.__Constraints
constraints: {},
rangeCheck: function(/*Number*/ primitive, /*dijit.form.RangeBoundTextBox.__Constraints*/ constraints){
// summary:
// Overridable function used to validate the range of the numeric input value.
// tags:
// protected
var isMin = "min" in constraints;
var isMax = "max" in constraints;
if(isMin || isMax){
return (!isMin || this.compare(primitive,constraints.min) >= 0) &&
(!isMax || this.compare(primitive,constraints.max) <= 0);
}
return true; // Boolean
},
isInRange: function(/*Boolean*/ isFocused){
// summary:
// Tests if the value is in the min/max range specified in constraints
// tags:
// protected
return this.rangeCheck(this.attr('value'), this.constraints);
},
_isDefinitelyOutOfRange: function(){
// summary:
// Returns true if the value is out of range and will remain
// out of range even if the user types more characters
var val = this.attr('value');
var isTooLittle = false;
var isTooMuch = false;
if("min" in this.constraints){
var min = this.constraints.min;
val = this.compare(val, ((typeof min == "number") && min >= 0 && val !=0)? 0 : min);
isTooLittle = (typeof val == "number") && val < 0;
}
if("max" in this.constraints){
var max = this.constraints.max;
val = this.compare(val, ((typeof max != "number") || max > 0)? max : 0);
isTooMuch = (typeof val == "number") && val > 0;
}
return isTooLittle || isTooMuch;
},
_isValidSubset: function(){
// summary:
// Overrides `dijit.form.ValidationTextBox._isValidSubset`.
// Returns true if the input is syntactically valid, and either within
// range or could be made in range by more typing.
return this.inherited(arguments) && !this._isDefinitelyOutOfRange();
},
isValid: function(/*Boolean*/ isFocused){
// Overrides dijit.form.ValidationTextBox.isValid to check that the value is also in range.
return this.inherited(arguments) &&
((this._isEmpty(this.textbox.value) && !this.required) || this.isInRange(isFocused)); // Boolean
},
getErrorMessage: function(/*Boolean*/ isFocused){
// Overrides dijit.form.ValidationTextBox.getErrorMessage to print "out of range" message if appropriate
if(dijit.form.RangeBoundTextBox.superclass.isValid.call(this, false) && !this.isInRange(isFocused)){ return this.rangeMessage; } // String
return this.inherited(arguments);";s:7:"returns";s:14:"String|Boolean";s:6:"chains";a:1:{s:4:"call";a:1:{i:0;s:47:"dijit.form.RangeBoundTextBox.superclass.isValid";}}s:7:"summary";s:0:"";}s:48:"dijit.form.RangeBoundTextBox.postMixInProperties";a:4:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:6:"source";s:197:" this.inherited(arguments);
if(!this.rangeMessage){
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang);
this.rangeMessage = this.messages.rangeMessage;
}";s:7:"summary";s:0:"";}s:39:"dijit.form.RangeBoundTextBox.postCreate";a:4:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:6:"source";s:271:" this.inherited(arguments);
if(this.constraints.min !== undefined){
dijit.setWaiState(this.focusNode, "valuemin", this.constraints.min);
}
if(this.constraints.max !== undefined){
dijit.setWaiState(this.focusNode, "valuemax", this.constraints.max);
}";s:7:"summary";s:0:"";}s:42:"dijit.form.RangeBoundTextBox._setValueAttr";a:6:{s:9:"prototype";s:28:"dijit.form.RangeBoundTextBox";s:4:"type";s:8:"Function";s:10:"parameters";a:2:{s:5:"value";a:1:{s:4:"type";s:6:"Number";}s:14:"priorityChange";a:2:{s:8:"optional";b:1;s:4:"type";s:7:"Boolean";}}s:6:"source";s:86:" dijit.setWaiState(this.focusNode, "valuenow", value);
this.inherited(arguments);";s:7:"summary";s:33:"Hook so attr('value', ...) works.";s:7:"private";b:1;}s:37:"dijit.form.RangeBoundTextBox.messages";a:2:{s:8:"instance";s:28:"dijit.form.RangeBoundTextBox";s:7:"summary";s:0:"";}s:42:"dijit.form.ValidationTextBox.__Constraints";a:5:{s:4:"type";s:8:"Function";s:6:"source";s:482:"dojo.provide("dijit.form.ValidationTextBox");
dojo.require("dojo.i18n");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.Tooltip");
dojo.requireLocalization("dijit.form", "validate");
dijit.form.ValidationTextBox.__Constraints = function(){
// locale: String
// locale used for validation, picks up value from this widget's lang attribute
// _flags_: anything
// various flags passed to regExpGen function
this.locale = "";
this._flags_ = "";";s:7:"private";b:1;s:9:"classlike";b:1;s:7:"summary";s:0:"";}s:49:"dijit.form.ValidationTextBox.__Constraints.locale";a:4:{s:8:"instance";s:42:"dijit.form.ValidationTextBox.__Constraints";s:4:"type";s:6:"String";s:7:"summary";s:76:"locale used for validation, picks up value from this widget's lang attribute";s:14:"private_parent";b:1;}s:50:"dijit.form.ValidationTextBox.__Constraints._flags_";a:5:{s:8:"instance";s:42:"dijit.form.ValidationTextBox.__Constraints";s:4:"type";s:8:"anything";s:7:"summary";s:42:"various flags passed to regExpGen function";s:7:"private";b:1;s:14:"private_parent";b:1;}s:42:"dijit.form.RangeBoundTextBox.__Constraints";a:5:{s:4:"type";s:8:"Function";s:6:"source";s:11053:"dojo.provide("dijit.form.ValidationTextBox");
dojo.require("dojo.i18n");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.Tooltip");
dojo.requireLocalization("dijit.form", "validate");
dijit.form.ValidationTextBox.__Constraints = function(){
// locale: String
// locale used for validation, picks up value from this widget's lang attribute
// _flags_: anything
// various flags passed to regExpGen function
this.locale = "";
this._flags_ = "";
}
dojo.declare(
"dijit.form.ValidationTextBox",
dijit.form.TextBox,
{
// summary:
// Base class for textbox widgets with the ability to validate content of various types and provide user feedback.
// tags:
// protected
templatePath: dojo.moduleUrl("dijit.form", "templates/ValidationTextBox.html"),
baseClass: "dijitTextBox",
// required: Boolean
// User is required to enter data into this field.
required: false,
// promptMessage: String
// If defined, display this hint string immediately on focus to the textbox, if empty.
// Think of this like a tooltip that tells the user what to do, not an error message
// that tells the user what they've done wrong.
//
// Message disappears when user starts typing.
promptMessage: "",
// invalidMessage: String
// The message to display if value is invalid.
invalidMessage: "$_unset_$", // read from the message file if not overridden
// constraints: dijit.form.ValidationTextBox.__Constraints
// user-defined object needed to pass parameters to the validator functions
constraints: {},
// regExp: [extension protected] String
// regular expression string used to validate the input
// Do not specify both regExp and regExpGen
regExp: ".*",
regExpGen: function(/*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to generate regExp when dependent on constraints.
// Do not specify both regExp and regExpGen.
// tags:
// extension protected
return this.regExp; // String
},
// state: [readonly] String
// Shows current state (ie, validation result) of input (Normal, Warning, or Error)
state: "",
// tooltipPosition: String[]
// See description of `dijit.Tooltip.defaultPosition` for details on this parameter.
tooltipPosition: [],
_setValueAttr: function(){
// summary:
// Hook so attr('value', ...) works.
this.inherited(arguments);
this.validate(this._focused);
},
validator: function(/*anything*/value, /*dijit.form.ValidationTextBox.__Constraints*/constraints){
// summary:
// Overridable function used to validate the text input against the regular expression.
// tags:
// protected
return (new RegExp("^(?:" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) &&
(!this.required || !this._isEmpty(value)) &&
(this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean
},
_isValidSubset: function(){
// summary:
// Returns true if the value is either already valid or could be made valid by appending characters.
// This is used for validation while the user [may be] still typing.
return this.textbox.value.search(this._partialre) == 0;
},
isValid: function(/*Boolean*/ isFocused){
// summary:
// Tests if value is valid.
// Can override with your own routine in a subclass.
// tags:
// protected
return this.validator(this.textbox.value, this.constraints);
},
_isEmpty: function(value){
// summary:
// Checks for whitespace
return /^\s*$/.test(value); // Boolean
},
getErrorMessage: function(/*Boolean*/ isFocused){
// summary:
// Return an error message to show if appropriate
// tags:
// protected
return this.invalidMessage; // String
},
getPromptMessage: function(/*Boolean*/ isFocused){
// summary:
// Return a hint message to show when widget is first focused
// tags:
// protected
return this.promptMessage; // String
},
_maskValidSubsetError: true,
validate: function(/*Boolean*/ isFocused){
// summary:
// Called by oninit, onblur, and onkeypress.
// description:
// Show missing or invalid messages if appropriate, and highlight textbox field.
// tags:
// protected
var message = "";
var isValid = this.disabled || this.isValid(isFocused);
if(isValid){ this._maskValidSubsetError = true; }
var isValidSubset = !isValid && isFocused && this._isValidSubset();
var isEmpty = this._isEmpty(this.textbox.value);
this.state = (isValid || (!this._hasBeenBlurred && isEmpty) || isValidSubset) ? "" : "Error";
if(this.state == "Error"){ this._maskValidSubsetError = false; }
this._setStateClass();
dijit.setWaiState(this.focusNode, "invalid", isValid ? "false" : "true");
if(isFocused){
if(isEmpty){
message = this.getPromptMessage(true);
}
if(!message && (this.state == "Error" || (isValidSubset && !this._maskValidSubsetError))){
message = this.getErrorMessage(true);
}
}
this.displayMessage(message);
return isValid;
},
// _message: String
// Currently displayed message
_message: "",
displayMessage: function(/*String*/ message){
// summary:
// Overridable method to display validation errors/hints.
// By default uses a tooltip.
// tags:
// extension
if(this._message == message){ return; }
this._message = message;
dijit.hideTooltip(this.domNode);
if(message){
dijit.showTooltip(message, this.domNode, this.tooltipPosition);
}
},
_refreshState: function(){
// Overrides TextBox._refreshState()
this.validate(this._focused);
this.inherited(arguments);
},
//////////// INITIALIZATION METHODS ///////////////////////////////////////
constructor: function(){
this.constraints = {};
},
postMixInProperties: function(){
this.inherited(arguments);
this.constraints.locale = this.lang;
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang);
if(this.invalidMessage == "$_unset_$"){ this.invalidMessage = this.messages.invalidMessage; }
var p = this.regExpGen(this.constraints);
this.regExp = p;
var partialre = "";
// parse the regexp and produce a new regexp that matches valid subsets
// if the regexp is .* then there's no use in matching subsets since everything is valid
if(p != ".*"){ this.regExp.replace(/\\.|\[\]|\[.*?[^\\]{1}\]|\{.*?\}|\(\?[=:!]|./g,
function (re){
switch(re.charAt(0)){
case '{':
case '+':
case '?':
case '*':
case '^':
case '$':
case '|':
case '(': partialre += re; break;
case ")": partialre += "|$)"; break;
default: partialre += "(?:"+re+"|$)"; break;
}
}
);}
try{ // this is needed for now since the above regexp parsing needs more test verification
"".search(partialre);
}catch(e){ // should never be here unless the original RE is bad or the parsing is bad
partialre = this.regExp;
console.warn('RegExp error in ' + this.declaredClass + ': ' + this.regExp);
} // should never be here unless the original RE is bad or the parsing is bad
this._partialre = "^(?:" + partialre + ")$";
},
_setDisabledAttr: function(/*Boolean*/ value){
this.inherited(arguments); // call FormValueWidget._setDisabledAttr()
if(this.valueNode){
this.valueNode.disabled = value;
}
this._refreshState();
},
_setRequiredAttr: function(/*Boolean*/ value){
this.required = value;
dijit.setWaiState(this.focusNode,"required", value);
this._refreshState();
},
postCreate: function(){
if(dojo.isIE){ // IE INPUT tag fontFamily has to be set directly using STYLE
var s = dojo.getComputedStyle(this.focusNode);
if(s){
var ff = s.fontFamily;
if(ff){
this.focusNode.style.fontFamily = ff;
}
}
}
this.inherited(arguments);
},
reset:function(){
// Overrides dijit.form.TextBox.reset() by also
// hiding errors about partial matches
this._maskValidSubsetError = true;
this.inherited(arguments);
}
}
);
dojo.declare(
"dijit.form.MappedTextBox",
dijit.form.ValidationTextBox,
{
// summary:
// A dijit.form.ValidationTextBox subclass which provides a base class for widgets that have
// a visible formatted display value, and a serializable
// value in a hidden input field which is actually sent to the server.
// description:
// The visible display may
// be locale-dependent and interactive. The value sent to the server is stored in a hidden
// input field which uses the `name` attribute declared by the original widget. That value sent
// to the server is defined by the dijit.form.MappedTextBox.serialize method and is typically
// locale-neutral.
// tags:
// protected
postMixInProperties: function(){
this.inherited(arguments);
// we want the name attribute to go to the hidden , not the displayed ,
// so override _FormWidget.postMixInProperties() setting of nameAttrSetting
this.nameAttrSetting = "";
},
serialize: function(/*anything*/val, /*Object?*/options){
// summary:
// Overridable function used to convert the attr('value') result to a canonical
// (non-localized) string. For example, will print dates in ISO format, and
// numbers the same way as they are represented in javascript.
// tags:
// protected extension
return val.toString ? val.toString() : ""; // String
},
toString: function(){
// summary:
// Returns widget as a printable string using the widget's value
// tags:
// protected
var val = this.filter(this.attr('value')); // call filter in case value is nonstring and filter has been customized
return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String
},
validate: function(){
// Overrides `dijit.form.TextBox.validate`
this.valueNode.value = this.toString();
return this.inherited(arguments);
},
buildRendering: function(){
// Overrides `dijit._Templated.buildRendering`
this.inherited(arguments);
// Create a hidden node with the serialized value used for submit
// (as opposed to the displayed value)
this.valueNode = dojo.create("input", {
style: { display: "none" },
type: this.type,
name: this.name
}, this.textbox, "after");
},
_setDisabledAttr: function(/*Boolean*/ value){
this.inherited(arguments);
dojo.attr(this.valueNode, 'disabled', value);
},
reset:function(){
// Overrides `dijit.form.ValidationTextBox.reset` to
// reset the hidden textbox value to ''
this.valueNode.value = '';
this.inherited(arguments);
}
}
);
dijit.form.RangeBoundTextBox.__Constraints = function(){
// min: Number
// Minimum signed value. Default is -Infinity
// max: Number
// Maximum signed value. Default is +Infinity
this.min = min;
this.max = max;";s:7:"private";b:1;s:9:"classlike";b:1;s:7:"summary";s:0:"";}s:46:"dijit.form.RangeBoundTextBox.__Constraints.min";a:4:{s:8:"instance";s:42:"dijit.form.RangeBoundTextBox.__Constraints";s:4:"type";s:6:"Number";s:7:"summary";s:43:"Minimum signed value. Default is -Infinity";s:14:"private_parent";b:1;}s:46:"dijit.form.RangeBoundTextBox.__Constraints.max";a:4:{s:8:"instance";s:42:"dijit.form.RangeBoundTextBox.__Constraints";s:4:"type";s:6:"Number";s:7:"summary";s:43:"Maximum signed value. Default is +Infinity";s:14:"private_parent";b:1;}s:10:"dijit.form";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}s:5:"dijit";a:2:{s:4:"type";s:6:"Object";s:7:"summary";s:0:"";}}