Changeset 9697
- Timestamp:
- 07/18/07 00:43:21 (18 months ago)
- Location:
- dijit/trunk
- Files:
-
- 3 added
- 2 modified
-
form/DateTextbox.js (modified) (1 diff)
-
form/templates/TimePicker.html (added)
-
form/TimeTextbox.js (added)
-
form/_TimePicker.js (added)
-
tests/form/test_validate.html (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dijit/trunk/form/DateTextbox.js
r9638 r9697 2 2 3 3 dojo.require("dijit._Calendar"); 4 dojo.require("dijit.util.popup"); 5 dojo.require("dojo.date"); 6 dojo.require("dojo.date.locale"); 7 dojo.require("dojo.date.stamp"); 8 dojo.require("dijit.form.ValidationTextbox"); 4 dojo.require("dijit.form.TimeTextbox"); 9 5 10 6 dojo.declare( 11 7 "dijit.form.DateTextbox", 12 dijit.form. RangeBoundTextbox,8 dijit.form.TimeTextbox, 13 9 { 14 10 // summary: 15 11 // A validating, serializable, range-bound date text box. 16 17 // constraints object: min, max 18 regExpGen: dojo.date.locale.regexp, 19 compare: dojo.date.compare, 20 format: dojo.date.locale.format, 21 parse: dojo.date.locale.parse, 22 value: new Date(), 23 12 13 _popupClass: "dijit._Calendar", 14 24 15 postMixInProperties: function(){ 25 dijit.form.RangeBoundTextbox.prototype.postMixInProperties.apply(this, arguments);16 this.inherited('postMixInProperties', arguments); 26 17 27 18 // #3407: only change constraints after postMixInProperties or ValidationTextbox will clear the change 28 19 this.constraints.selector = 'date'; 29 30 // #299931 if(typeof this.constraints.min == "string"){ this.constraints.min = dojo.date.stamp.fromISOString(this.constraints.min); }32 if(typeof this.constraints.max == "string"){ this.constraints.max = dojo.date.stamp.fromISOString(this.constraints.max); }33 },34 35 onfocus: function(/*Event*/ evt){36 // open the calendar37 this._open();38 dijit.form.RangeBoundTextbox.prototype.onfocus.apply(this, arguments);39 },40 41 serialize: function(/*Date*/date){42 return dojo.date.stamp.toISOString(date, 'date'); // String43 },44 45 setValue: function(/*Date*/date, /*Boolean, optional*/ priorityChange){46 // summary:47 // Sets the date on this textbox48 this.inherited('setValue', arguments);49 if(this._calendar){50 this._calendar.setValue(date);51 }52 },53 54 _open: function(){55 // summary:56 // opens the Calendar, and sets the onValueSelected for the Calendar57 var self = this;58 59 if(!this._calendar){60 this._calendar = new dijit._Calendar({61 onValueSelected: function(value){62 63 self.focus(); // focus the textbox before the popup closes to avoid reopening the popup64 setTimeout(dijit.util.popup.close, 1); // allow focus time to take65 66 // this will cause InlineEditBox and other handlers to do stuff so make sure it's last67 dijit.form.DateTextbox.superclass.setValue.call(self, value, true);68 },69 lang: this.lang,70 isDisabledDate: function(/*Date*/ date){71 // summary:72 // disables dates outside of the min/max of the DateTextbox73 return self.constraints && (dojo.date.compare(self.constraints.min,date) > 0 || dojo.date.compare(self.constraints.max,date) < 0);74 }75 });76 this._calendar.setValue(this.getValue() || new Date());77 }78 if(!this._opened){79 dijit.util.popup.open({80 host: this,81 popup: this._calendar,82 around: this.domNode,83 onClose: function(){ self._opened=false; }84 });85 this._opened=true;86 }87 },88 89 _onBlur: function(){90 // summary: called magically when focus has shifted away from this widget and it's dropdown91 dijit.util.popup.closeAll();92 this.inherited('_onBlur', arguments);93 // don't focus on <input>. the user has explicitly focused on something else.94 },95 96 postCreate: function(){97 this.inherited('postCreate', arguments);98 this.connect(this.domNode, "onclick", this._open);99 },100 101 getDisplayedValue:function(){102 return this.textbox.value;103 },104 105 setDisplayedValue:function(/*String*/ value){106 this.textbox.value=value;107 20 } 108 21 } -
dijit/trunk/tests/form/test_validate.html
r9627 r9697 15 15 dojo.require("dijit.form.CurrencyTextbox"); 16 16 dojo.require("dijit.form.DateTextbox"); 17 dojo.require("dijit.form.TimeTextbox"); 17 18 // dojo.require("dojo.validate.common"); 18 19 // dojo.require("dojo.validate.us"); … … 407 408 </div> 408 409 <div class="testExample"> 409 <input id="q16" type="text" name="time1" class="medium" value="5:45:00 pm" 410 dojoType="dijit.form.ValidationTextbox" 411 validator="dojo.date.locale.parse" 410 <input id="q16" type="text" name="time1" class="medium" value="T17:45:00" 411 dojoType="dijit.form.TimeTextbox" 412 412 constraints={formatLength:'medium',selector:'time'} 413 trim="true"414 413 required="true" 415 414 invalidMessage="Invalid time." /> … … 422 421 </div> 423 422 <div class="testExample"> 424 <input id="q17" type="text" name="time2" class="medium" value="17:45:00" 425 dojoType="dijit.form.ValidationTextbox" 426 validator="dojo.date.locale.parse" 423 <input id="q17" type="text" name="time2" class="medium" value="T17:45:00" 424 dojoType="dijit.form.TimeTextbox" 427 425 constraints={formatLength:'short',selector:'time',timePattern:'HH:mm:ss'} 428 trim="true"429 426 required="true" 430 427 invalidMessage="Invalid time. Use HH:mm:ss where HH is 00 - 23 hours.">