+++ /dev/null
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.form.TimeField\r
- * @extends Ext.form.ComboBox\r
- * Provides a time input field with a time dropdown and automatic time validation. Example usage:\r
- * <pre><code>\r
-new Ext.form.TimeField({\r
- minValue: '9:00 AM',\r
- maxValue: '6:00 PM',\r
- increment: 30\r
-});\r
-</code></pre>\r
- * @constructor\r
- * Create a new TimeField\r
- * @param {Object} config\r
- */\r
-Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {\r
- /**\r
- * @cfg {Date/String} minValue\r
- * The minimum allowed time. Can be either a Javascript date object with a valid time value or a string \r
- * time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to null).\r
- */\r
- minValue : null,\r
- /**\r
- * @cfg {Date/String} maxValue\r
- * The maximum allowed time. Can be either a Javascript date object with a valid time value or a string \r
- * time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to null).\r
- */\r
- maxValue : null,\r
- /**\r
- * @cfg {String} minText\r
- * The error text to display when the date in the cell is before minValue (defaults to\r
- * 'The time in this field must be equal to or after {0}').\r
- */\r
- minText : "The time in this field must be equal to or after {0}",\r
- /**\r
- * @cfg {String} maxText\r
- * The error text to display when the time is after maxValue (defaults to\r
- * 'The time in this field must be equal to or before {0}').\r
- */\r
- maxText : "The time in this field must be equal to or before {0}",\r
- /**\r
- * @cfg {String} invalidText\r
- * The error text to display when the time in the field is invalid (defaults to\r
- * '{value} is not a valid time').\r
- */\r
- invalidText : "{0} is not a valid time",\r
- /**\r
- * @cfg {String} format\r
- * The default time format string which can be overriden for localization support. The format must be\r
- * valid according to {@link Date#parseDate} (defaults to 'g:i A', e.g., '3:15 PM'). For 24-hour time\r
- * format try 'H:i' instead.\r
- */\r
- format : "g:i A",\r
- /**\r
- * @cfg {String} altFormats\r
- * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined\r
- * 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
- */\r
- 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
- /**\r
- * @cfg {Number} increment\r
- * The number of minutes between each time value in the list (defaults to 15).\r
- */\r
- increment: 15,\r
-\r
- // private override\r
- mode: 'local',\r
- // private override\r
- triggerAction: 'all',\r
- // private override\r
- typeAhead: false,\r
- \r
- // private - This is the date to use when generating time values in the absence of either minValue\r
- // or maxValue. Using the current date causes DST issues on DST boundary dates, so this is an \r
- // arbitrary "safe" date that can be any date aside from DST boundary dates.\r
- initDate: '1/1/2008',\r
-\r
- // private\r
- initComponent : function(){\r
- Ext.form.TimeField.superclass.initComponent.call(this);\r
-\r
- if(typeof this.minValue == "string"){\r
- this.minValue = this.parseDate(this.minValue);\r
- }\r
- if(typeof this.maxValue == "string"){\r
- this.maxValue = this.parseDate(this.maxValue);\r
- }\r
-\r
- if(!this.store){\r
- var min = this.parseDate(this.minValue);\r
- if(!min){\r
- min = new Date(this.initDate).clearTime();\r
- }\r
- var max = this.parseDate(this.maxValue);\r
- if(!max){\r
- max = new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1);\r
- }\r
- var times = [];\r
- while(min <= max){\r
- times.push([min.dateFormat(this.format)]);\r
- min = min.add('mi', this.increment);\r
- }\r
- this.store = new Ext.data.SimpleStore({\r
- fields: ['text'],\r
- data : times\r
- });\r
- this.displayField = 'text';\r
- }\r
- },\r
-\r
- // inherited docs\r
- getValue : function(){\r
- var v = Ext.form.TimeField.superclass.getValue.call(this);\r
- return this.formatDate(this.parseDate(v)) || '';\r
- },\r
-\r
- // inherited docs\r
- setValue : function(value){\r
- Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));\r
- },\r
-\r
- // private overrides\r
- validateValue : Ext.form.DateField.prototype.validateValue,\r
- parseDate : Ext.form.DateField.prototype.parseDate,\r
- formatDate : Ext.form.DateField.prototype.formatDate,\r
-\r
- // private\r
- beforeBlur : function(){\r
- var v = this.parseDate(this.getRawValue());\r
- if(v){\r
- this.setValue(v.dateFormat(this.format));\r
- }\r
- }\r
-\r
- /**\r
- * @cfg {Boolean} grow @hide\r
- */\r
- /**\r
- * @cfg {Number} growMin @hide\r
- */\r
- /**\r
- * @cfg {Number} growMax @hide\r
- */\r
- /**\r
- * @hide\r
- * @method autoSize\r
- */\r
-});\r
-Ext.reg('timefield', Ext.form.TimeField);
\ No newline at end of file