2
* Ext JS Library 3.0 RC2
3
* Copyright(c) 2006-2009, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.form.TimeField
11
* @extends Ext.form.ComboBox
12
* Provides a time input field with a time dropdown and automatic time validation. Example usage:
14
new Ext.form.TimeField({
21
* Create a new TimeField
22
* @param {Object} config
25
Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
27
* @cfg {Date/String} minValue
28
* The minimum allowed time. Can be either a Javascript date object with a valid time value or a string
29
* time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to null).
33
* @cfg {Date/String} maxValue
34
* The maximum allowed time. Can be either a Javascript date object with a valid time value or a string
35
* time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to null).
39
* @cfg {String} minText
40
* The error text to display when the date in the cell is before minValue (defaults to
41
* 'The time in this field must be equal to or after {0}').
43
minText : "The time in this field must be equal to or after {0}",
45
* @cfg {String} maxText
46
* The error text to display when the time is after maxValue (defaults to
47
* 'The time in this field must be equal to or before {0}').
49
maxText : "The time in this field must be equal to or before {0}",
51
* @cfg {String} invalidText
52
* The error text to display when the time in the field is invalid (defaults to
53
* '{value} is not a valid time').
55
invalidText : "{0} is not a valid time",
57
* @cfg {String} format
58
* The default time format string which can be overriden for localization support. The format must be
59
* valid according to {@link Date#parseDate} (defaults to 'g:i A', e.g., '3:15 PM'). For 24-hour time
60
* format try 'H:i' instead.
64
* @cfg {String} altFormats
65
* Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
66
* format (defaults to 'g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H').
68
altFormats : "g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H",
70
* @cfg {Number} increment
71
* The number of minutes between each time value in the list (defaults to 15).
82
// private - This is the date to use when generating time values in the absence of either minValue
83
// or maxValue. Using the current date causes DST issues on DST boundary dates, so this is an
84
// arbitrary "safe" date that can be any date aside from DST boundary dates.
88
initComponent : function(){
89
Ext.form.TimeField.superclass.initComponent.call(this);
91
if(typeof this.minValue == "string"){
92
this.minValue = this.parseDate(this.minValue);
94
if(typeof this.maxValue == "string"){
95
this.maxValue = this.parseDate(this.maxValue);
99
var min = this.parseDate(this.minValue);
101
min = new Date(this.initDate).clearTime();
103
var max = this.parseDate(this.maxValue);
105
max = new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1);
109
times.push([min.dateFormat(this.format)]);
110
min = min.add('mi', this.increment);
112
this.store = new Ext.data.ArrayStore({
116
this.displayField = 'text';
121
getValue : function(){
122
var v = Ext.form.TimeField.superclass.getValue.call(this);
123
return this.formatDate(this.parseDate(v)) || '';
127
setValue : function(value){
128
return Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
132
validateValue : Ext.form.DateField.prototype.validateValue,
133
parseDate : Ext.form.DateField.prototype.parseDate,
134
formatDate : Ext.form.DateField.prototype.formatDate,
137
beforeBlur : function(){
138
var v = this.parseDate(this.getRawValue());
140
this.setValue(v.dateFormat(this.format));
142
Ext.form.TimeField.superclass.beforeBlur.call(this);
146
* @cfg {Boolean} grow @hide
149
* @cfg {Number} growMin @hide
152
* @cfg {Number} growMax @hide
159
Ext.reg('timefield', Ext.form.TimeField);
b'\\ No newline at end of file'