|
| 1 | +// Type definitions for jQuery-timeentry.js 2.0.1 |
| 2 | +// Project: https://github.com/kbwood/timeentry |
| 3 | +// Definitions by: Mark Nadig <https://github.com/marknadig> |
| 4 | +// Definitions: https://github.com/borisyankov/DefinitelyTyped |
| 5 | + |
| 6 | +/// <reference path="../jquery/jquery.d.ts"/> |
| 7 | + |
| 8 | +interface ITimeEntryRegionalOptions { |
| 9 | + /** |
| 10 | + * Indicate whether to use 12-hour (false) or 24-hour (true) time. This is one of the regional settings fields. |
| 11 | + * |
| 12 | + * default: False |
| 13 | + */ |
| 14 | + show24Hours?: boolean; |
| 15 | + /** |
| 16 | + * The separator between time portions. This is one of the regional settings fields. |
| 17 | + * |
| 18 | + * default: ':' |
| 19 | + */ |
| 20 | + separator?: string; |
| 21 | + /** |
| 22 | + * The text that separates the time from the AM and PM indicators. This is one of the regional settings fields. |
| 23 | + * |
| 24 | + * default: '' |
| 25 | + */ |
| 26 | + ampmPrefix?: string; |
| 27 | + /** |
| 28 | + * The AM and PM display text. This is one of the regional settings fields. |
| 29 | + * |
| 30 | + * default: ['AM','PM'] |
| 31 | + */ |
| 32 | + ampmNames?: string[]; |
| 33 | + /** |
| 34 | + * The tooltip text for the spinner buttons. This is one of the regional settings fields. |
| 35 | + * |
| 36 | + * default: ['Now', 'Previous field', 'Next field', 'Increment', 'Decrement'] |
| 37 | + */ |
| 38 | + spinnerTexts?: string[]; |
| 39 | +} |
| 40 | + |
| 41 | +interface ITimeEntryOptions extends ITimeEntryRegionalOptions { |
| 42 | + /** |
| 43 | + * Indicate whether or not the seconds part of the time should be displayed. |
| 44 | + * |
| 45 | + * default: False |
| 46 | + */ |
| 47 | + showSeconds?: boolean; |
| 48 | + /** |
| 49 | + * Indicate whether to restrict hours to just those in one day (false) or to allow for any value for hours (true). |
| 50 | + * |
| 51 | + * default: false |
| 52 | + */ |
| 53 | + unlimitedHours?: boolean; |
| 54 | + /** |
| 55 | + * Add content to display after each time field. This may contain HTML markup. |
| 56 | + * |
| 57 | + * default: '' |
| 58 | + */ |
| 59 | + appendText?: string; |
| 60 | + /** |
| 61 | + * The increment/decrement values for each of the time portions - hours, minutes, and seconds. |
| 62 | + * Use this to constrain the portions, e.g. [1, 15, 0] restricts the times to quarter hours. |
| 63 | + * |
| 64 | + * default: [1,1,1] |
| 65 | + */ |
| 66 | + timeSteps?: number[]; |
| 67 | + /** |
| 68 | + * The number of the portion of the time field to highlight initially. |
| 69 | + * Use 0 for hours, 1 for minutes, etc., or null for the user selection. |
| 70 | + * |
| 71 | + * default: null |
| 72 | + */ |
| 73 | + initialField?: number; |
| 74 | + /** |
| 75 | + * Set to true to allow direct entry of a time from the keyboard without needing to type separators, |
| 76 | + * i.e. the field moves on after two digits. |
| 77 | + * |
| 78 | + * default: false |
| 79 | + */ |
| 80 | + noSeparatorEntry?: boolean; |
| 81 | + /** |
| 82 | + * true to have the tab key exit this field and move to the next one, or false to have the tab key step |
| 83 | + * through the date subfields. |
| 84 | + * |
| 85 | + * default: false |
| 86 | + */ |
| 87 | + tabToExit?: boolean; |
| 88 | + /** |
| 89 | + * Set to true to use the mouse wheel for increment/decrement if possible, or false to never use it. |
| 90 | + * |
| 91 | + * default: true |
| 92 | + */ |
| 93 | + useMouseWheel?: boolean; |
| 94 | + /** |
| 95 | + * The default time to show when no other value has been entered. This may be a Date object |
| 96 | + * (but the year/month/day values are ignored), a string in the current time format, a numeric |
| 97 | + * value as seconds offset from now, or a string value indicating a number and units, e.g. '+2h'. |
| 98 | + * In the latter case, use 'h' for hours, 'm' for minutes, or 's' for seconds. Letters may be upper |
| 99 | + * or lower case. Multiple offsets may be combined into one setting, e.g. '-2h -20m'. Prefix with '!' |
| 100 | + * to prevent a wrap around into another day. Leave as null to default to the current time. |
| 101 | + * |
| 102 | + * default: null |
| 103 | + */ |
| 104 | + defaultTime?: Date | number | string; |
| 105 | + /** |
| 106 | + * The minimum time that may be selected, or null for no limit. See defaultTime for a description |
| 107 | + * of the possible formats. Use an array of number for hours, minutes, seconds in conjunction with unlimitedHours. |
| 108 | + * |
| 109 | + * default: null |
| 110 | + */ |
| 111 | + minTime?: Date | number | number[] | string; |
| 112 | + /** |
| 113 | + * The maximum time that may be selected, or null for no limit. See defaultTime for a description of the possible |
| 114 | + * formats. Use an array of number for hours, minutes, seconds in conjunction with unlimitedHours. |
| 115 | + * |
| 116 | + * Note that the maxTime may be set to less than the minTime in which case the entered time is restricted to |
| 117 | + * the period between the minimum and the maximum on the "next day". |
| 118 | + * |
| 119 | + * default: null |
| 120 | + */ |
| 121 | + maxTime?: Date | number | number[] | string; |
| 122 | + /** |
| 123 | + * The URL for the spinner images to use, or '' for no spinner. The file must contain seven images horizontally |
| 124 | + * for the normal view, then for each "button" pressed (now, previous, next, increment, and decrement), and, |
| 125 | + * finally, the disabled view. |
| 126 | + * |
| 127 | + * default: 'spinnerDefault.png' |
| 128 | + */ |
| 129 | + spinnerImage?: string; |
| 130 | + /** |
| 131 | + * The dimensions of the spinner image for determining which "button" was clicked. The first two values are the |
| 132 | + * width and height of the individual images, the third is the size of the central button for setting the current |
| 133 | + * time, or 0 for no central button. |
| 134 | + * |
| 135 | + * default: [20, 20, 8] |
| 136 | + */ |
| 137 | + spinnerSize?: number[]; |
| 138 | + /** |
| 139 | + * The URL for an expanded spinner image to use, or '' for no expansion. The layout is the same as for |
| 140 | + * spinnerImage but should be a larger size. The expanded spinner appears when the user hovers over the |
| 141 | + * original spinner and disappears when they move off it. |
| 142 | + * |
| 143 | + * default: '' |
| 144 | + */ |
| 145 | + spinnerBigImage?: string; |
| 146 | + /** |
| 147 | + * The dimensions of the expanded spinner image for determining which "button" was clicked. The first two values |
| 148 | + * are the width and height of the individual images, the third is the size of the central button for setting the |
| 149 | + * current time, or 0 for no central button. |
| 150 | + * |
| 151 | + * default: [40, 40, 16] |
| 152 | + */ |
| 153 | + spinnerBigSize?: number[]; |
| 154 | + /** |
| 155 | + * Set to true to have only the increment and decrement buttons on the spinner, or false for all the buttons. |
| 156 | + * |
| 157 | + * default: false |
| 158 | + */ |
| 159 | + spinnerIncDecOnly?: boolean; |
| 160 | + /** |
| 161 | + * The times in milliseconds for the auto-repeat feature on the increment and decrement spinner buttons. |
| 162 | + * The first value is the initial delay and the second one is the subsequent delay. Hold the mouse button down |
| 163 | + * on these spinner buttons to trigger this feature. Use [0, 0] to disable the auto-repeat. |
| 164 | + * |
| 165 | + * default: [500, 250] |
| 166 | + */ |
| 167 | + spinnerRepeat?: number[]; |
| 168 | + /** |
| 169 | + * A function that accepts an input field and returns a settings object containing new settings for the time |
| 170 | + * entry for this field. For example, you can use it to set up a time range wherein both fields restrict the |
| 171 | + * possible values of the other field. this refers to the input field as well. Leave as null for no per-field |
| 172 | + * customisation. |
| 173 | + * |
| 174 | + * default: null |
| 175 | + */ |
| 176 | + beforeShow?: Function; |
| 177 | + /** |
| 178 | + * A function that accepts the old and new times, and minimum and maximum times, and returns an updated time. |
| 179 | + * This refers to the associated input field. This call is made just before the time is updated into the field |
| 180 | + * allowing for additional restrictions to be applied. Leave as null for no additional restrictions. |
| 181 | + * |
| 182 | + * default: null |
| 183 | + */ |
| 184 | + beforeSetTime?: Function; |
| 185 | +} |
| 186 | + |
| 187 | +interface ITimeEntry { |
| 188 | + /** |
| 189 | + * initialize TimeEntry plugin |
| 190 | + */ |
| 191 | + (configOrFnName?: ITimeEntryOptions | string, nameOrOption?: any, value?: any): any; // functions accessed with string key :/ |
| 192 | +} |
| 193 | + |
| 194 | +interface ITimeEntryLocales { |
| 195 | + [index: string]: ITimeEntryRegionalOptions; |
| 196 | +} |
| 197 | + |
| 198 | +interface ITimeEntryStatic { |
| 199 | + regionalOptions: ITimeEntryLocales; |
| 200 | + setDefaults(settings: ITimeEntryOptions): void; |
| 201 | +} |
| 202 | + |
| 203 | +interface JQuery { |
| 204 | + /** |
| 205 | + * initialize TimeEntry plugin |
| 206 | + */ |
| 207 | + timeEntry: ITimeEntry; |
| 208 | +} |
| 209 | + |
| 210 | +interface JQueryStatic { |
| 211 | + timeEntry: ITimeEntryStatic; |
| 212 | +} |
0 commit comments