jquery.timepicker.d.ts 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // Type definitions for jQuery.timepicker 1.11.14
  2. // https://github.com/jonthornton/jquery-timepicker
  3. /**
  4. * Declaring a namespace because there are several jquery timepickers already out there on DefinitelyTyped. Jt stands for Jon Thornton
  5. */
  6. declare namespace Jt.Timepicker {
  7. /**
  8. * Options object for the jquery.timepicker
  9. */
  10. export interface Options {
  11. /**
  12. * Default: 'body'
  13. * Override where the dropdown is appended.
  14. * Takes either a string to use as a selector, a function that gets passed the clicked input element as argument or a jquery object to use directly.
  15. */
  16. appendTo?: string | ((clickedElement) => string);
  17. /**
  18. * Default: null
  19. * A class name to apply to the HTML element that contains the timepicker dropdown.
  20. */
  21. className?: string;
  22. /**
  23. * Default: false
  24. * Close the timepicker when the window is scrolled. (Replicates <select> behavior.)
  25. */
  26. closeOnWindowScroll?: boolean;
  27. /**
  28. * Default: false
  29. * Disable typing in the timepicker input box; force users to select from list.
  30. * More information https://github.com/jonthornton/jquery-timepicker/issues/425#issuecomment-133262458
  31. */
  32. disableTextInput?: boolean;
  33. /**
  34. * Default: []
  35. * Disable selection of certain time ranges. Input is an array of time pairs, like `[['3:00am', '4:30am'], ['5:00pm', '8:00pm']].
  36. * The start of the interval will be disabled but the end won't.
  37. */
  38. disableTimeRanges?: Array<string[]>;
  39. /**
  40. * Default: false
  41. * Disables the onscreen keyboard for touch devices. There can be instances where Firefox or Chrome have touch events enabled
  42. * (such as on Surface tablets but not actually be a touch device. In this case disableTouchKeyboard will prevent the timepicker
  43. * input field from being focused.
  44. * More information: https://github.com/jonthornton/jquery-timepicker/issues/413
  45. */
  46. disableTouchKeyboard?: boolean;
  47. /**
  48. * Default: Same as the minTime
  49. * The time against which showDuration will compute relative times. This should be given as a formatted date string.
  50. */
  51. durationTime?: string | Date | (() => string | Date);
  52. /**
  53. * Default: false
  54. * Force update the time to step settings as soon as it loses focus`.
  55. */
  56. forceRoundTime?: boolean;
  57. /**
  58. * Default: 24 hours after minTime
  59. * The time that should appear last in the dropdown list. Can be used to limit the range of time options.
  60. */
  61. maxTime?: Date | string;
  62. /**
  63. * Default: 12:00 am
  64. * The time that should appear first in the dropdown list.
  65. */
  66. minTime?: Date | string;
  67. /**
  68. * Default: false.
  69. * Adds one or more custom options to the top of the dropdown. Can accept several different value types:
  70. * Boolean (true): Adds a "None" option that results in an empty input value
  71. * String: Adds an option with a custom label that results in an empty input value
  72. * Object: Similar to string, but allows customizing the element's class name and the resulting input value. Can contain label, value, and className properties. The value property must be a string type.
  73. * Array: An array of strings or objects to add multiple non-time options
  74. */
  75. noneOption?: boolean | string | string[] | NoneObject;
  76. /**
  77. * default: 'l'
  78. * By default the timepicker dropdown will be aligned to the bottom right of the input element, or aligned to the top left if there isn't enough room below the input. Force alignment with l (left), r (right), t (top), and b (bottom). Examples: tl, rb.
  79. */
  80. orientation?: string;
  81. /**
  82. * Default: Rounds to the nearest step
  83. * Function used to compute rounded times. The function will receive time in seconds and a settings object as arguments. The function should handle a null value for seconds
  84. */
  85. roundingFunction?: (seconds: number, settings: Options) => number;
  86. /**
  87. * Default: null
  88. * If no time value is selected, set the dropdown scroll position to show the time provided, e.g. "09:00". A time string, Date object, or integer (seconds past midnight) is acceptible, as well as the string 'now'
  89. */
  90. scrollDefault?: string | Date | number | {};
  91. /**
  92. * Default: false
  93. * Update the input with the currently highlighted time value when the timepicker loses focus.
  94. */
  95. selectOnBlur?: boolean;
  96. /**
  97. * Default: false
  98. * Show "24:00" as an option when using 24-hour time format
  99. */
  100. show2400?: boolean;
  101. /**
  102. * Default: false
  103. * Shows the relative time for each item in the dropdown. minTime or durationTime must be set.
  104. */
  105. showDuration?: boolean;
  106. /**
  107. * Default: ["click", "focus"]
  108. * Display a timepicker dropdown when the input fires a particular event. Set to null or an empty array to disable automatic display. Setting should be an array of strings
  109. */
  110. showOn?: string[];
  111. /**
  112. * @deprecated Display a timepicker dropdown when the input gains focus.
  113. * Default: true
  114. */
  115. showOnFocus?: boolean;
  116. /**
  117. * Default: 30
  118. * The amount of time, in minutes, between each item in the dropdown. Alternately, you can specify a function to generate steps dynamically. The function will receive a count integer (0, 1, 2...) and is expected to return a step integer.
  119. */
  120. step?: number;
  121. /**
  122. * Default: false
  123. * When scrolling on the edge of the picker, it prevent parent containers () to scroll
  124. */
  125. stopScrollPropagation?: boolean;
  126. /**
  127. * Default: 'g:ia'
  128. * How times should be displayed in the list and input element. Uses PHP's date() formatting syntax. Characters can be escaped with a preceeding double slash (e.g. H\\hi). Alternatively, you can specify a function instead of a string, to use completely custom time formatting. In this case, * the format function receives a Date object and is expected to return a formatted time as a string
  129. */
  130. timeFormat?: string | ((givenDate: Date) => string);
  131. /**
  132. * Default: true
  133. * Highlight the nearest corresponding time option as a value is typed into the form input.
  134. */
  135. typeaheadHighlight?: boolean;
  136. /**
  137. * Default: false
  138. * Convert the input to an HTML <SELECT> control. This is ideal for small screen devices, or if you want to prevent the user from entering
  139. * arbitrary values. This option is not compatible with the following options: appendTo, closeOnWindowScroll, disableTouchKeyboard,
  140. * scrollDefault, selectOnBlur, typeAheadHighlight.
  141. */
  142. useSelect?: boolean;
  143. }
  144. export interface NoneObject {
  145. label: string;
  146. value: string;
  147. className: string;
  148. }
  149. }