1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
<html>
<head>
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
* Ext JS Library 3.0.3
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
<div id="cls-Ext.form.TimeField"></div>/**
* @class Ext.form.TimeField
* @extends Ext.form.ComboBox
* Provides a time input field with a time dropdown and automatic time validation. Example usage:
* <pre><code>
new Ext.form.TimeField({
minValue: '9:00 AM',
maxValue: '6:00 PM',
increment: 30
});
</code></pre>
* @constructor
* Create a new TimeField
* @param {Object} config
* @xtype timefield
*/
Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
<div id="cfg-Ext.form.TimeField-minValue"></div>/**
* @cfg {Date/String} minValue
* The minimum allowed time. Can be either a Javascript date object with a valid time value or a string
* time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to null).
*/
minValue : null,
<div id="cfg-Ext.form.TimeField-maxValue"></div>/**
* @cfg {Date/String} maxValue
* The maximum allowed time. Can be either a Javascript date object with a valid time value or a string
* time in a valid format -- see {@link #format} and {@link #altFormats} (defaults to null).
*/
maxValue : null,
<div id="cfg-Ext.form.TimeField-minText"></div>/**
* @cfg {String} minText
* The error text to display when the date in the cell is before minValue (defaults to
* 'The time in this field must be equal to or after {0}').
*/
minText : "The time in this field must be equal to or after {0}",
<div id="cfg-Ext.form.TimeField-maxText"></div>/**
* @cfg {String} maxText
* The error text to display when the time is after maxValue (defaults to
* 'The time in this field must be equal to or before {0}').
*/
maxText : "The time in this field must be equal to or before {0}",
<div id="cfg-Ext.form.TimeField-invalidText"></div>/**
* @cfg {String} invalidText
* The error text to display when the time in the field is invalid (defaults to
* '{value} is not a valid time').
*/
invalidText : "{0} is not a valid time",
<div id="cfg-Ext.form.TimeField-format"></div>/**
* @cfg {String} format
* The default time format string which can be overriden for localization support. The format must be
* valid according to {@link Date#parseDate} (defaults to 'g:i A', e.g., '3:15 PM'). For 24-hour time
* format try 'H:i' instead.
*/
format : "g:i A",
<div id="cfg-Ext.form.TimeField-altFormats"></div>/**
* @cfg {String} altFormats
* Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
* 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').
*/
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",
<div id="cfg-Ext.form.TimeField-increment"></div>/**
* @cfg {Number} increment
* The number of minutes between each time value in the list (defaults to 15).
*/
increment: 15,
// private override
mode: 'local',
// private override
triggerAction: 'all',
// private override
typeAhead: false,
// private - This is the date to use when generating time values in the absence of either minValue
// or maxValue. Using the current date causes DST issues on DST boundary dates, so this is an
// arbitrary "safe" date that can be any date aside from DST boundary dates.
initDate: '1/1/2008',
// private
initComponent : function(){
if(typeof this.minValue == "string"){
this.minValue = this.parseDate(this.minValue);
}
if(typeof this.maxValue == "string"){
this.maxValue = this.parseDate(this.maxValue);
}
if(!this.store){
var min = this.parseDate(this.minValue) || new Date(this.initDate).clearTime();
var max = this.parseDate(this.maxValue) || new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1);
var times = [];
while(min <= max){
times.push(min.dateFormat(this.format));
min = min.add('mi', this.increment);
}
this.store = times;
}
Ext.form.TimeField.superclass.initComponent.call(this);
},
// inherited docs
getValue : function(){
var v = Ext.form.TimeField.superclass.getValue.call(this);
return this.formatDate(this.parseDate(v)) || '';
},
// inherited docs
setValue : function(value){
return Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
},
// private overrides
validateValue : Ext.form.DateField.prototype.validateValue,
parseDate : Ext.form.DateField.prototype.parseDate,
formatDate : Ext.form.DateField.prototype.formatDate,
// private
beforeBlur : function(){
var v = this.parseDate(this.getRawValue());
if(v){
this.setValue(v.dateFormat(this.format));
}
Ext.form.TimeField.superclass.beforeBlur.call(this);
}
<div id="cfg-Ext.form.TimeField-grow"></div>/**
* @cfg {Boolean} grow @hide
*/
<div id="cfg-Ext.form.TimeField-growMin"></div>/**
* @cfg {Number} growMin @hide
*/
<div id="cfg-Ext.form.TimeField-growMax"></div>/**
* @cfg {Number} growMax @hide
*/
<div id="method-Ext.form.TimeField-autoSize"></div>/**
* @hide
* @method autoSize
*/
});
Ext.reg('timefield', Ext.form.TimeField);</pre>
</body>
</html>
|