TimeTextBox.js.uncompressed.js 2.6 KB

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