3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.form.TimeField"></div>/**
\r
9 * @class Ext.form.TimeField
\r
10 * @extends Ext.form.ComboBox
\r
11 * Provides a time input field with a time dropdown and automatic time validation. Example usage:
\r
13 new Ext.form.TimeField({
\r
14 minValue: '9:00 AM',
\r
15 maxValue: '6:00 PM',
\r
20 * Create a new TimeField
\r
21 * @param {Object} config
\r
24 Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
\r
25 <div id="cfg-Ext.form.TimeField-minValue"></div>/**
\r
26 * @cfg {Date/String} minValue
\r
27 * The minimum allowed time. Can be either a Javascript date object with a valid time value or a string
\r
28 * time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to null).
\r
31 <div id="cfg-Ext.form.TimeField-maxValue"></div>/**
\r
32 * @cfg {Date/String} maxValue
\r
33 * The maximum allowed time. Can be either a Javascript date object with a valid time value or a string
\r
34 * time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to null).
\r
37 <div id="cfg-Ext.form.TimeField-minText"></div>/**
\r
38 * @cfg {String} minText
\r
39 * The error text to display when the date in the cell is before minValue (defaults to
\r
40 * 'The time in this field must be equal to or after {0}').
\r
42 minText : "The time in this field must be equal to or after {0}",
\r
43 <div id="cfg-Ext.form.TimeField-maxText"></div>/**
\r
44 * @cfg {String} maxText
\r
45 * The error text to display when the time is after maxValue (defaults to
\r
46 * 'The time in this field must be equal to or before {0}').
\r
48 maxText : "The time in this field must be equal to or before {0}",
\r
49 <div id="cfg-Ext.form.TimeField-invalidText"></div>/**
\r
50 * @cfg {String} invalidText
\r
51 * The error text to display when the time in the field is invalid (defaults to
\r
52 * '{value} is not a valid time').
\r
54 invalidText : "{0} is not a valid time",
\r
55 <div id="cfg-Ext.form.TimeField-format"></div>/**
\r
56 * @cfg {String} format
\r
57 * The default time format string which can be overriden for localization support. The format must be
\r
58 * valid according to {@link Date#parseDate} (defaults to 'g:i A', e.g., '3:15 PM'). For 24-hour time
\r
59 * format try 'H:i' instead.
\r
62 <div id="cfg-Ext.form.TimeField-altFormats"></div>/**
\r
63 * @cfg {String} altFormats
\r
64 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
\r
65 * 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
67 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
68 <div id="cfg-Ext.form.TimeField-increment"></div>/**
\r
69 * @cfg {Number} increment
\r
70 * The number of minutes between each time value in the list (defaults to 15).
\r
77 triggerAction: 'all',
\r
81 // private - This is the date to use when generating time values in the absence of either minValue
\r
82 // or maxValue. Using the current date causes DST issues on DST boundary dates, so this is an
\r
83 // arbitrary "safe" date that can be any date aside from DST boundary dates.
\r
84 initDate: '1/1/2008',
\r
87 initComponent : function(){
\r
88 if(typeof this.minValue == "string"){
\r
89 this.minValue = this.parseDate(this.minValue);
\r
91 if(typeof this.maxValue == "string"){
\r
92 this.maxValue = this.parseDate(this.maxValue);
\r
96 var min = this.parseDate(this.minValue) || new Date(this.initDate).clearTime();
\r
97 var max = this.parseDate(this.maxValue) || new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1);
\r
100 times.push(min.dateFormat(this.format));
\r
101 min = min.add('mi', this.increment);
\r
103 this.store = times;
\r
105 Ext.form.TimeField.superclass.initComponent.call(this);
\r
109 getValue : function(){
\r
110 var v = Ext.form.TimeField.superclass.getValue.call(this);
\r
111 return this.formatDate(this.parseDate(v)) || '';
\r
115 setValue : function(value){
\r
116 return Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
\r
119 // private overrides
\r
120 validateValue : Ext.form.DateField.prototype.validateValue,
\r
121 parseDate : Ext.form.DateField.prototype.parseDate,
\r
122 formatDate : Ext.form.DateField.prototype.formatDate,
\r
125 beforeBlur : function(){
\r
126 var v = this.parseDate(this.getRawValue());
\r
128 this.setValue(v.dateFormat(this.format));
\r
130 Ext.form.TimeField.superclass.beforeBlur.call(this);
\r
133 <div id="cfg-Ext.form.TimeField-grow"></div>/**
\r
134 * @cfg {Boolean} grow @hide
\r
136 <div id="cfg-Ext.form.TimeField-growMin"></div>/**
\r
137 * @cfg {Number} growMin @hide
\r
139 <div id="cfg-Ext.form.TimeField-growMax"></div>/**
\r
140 * @cfg {Number} growMax @hide
\r
142 <div id="method-Ext.form.TimeField-autoSize"></div>/**
\r
147 Ext.reg('timefield', Ext.form.TimeField);</pre>
\r