Debian Codegraph @

dijit/form/TimeTextBox.js

raw symbols SCIP
1 define([
2 "dojo/_base/declare", // declare
3 "dojo/keys", // keys.DOWN_ARROW keys.ENTER keys.ESCAPE keys.TAB keys.UP_ARROW
4 "dojo/query",
5 "dojo/_base/lang", // lang.hitch
6 "../_TimePicker",
7 "./_DateTimeTextBox"
8 ], function(declare, keys, query, lang, _TimePicker, _DateTimeTextBox){
9
10 // module:
11 // dijit/form/TimeTextBox
12
13
14 var TimeTextBox = declare("dijit.form.TimeTextBox", _DateTimeTextBox, {
15 // summary:
16 // A validating, serializable, range-bound time text box with a drop down time picker
17
18 baseClass: "dijitTextBox dijitComboBox dijitTimeTextBox",
19 popupClass: _TimePicker,
20 _selector: "time",
21
22 /*=====
23 // constraints: TimeTextBox.__Constraints
24 // Despite the name, this parameter specifies both constraints on the input
25 // (including minimum/maximum allowed values) as well as
26 // formatting options. See `dijit/form/TimeTextBox.__Constraints` for details.
27 constraints:{},
28 =====*/
29
30 // value: Date
31 // The value of this widget as a JavaScript Date object. Note that the date portion implies time zone and daylight savings rules.
32 //
33 // Example:
34 // | new dijit/form/TimeTextBox({value: stamp.fromISOString("T12:59:59", new Date())})
35 //
36 // When passed to the parser in markup, must be specified according to locale-independent
37 // `stamp.fromISOString` format.
38 //
39 // Example:
40 // | <input data-dojo-type='dijit/form/TimeTextBox' value='T12:34:00'>
41 value: new Date(""), // value.toString()="NaN"
42 //FIXME: in markup, you have no control over daylight savings
43
44 // Add scrollbars if necessary so that dropdown doesn't cover the <input>
45 maxHeight: -1,
46
47 openDropDown: function(/*Function*/ callback){
48 this.inherited(arguments);
49
50 // Fix #18683
51 var selectedNode = query(".dijitTimePickerItemSelected", this.dropDown.domNode),
52 parentNode=this.dropDown.domNode.parentNode;
53 if(selectedNode[0]){
54 // Center the selected node in the client area of the popup.
55 parentNode.scrollTop=selectedNode[0].offsetTop-(parentNode.clientHeight-selectedNode[0].clientHeight)/2;
56 }else{
57 // There is no currently selected value. Position the list so that the median
58 // node is visible.
59 parentNode.scrollTop=(parentNode.scrollHeight-parentNode.clientHeight)/2;
60 }
61
62 // For screen readers, as user arrows through values, populate <input> with latest value.
63 this.dropDown.on("input", lang.hitch(this, function(){
64 this.set('value', this.dropDown.get("value"), false);
65 }));
66 },
67
68 _onInput: function(){
69 this.inherited(arguments);
70
71 // set this.filterString to the filter to apply to the drop down list;
72 // it will be used in openDropDown()
73 var val = this.get('displayedValue');
74 this.filterString = (val && !this.parse(val, this.constraints)) ? val.toLowerCase() : "";
75
76 // close the drop down and reopen it, in order to filter the items shown in the list
77 // and also since the drop down may need to be repositioned if the number of list items has changed
78 // and it's being displayed above the <input>
79 if(this._opened){
80 this.closeDropDown();
81 }
82 this.openDropDown();
83 }
84 });
85
86 /*=====
87 TimeTextBox.__Constraints = declare([_DateTimeTextBox.__Constraints, _TimePicker.__Constraints], {
88 // summary:
89 // Specifies both the rules on valid/invalid values (first/last time allowed),
90 // and also formatting options for how the time is displayed.
91 });
92 =====*/
93
94 return TimeTextBox;
95 });