]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/TimeTextBox.js
upgrade Dojo to 1.6.1
[tt-rss.git] / lib / dijit / form / TimeTextBox.js
1 /*
2 Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
5 */
6
7
8 if(!dojo._hasResource["dijit.form.TimeTextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
9 dojo._hasResource["dijit.form.TimeTextBox"] = true;
10 dojo.provide("dijit.form.TimeTextBox");
11 dojo.require("dijit._TimePicker");
12 dojo.require("dijit.form._DateTimeTextBox");
13
14
15 /*=====
16 dojo.declare(
17 "dijit.form.TimeTextBox.__Constraints",
18 [dijit.form._DateTimeTextBox.__Constraints, dijit._TimePicker.__Constraints]
19 );
20 =====*/
21
22 dojo.declare(
23 "dijit.form.TimeTextBox",
24 dijit.form._DateTimeTextBox,
25 {
26 // summary:
27 // A validating, serializable, range-bound time text box with a drop down time picker
28
29 baseClass: "dijitTextBox dijitComboBox dijitTimeTextBox",
30 popupClass: "dijit._TimePicker",
31 _selector: "time",
32
33 /*=====
34 // constraints: dijit.form.TimeTextBox.__Constraints
35 constraints:{},
36 =====*/
37
38 // value: Date
39 // The value of this widget as a JavaScript Date object. Note that the date portion implies time zone and daylight savings rules.
40 //
41 // Example:
42 // | new dijit.form.TimeTextBox({value: dojo.date.stamp.fromISOString("T12:59:59", new Date())})
43 //
44 // When passed to the parser in markup, must be specified according to locale-independent
45 // `dojo.date.stamp.fromISOString` format.
46 //
47 // Example:
48 // | <input dojotype='dijit.form.TimeTextBox' value='T12:34:00'>
49 value: new Date(""), // value.toString()="NaN"
50 //FIXME: in markup, you have no control over daylight savings
51
52 _onKey: function(evt){
53 this.inherited(arguments);
54
55 // If the user has backspaced or typed some numbers, then filter the result list
56 // by what they typed. Maybe there's a better way to detect this, like _handleOnChange()?
57 switch(evt.keyCode){
58 case dojo.keys.ENTER:
59 case dojo.keys.TAB:
60 case dojo.keys.ESCAPE:
61 case dojo.keys.DOWN_ARROW:
62 case dojo.keys.UP_ARROW:
63 // these keys have special meaning
64 break;
65 default:
66 // setTimeout() because the keystroke hasn't yet appeared in the <input>,
67 // so the get('displayedValue') call below won't give the result we want.
68 setTimeout(dojo.hitch(this, function(){
69 // set this.filterString to the filter to apply to the drop down list;
70 // it will be used in openDropDown()
71 var val = this.get('displayedValue');
72 this.filterString = (val && !this.parse(val, this.constraints)) ? val.toLowerCase() : "";
73
74 // close the drop down and reopen it, in order to filter the items shown in the list
75 // and also since the drop down may need to be repositioned if the number of list items has changed
76 // and it's being displayed above the <input>
77 if(this._opened){
78 this.closeDropDown();
79 }
80 this.openDropDown();
81 }), 0);
82 }
83 }
84 }
85 );
86
87 }