Changeset 12918
- Timestamp:
- 03/05/08 19:01:39 (10 months ago)
- Location:
- dijit/trunk/form
- Files:
-
- 5 modified
-
DateTextBox.js (modified) (1 diff)
-
TextBox.js (modified) (2 diffs)
-
TimeTextBox.js (modified) (1 diff)
-
ValidationTextBox.js (modified) (12 diffs)
-
_DateTimeTextBox.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dijit/trunk/form/DateTextBox.js
r11916 r12918 9 9 { 10 10 // summary: 11 // A validating, serializable, range-bound date text box .11 // A validating, serializable, range-bound date text box with a popup calendar 12 12 13 13 popupClass: "dijit._Calendar", -
dijit/trunk/form/TextBox.js
r12710 r12918 38 38 39 39 getDisplayedValue: function(){ 40 // summary: 41 // returns the formatted value that the user sees in the textbox, which may be different 42 // from the serialized value that's actually sent to the server (see dijit.form.ValidationTextBox.serialize) 40 43 return this.filter(this.textbox.value); 41 44 }, … … 85 88 86 89 filter: function(val){ 87 // summary: Apply variousfilters to textbox value90 // summary: Apply specified filters to textbox value 88 91 if(val === null || val === undefined){ return ""; } 89 92 else if(typeof val != "string"){ return val; } -
dijit/trunk/form/TimeTextBox.js
r11916 r12918 9 9 { 10 10 // summary: 11 // A validating, serializable, range-bound time text box .11 // A validating, serializable, range-bound time text box with a popup time picker 12 12 13 13 popupClass: "dijit._TimePicker", -
dijit/trunk/form/ValidationTextBox.js
r12731 r12918 7 7 8 8 dojo.requireLocalization("dijit.form", "validate"); 9 10 /*===== 11 dijit.form.ValidationTextBox.__Constraints = function(){ 12 // locale: String 13 // locale used for validation, picks up value from this widget's lang attribute 14 // _flags_: anything 15 // various flags passed to regExpGen function 16 this.locale = ""; 17 this._flags_ = ""; 18 } 19 =====*/ 9 20 10 21 dojo.declare( … … 32 43 invalidMessage: "$_unset_$", // read from the message file if not overridden 33 44 34 // constraints: Object45 // constraints: dijit.form.ValidationTextBox.__Constraints 35 46 // user-defined object needed to pass parameters to the validator functions 36 47 constraints: {}, … … 44 55 // user replaceable function used to generate regExp when dependent on constraints 45 56 // Do not specify both regExp and regExpGen 46 regExpGen: function( constraints){ return this.regExp; },57 regExpGen: function(/*dijit.form.ValidationTextBox.__Constraints*/constraints){ return this.regExp; }, 47 58 48 59 // state: String … … 59 70 }, 60 71 61 validator: function( value,constraints){72 validator: function(/*anything*/value, /*dijit.form.ValidationTextBox.__Constraints*/constraints){ 62 73 // summary: user replaceable function used to validate the text input against the regular expression. 63 74 return (new RegExp("^(" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) && … … 66 77 }, 67 78 68 isValid: function(/* Boolean*/ isFocused){79 isValid: function(/*Boolean*/ isFocused){ 69 80 // summary: Need to over-ride with your own validation code in subclasses 70 81 return this.validator(this.textbox.value, this.constraints); … … 76 87 }, 77 88 78 getErrorMessage: function(/* Boolean*/ isFocused){89 getErrorMessage: function(/*Boolean*/ isFocused){ 79 90 // summary: return an error message to show if appropriate 80 91 return this.invalidMessage; 81 92 }, 82 93 83 getPromptMessage: function(/* Boolean*/ isFocused){94 getPromptMessage: function(/*Boolean*/ isFocused){ 84 95 // summary: return a hint to show if appropriate 85 96 return this.promptMessage; 86 97 }, 87 98 88 validate: function(/* Boolean*/ isFocused){99 validate: function(/*Boolean*/ isFocused){ 89 100 // summary: 90 101 // Called by oninit, onblur, and onkeypress. … … 158 169 // Provides a hidden input field and a serialize method to override 159 170 160 serialize: function( val, /*Object?*/options){171 serialize: function(/*anything*/val, /*Object?*/options){ 161 172 // summary: user replaceable function used to convert the getValue() result to a String 162 return val.toString ? val.toString() : ""; 173 return val.toString ? val.toString() : ""; // String 163 174 }, 164 175 … … 166 177 // summary: display the widget as a printable string using the widget's value 167 178 var val = this.filter(this.getValue()); 168 return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; 179 return val != null ? (typeof val == "string" ? val : this.serialize(val, this.constraints)) : ""; // String 169 180 }, 170 181 … … 201 212 ); 202 213 214 /*===== 215 dijit.form.RangeBoundTextBox.__Constraints = function(){ 216 // min: Number 217 // Minimum signed value. Default is -Infinity 218 // max: Number 219 // Maximum signed value. Default is +Infinity 220 this.min = min; 221 this.max = max; 222 } 223 =====*/ 224 203 225 dojo.declare( 204 226 "dijit.form.RangeBoundTextBox", … … 208 230 // A subclass of MappedTextBox. 209 231 // Tests for a value out-of-range 210 /*===== contraints object: 211 // min: Number 212 // Minimum signed value. Default is -Infinity 213 min: undefined, 214 // max: Number 215 // Maximum signed value. Default is +Infinity 216 max: undefined, 217 =====*/ 218 232 // 233 // constraints: dijit.form.RangeBoundTextBox.__Constraints 234 // 219 235 // rangeMessage: String 220 236 // The message to display if value is out-of-range 221 237 rangeMessage: "", 222 238 223 compare: function( val1,val2){239 compare: function(/*anything*/val1, /*anything*/val2){ 224 240 // summary: compare 2 values 225 241 return val1 - val2; 226 242 }, 227 243 228 rangeCheck: function(/* Number */ primitive, /* Object*/ constraints){244 rangeCheck: function(/*Number*/ primitive, /*dijit.form.RangeBoundTextBox.__Constraints*/ constraints){ 229 245 // summary: user replaceable function used to validate the range of the numeric input value 230 246 var isMin = (constraints.min !== undefined); … … 234 250 (!isMax || this.compare(primitive,constraints.max) <= 0); 235 251 } 236 return true; 237 }, 238 239 isInRange: function(/* Boolean*/ isFocused){252 return true; // Boolean 253 }, 254 255 isInRange: function(/*Boolean*/ isFocused){ 240 256 // summary: Need to over-ride with your own validation code in subclasses 241 257 return this.rangeCheck(this.getValue(), this.constraints); 242 258 }, 243 259 244 isValid: function(/* Boolean*/ isFocused){260 isValid: function(/*Boolean*/ isFocused){ 245 261 return this.inherited(arguments) && 246 ((this._isEmpty(this.textbox.value) && !this.required) || this.isInRange(isFocused)); 247 }, 248 249 getErrorMessage: function(/* Boolean*/ isFocused){250 if(dijit.form.RangeBoundTextBox.superclass.isValid.call(this, false) && !this.isInRange(isFocused)){ return this.rangeMessage; } 262 ((this._isEmpty(this.textbox.value) && !this.required) || this.isInRange(isFocused)); // Boolean 263 }, 264 265 getErrorMessage: function(/*Boolean*/ isFocused){ 266 if(dijit.form.RangeBoundTextBox.superclass.isValid.call(this, false) && !this.isInRange(isFocused)){ return this.rangeMessage; } // String 251 267 return this.inherited(arguments); 252 268 }, … … 270 286 }, 271 287 272 setValue: function(/*Number*/ value, /*Boolean , optional*/ priorityChange){288 setValue: function(/*Number*/ value, /*Boolean?*/ priorityChange){ 273 289 dijit.setWaiState(this.focusNode, "valuenow", value); 274 290 this.inherited('setValue', arguments); -
dijit/trunk/form/_DateTimeTextBox.js
r12736 r12918 6 6 dojo.require("dijit.form.ValidationTextBox"); 7 7 8 /*===== 9 dojo.declare( 10 "dijit.form._DateTimeTextBox.__Constraints", 11 [dijit.form.RangeBoundTextBox.__Constraints, dojo.date.locale.__FormatOptions], 12 {} 13 ); 14 =====*/ 15 8 16 dojo.declare( 9 17 "dijit.form._DateTimeTextBox", … … 12 20 // summary: 13 21 // A validating, serializable, range-bound date or time text box. 22 // 23 // constraints: dijit.form._DateTimeTextBox.__Constraints 14 24 15 // constraints object: min, max16 25 regExpGen: dojo.date.locale.regexp, 17 26 compare: dojo.date.compare, 18 format: function(/*Date*/ value, /* Object*/ constraints){27 format: function(/*Date*/ value, /*dijit.form._DateTimeTextBox.__Constraints*/ constraints){ 19 28 if(!value){ return ''; } 20 29 return dojo.date.locale.format(value, constraints); 21 30 }, 22 parse: function(/*String*/ value, /* Object*/ constraints){31 parse: function(/*String*/ value, /*dijit.form._DateTimeTextBox.__Constraints*/ constraints){ 23 32 return dojo.date.locale.parse(value, constraints) || undefined; /* can't return null to getValue since that's special */ 24 33 }, … … 72 81 73 82 if(!this._picker){ 74 var popupProto=dojo.getObject(this.popupClass, false);75 this._picker = new popupProto({83 var PopupProto=dojo.getObject(this.popupClass, false); 84 this._picker = new PopupProto({ 76 85 onValueSelected: function(value){ 77 86 … … 144 153 }, 145 154 146 _onKeyPress: function( e){155 _onKeyPress: function(/*Event*/e){ 147 156 if(dijit.form._DateTimeTextBox.superclass._onKeyPress.apply(this, arguments)){ 148 157 if(this._opened && e.keyCode == dojo.keys.ESCAPE && !e.shiftKey && !e.ctrlKey && !e.altKey){