Blame | Last modification | View Log | RSS feed
if(!dojo._hasResource["dijit.form.TimeTextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dijit.form.TimeTextBox"] = true;dojo.provide("dijit.form.TimeTextBox");dojo.require("dojo.date");dojo.require("dojo.date.locale");dojo.require("dojo.date.stamp");dojo.require("dijit._TimePicker");dojo.require("dijit.form.ValidationTextBox");dojo.declare("dijit.form.TimeTextBox",dijit.form.RangeBoundTextBox,{// summary:// A validating, serializable, range-bound date text box.// constraints object: min, maxregExpGen: dojo.date.locale.regexp,compare: dojo.date.compare,format: function(/*Date*/ value, /*Object*/ constraints){if(!value || value.toString() == this._invalid){ return null; }return dojo.date.locale.format(value, constraints);},parse: dojo.date.locale.parse,serialize: dojo.date.stamp.toISOString,value: new Date(""), // NaN_invalid: (new Date("")).toString(), // NaN_popupClass: "dijit._TimePicker",postMixInProperties: function(){//dijit.form.RangeBoundTextBox.prototype.postMixInProperties.apply(this, arguments);this.inherited("postMixInProperties",arguments);var constraints = this.constraints;constraints.selector = 'time';if(typeof constraints.min == "string"){ constraints.min = dojo.date.stamp.fromISOString(constraints.min); }if(typeof constraints.max == "string"){ constraints.max = dojo.date.stamp.fromISOString(constraints.max); }},_onFocus: function(/*Event*/ evt){// summary: open the TimePicker popupthis._open();},setValue: function(/*Date*/ value, /*Boolean, optional*/ priorityChange){// summary:// Sets the date on this textboxthis.inherited('setValue', arguments);if(this._picker){// #3948: fix blank date on popup onlyif(!value || value.toString() == this._invalid){value=new Date();}this._picker.setValue(value);}},_open: function(){// summary:// opens the TimePicker, and sets the onValueSelected valueif(this.disabled){return;}var self = this;if(!this._picker){var popupProto=dojo.getObject(this._popupClass, false);this._picker = new popupProto({onValueSelected: function(value){self.focus(); // focus the textbox before the popup closes to avoid reopening the popupsetTimeout(dojo.hitch(self, "_close"), 1); // allow focus time to take// this will cause InlineEditBox and other handlers to do stuff so make sure it's lastdijit.form.TimeTextBox.superclass.setValue.call(self, value, true);},lang: this.lang,constraints:this.constraints,isDisabledDate: function(/*Date*/ date){// summary:// disables dates outside of the min/max of the TimeTextBoxreturn self.constraints && (dojo.date.compare(self.constraints.min,date) > 0 || dojo.date.compare(self.constraints.max,date) < 0);}});this._picker.setValue(this.getValue() || new Date());}if(!this._opened){dijit.popup.open({parent: this,popup: this._picker,around: this.domNode,onCancel: dojo.hitch(this, this._close),onClose: function(){ self._opened=false; }});this._opened=true;}dojo.marginBox(this._picker.domNode,{ w:this.domNode.offsetWidth });},_close: function(){if(this._opened){dijit.popup.close(this._picker);this._opened=false;}},_onBlur: function(){// summary: called magically when focus has shifted away from this widget and it's dropdownthis._close();this.inherited('_onBlur', arguments);// don't focus on <input>. the user has explicitly focused on something else.},getDisplayedValue:function(){return this.textbox.value;},setDisplayedValue:function(/*String*/ value){this.textbox.value=value;}});}