source: Dev/trunk/src/client/dijit/form/TimeTextBox.js @ 483

Last change on this file since 483 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 2.7 KB
Line 
1define([
2        "dojo/_base/declare", // declare
3        "dojo/keys", // keys.DOWN_ARROW keys.ENTER keys.ESCAPE keys.TAB keys.UP_ARROW
4        "dojo/_base/lang", // lang.hitch
5        "../_TimePicker",
6        "./_DateTimeTextBox"
7], function(declare, keys, lang, _TimePicker, _DateTimeTextBox){
8
9        // module:
10        //              dijit/form/TimeTextBox
11
12
13        /*=====
14        var __Constraints = declare([_DateTimeTextBox.__Constraints, _TimePicker.__Constraints], {
15        });
16        =====*/
17
18        return declare("dijit.form.TimeTextBox", _DateTimeTextBox, {
19                // summary:
20                //              A validating, serializable, range-bound time text box with a drop down time picker
21
22                baseClass: "dijitTextBox dijitComboBox dijitTimeTextBox",
23                popupClass: _TimePicker,
24                _selector: "time",
25
26/*=====
27                // constraints: __Constraints
28                constraints:{},
29=====*/
30
31                // value: Date
32                //              The value of this widget as a JavaScript Date object.  Note that the date portion implies time zone and daylight savings rules.
33                //
34                //              Example:
35                // |    new dijit/form/TimeTextBox({value: stamp.fromISOString("T12:59:59", new Date())})
36                //
37                //              When passed to the parser in markup, must be specified according to locale-independent
38                //              `stamp.fromISOString` format.
39                //
40                //              Example:
41                // |    <input data-dojo-type='dijit/form/TimeTextBox' value='T12:34:00'>
42                value: new Date(""),            // value.toString()="NaN"
43                //FIXME: in markup, you have no control over daylight savings
44
45                // Add scrollbars if necessary so that dropdown doesn't cover the <input>
46                maxHeight: -1,
47
48                _onKey: function(evt){
49                        if(this.disabled || this.readOnly){ return; }
50                        this.inherited(arguments);
51
52                        // If the user has backspaced or typed some numbers, then filter the result list
53                        // by what they typed.  Maybe there's a better way to detect this, like _handleOnChange()?
54                        switch(evt.keyCode){
55                                case keys.ENTER:
56                                case keys.TAB:
57                                case keys.ESCAPE:
58                                case keys.DOWN_ARROW:
59                                case keys.UP_ARROW:
60                                        // these keys have special meaning
61                                        break;
62                                default:
63                                        // defer() because the keystroke hasn't yet appeared in the <input>,
64                                        // so the get('displayedValue') call below won't give the result we want.
65                                        this.defer(function(){
66                                                // set this.filterString to the filter to apply to the drop down list;
67                                                // it will be used in openDropDown()
68                                                var val = this.get('displayedValue');
69                                                this.filterString = (val && !this.parse(val, this.constraints)) ? val.toLowerCase() : "";
70
71                                                // close the drop down and reopen it, in order to filter the items shown in the list
72                                                // and also since the drop down may need to be repositioned if the number of list items has changed
73                                                // and it's being displayed above the <input>
74                                                if(this._opened){
75                                                        this.closeDropDown();
76                                                }
77                                                this.openDropDown();
78                                        });
79                        }
80                }
81        });
82});
Note: See TracBrowser for help on using the repository browser.