3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.form.TimeField"></div>/**
\r
10 * @class Ext.form.TimeField
\r
11 * @extends Ext.form.ComboBox
\r
12 * Provides a time input field with a time dropdown and automatic time validation. Example usage:
\r
14 new Ext.form.TimeField({
\r
15 minValue: '9:00 AM',
\r
16 maxValue: '6:00 PM',
\r
21 * Create a new TimeField
\r
22 * @param {Object} config
\r
25 Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
\r
26 <div id="cfg-Ext.form.TimeField-minValue"></div>/**
\r
27 * @cfg {Date/String} minValue
\r
28 * The minimum allowed time. Can be either a Javascript date object with a valid time value or a string
\r
29 * time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to undefined).
\r
31 minValue : undefined,
\r
32 <div id="cfg-Ext.form.TimeField-maxValue"></div>/**
\r
33 * @cfg {Date/String} maxValue
\r
34 * The maximum allowed time. Can be either a Javascript date object with a valid time value or a string
\r
35 * time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to undefined).
\r
37 maxValue : undefined,
\r
38 <div id="cfg-Ext.form.TimeField-minText"></div>/**
\r
39 * @cfg {String} minText
\r
40 * The error text to display when the date in the cell is before minValue (defaults to
\r
41 * 'The time in this field must be equal to or after {0}').
\r
43 minText : "The time in this field must be equal to or after {0}",
\r
44 <div id="cfg-Ext.form.TimeField-maxText"></div>/**
\r
45 * @cfg {String} maxText
\r
46 * The error text to display when the time is after maxValue (defaults to
\r
47 * 'The time in this field must be equal to or before {0}').
\r
49 maxText : "The time in this field must be equal to or before {0}",
\r
50 <div id="cfg-Ext.form.TimeField-invalidText"></div>/**
\r
51 * @cfg {String} invalidText
\r
52 * The error text to display when the time in the field is invalid (defaults to
\r
53 * '{value} is not a valid time').
\r
55 invalidText : "{0} is not a valid time",
\r
56 <div id="cfg-Ext.form.TimeField-format"></div>/**
\r
57 * @cfg {String} format
\r
58 * The default time format string which can be overriden for localization support. The format must be
\r
59 * valid according to {@link Date#parseDate} (defaults to 'g:i A', e.g., '3:15 PM'). For 24-hour time
\r
60 * format try 'H:i' instead.
\r
63 <div id="cfg-Ext.form.TimeField-altFormats"></div>/**
\r
64 * @cfg {String} altFormats
\r
65 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
\r
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').
\r
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",
\r
69 <div id="cfg-Ext.form.TimeField-increment"></div>/**
\r
70 * @cfg {Number} increment
\r
71 * The number of minutes between each time value in the list (defaults to 15).
\r
78 triggerAction: 'all',
\r
82 // private - This is the date to use when generating time values in the absence of either minValue
\r
83 // or maxValue. Using the current date causes DST issues on DST boundary dates, so this is an
\r
84 // arbitrary "safe" date that can be any date aside from DST boundary dates.
\r
85 initDate: '1/1/2008',
\r
88 initComponent : function(){
\r
89 if(Ext.isDefined(this.minValue)){
\r
90 this.setMinValue(this.minValue, true);
\r
92 if(Ext.isDefined(this.maxValue)){
\r
93 this.setMaxValue(this.maxValue, true);
\r
96 this.generateStore(true);
\r
98 Ext.form.TimeField.superclass.initComponent.call(this);
\r
101 <div id="method-Ext.form.TimeField-setMinValue"></div>/**
\r
102 * Replaces any existing {@link #minValue} with the new time and refreshes the store.
\r
103 * @param {Date/String} value The minimum time that can be selected
\r
105 setMinValue: function(value, /* private */ initial){
\r
106 this.setLimit(value, true, initial);
\r
110 <div id="method-Ext.form.TimeField-setMaxValue"></div>/**
\r
111 * Replaces any existing {@link #maxValue} with the new time and refreshes the store.
\r
112 * @param {Date/String} value The maximum time that can be selected
\r
114 setMaxValue: function(value, /* private */ initial){
\r
115 this.setLimit(value, false, initial);
\r
120 generateStore: function(initial){
\r
121 var min = this.minValue || new Date(this.initDate).clearTime(),
\r
122 max = this.maxValue || new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1),
\r
126 times.push(min.dateFormat(this.format));
\r
127 min = min.add('mi', this.increment);
\r
129 this.bindStore(times, initial);
\r
133 setLimit: function(value, isMin, initial){
\r
135 if(Ext.isString(value)){
\r
136 d = this.parseDate(value);
\r
137 }else if(Ext.isDate(value)){
\r
141 var val = new Date(this.initDate).clearTime();
\r
142 val.setHours(d.getHours(), d.getMinutes(), isMin ? 0 : 59, 0);
\r
143 this[isMin ? 'minValue' : 'maxValue'] = val;
\r
145 this.generateStore();
\r
151 getValue : function(){
\r
152 var v = Ext.form.TimeField.superclass.getValue.call(this);
\r
153 return this.formatDate(this.parseDate(v)) || '';
\r
157 setValue : function(value){
\r
158 return Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
\r
161 // private overrides
\r
162 validateValue : Ext.form.DateField.prototype.validateValue,
\r
163 parseDate : Ext.form.DateField.prototype.parseDate,
\r
164 formatDate : Ext.form.DateField.prototype.formatDate,
\r
167 beforeBlur : function(){
\r
168 var v = this.parseDate(this.getRawValue());
\r
170 this.setValue(v.dateFormat(this.format));
\r
172 Ext.form.TimeField.superclass.beforeBlur.call(this);
\r
175 <div id="cfg-Ext.form.TimeField-grow"></div>/**
\r
176 * @cfg {Boolean} grow @hide
\r
178 <div id="cfg-Ext.form.TimeField-growMin"></div>/**
\r
179 * @cfg {Number} growMin @hide
\r
181 <div id="cfg-Ext.form.TimeField-growMax"></div>/**
\r
182 * @cfg {Number} growMax @hide
\r
184 <div id="method-Ext.form.TimeField-autoSize"></div>/**
\r
189 Ext.reg('timefield', Ext.form.TimeField);</pre>
\r