Mercurial > hg > index.fcgi > www > www-1
comparison bootstrap-year-calendar/bootstrap-year-calendar.d.ts @ 136:93ad5ecd149d
myw2: Update radar url
author | paulo |
---|---|
date | Sat, 22 Oct 2022 18:50:25 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:28aa7f2faa13 |
---|---|
1 // Type definitions for bootstrap-year-calendar v1.1.0 | |
2 // Project: https://github.com/Paul-DS/bootstrap-year-calendar | |
3 // Definitions by: Paul David-Sivelle | |
4 // Definitions: https://github.com/borisyankov/DefinitelyTyped | |
5 | |
6 /// <reference path="../jquery/jquery.d.ts"/> | |
7 | |
8 /** | |
9 * Represent a context menu item for the calendar. | |
10 */ | |
11 interface CalendarContextMenuItem<T> { | |
12 /** | |
13 * The text of the menu item. | |
14 */ | |
15 text: string; | |
16 | |
17 /** | |
18 * A function to be called when the item is clicked. | |
19 */ | |
20 click?: (event: T) => void; | |
21 | |
22 /** | |
23 * The list of sub menu items. | |
24 */ | |
25 submenu?: CalendarContextMenuItem<T>[]; | |
26 } | |
27 | |
28 /** | |
29 * Represent an element to display in the calendar. | |
30 */ | |
31 interface CalendarDataSourceElement { | |
32 /** | |
33 * The name of the element. Used for context menu or specific events. | |
34 */ | |
35 name?: string; | |
36 | |
37 /** | |
38 * The color of the element. This property will be computed automatically if not defined. | |
39 */ | |
40 color?: string; | |
41 | |
42 /** | |
43 * The date of the beginning of the element range. | |
44 */ | |
45 startDate: Date; | |
46 | |
47 /** | |
48 * The date of the end of the element range. | |
49 */ | |
50 endDate: Date; | |
51 | |
52 /** | |
53 * Indicates whether only the half of start day of the element range should be rendered. | |
54 */ | |
55 startHalfDay?: boolean; | |
56 | |
57 /** | |
58 * Indicates whether only the half of last day of the element range should be rendered. | |
59 */ | |
60 endHalfDay?: boolean; | |
61 } | |
62 | |
63 /** | |
64 * Options used for calendar customization. | |
65 */ | |
66 interface CalendarOptions<T extends CalendarDataSourceElement> { | |
67 | |
68 /** | |
69 * Specifies whether the user can select a range which overlapping an other element present in the datasource. | |
70 */ | |
71 allowOverlap?: boolean; | |
72 | |
73 /** | |
74 * Specifies whether the beginning and the end of each range should be displayed as half selected day. | |
75 */ | |
76 alwaysHalfDay?: boolean; | |
77 | |
78 /** | |
79 * Specifies the items of the default context menu. | |
80 */ | |
81 contextMenuItems?: CalendarContextMenuItem<T>[]; | |
82 | |
83 /** | |
84 * Specify a custom renderer for days. | |
85 * This function is called during render for each day. | |
86 */ | |
87 customDayRenderer?: (element: JQuery, currentDate: Date) => void; | |
88 | |
89 /** | |
90 * Specify a custom renderer for data source. Works only with the style set to "custom". | |
91 * This function is called during render for each day containing at least one event. | |
92 */ | |
93 customDataSourceRenderer?: (element: JQuery, currentDate: Date, events: T[]) => void; | |
94 | |
95 /** | |
96 * The elements that must be displayed on the calendar. | |
97 */ | |
98 dataSource?: T[]; | |
99 | |
100 /** | |
101 * The days that must be displayed as disabled. | |
102 */ | |
103 disableDays?: Date[]; | |
104 | |
105 /** | |
106 * Specifies whether the weeks number are displayed. | |
107 */ | |
108 displayWeekNumber?: boolean; | |
109 | |
110 /** | |
111 * Specifies whether the default context menu must be displayed when right clicking on a day. | |
112 */ | |
113 enableContextMenu?: boolean; | |
114 | |
115 /** | |
116 * Specifies whether the range selection is enabled. | |
117 */ | |
118 enableRangeSelection?: boolean; | |
119 | |
120 /** | |
121 * The language/culture used for calendar rendering. | |
122 */ | |
123 language?: string; | |
124 | |
125 /** | |
126 * The date until which days are enabled. | |
127 */ | |
128 maxDate?: Date; | |
129 | |
130 /** | |
131 * The date from which days are enabled. | |
132 */ | |
133 minDate?: Date; | |
134 | |
135 /** | |
136 * Specifies whether the beginning and the end of each range should be displayed as rounded cells. | |
137 */ | |
138 roundRangeLimits?: boolean; | |
139 | |
140 /** | |
141 * The year on which the calendar should be opened. | |
142 */ | |
143 startYear?: number; | |
144 | |
145 /** | |
146 * Specifies the style used for displaying datasource ("background", "border" or "custom"). | |
147 */ | |
148 style?: string; | |
149 | |
150 /** | |
151 * Function fired when a day is clicked. | |
152 */ | |
153 clickDay?: (e: CalendarClickEventObject<T>) => void; | |
154 | |
155 /** | |
156 * Function fired when a day is right clicked. | |
157 */ | |
158 dayContextMenu?: (e: CalendarDayEventObject<T>) => void; | |
159 | |
160 /** | |
161 * Function fired when the mouse enter on a day. | |
162 */ | |
163 mouseOnDay?: (e: CalendarDayEventObject<T>) => void; | |
164 | |
165 /** | |
166 * Function fired when the mouse leaves a day. | |
167 */ | |
168 mouseOutDay?: (e: CalendarDayEventObject<T>) => void; | |
169 | |
170 /** | |
171 * Function fired when the calendar rendering is ended. | |
172 */ | |
173 renderEnd?: (e: CalendarRenderEndEventObject) => void; | |
174 | |
175 /** | |
176 * Function fired when a date range is selected. | |
177 */ | |
178 selectRange?: (e: CalendarRangeEventObject) => void; | |
179 } | |
180 | |
181 interface CalendarDayEventObject<T extends CalendarDataSourceElement> { | |
182 /** | |
183 * The element that contain the fired day. | |
184 */ | |
185 element: JQuery; | |
186 | |
187 /** | |
188 * The fired date. | |
189 */ | |
190 date: Date; | |
191 | |
192 /** | |
193 * The data source elements present on the fired day. | |
194 */ | |
195 events: T[]; | |
196 } | |
197 | |
198 interface CalendarClickEventObject<T extends CalendarDataSourceElement> extends CalendarDayEventObject<T> { | |
199 /** | |
200 * The clicked button. | |
201 */ | |
202 which: number; | |
203 } | |
204 | |
205 interface CalendarRenderEndEventObject { | |
206 /** | |
207 * The rendered year. | |
208 */ | |
209 currentYear: number; | |
210 } | |
211 | |
212 interface CalendarRangeEventObject { | |
213 /** | |
214 * The beginning of the selected range. | |
215 */ | |
216 startDate: Date; | |
217 | |
218 /** | |
219 * The end of the selected range. | |
220 */ | |
221 endDate: Date; | |
222 } | |
223 | |
224 /** | |
225 * Calendar instance. | |
226 */ | |
227 interface Calendar<T extends CalendarDataSourceElement> { | |
228 /** | |
229 * Add a new element to the data source. This method causes a refresh of the calendar. | |
230 * | |
231 * @param element The element to add. | |
232 */ | |
233 addEvent(element: T): void; | |
234 | |
235 /** | |
236 * Gets a value indicating whether the user can select a range which overlapping an other element present in the datasource. | |
237 */ | |
238 getAllowOverlap(): boolean; | |
239 | |
240 /** | |
241 * Gets a value indicating whether the beginning and the end of each range should be displayed as half selected day. | |
242 */ | |
243 getAlwaysHalfDay(): boolean; | |
244 | |
245 /** | |
246 * Gets the context menu items. | |
247 */ | |
248 getContextMenuItems(): CalendarContextMenuItem<T>[]; | |
249 | |
250 /** | |
251 * Gets the custom day renderer. | |
252 */ | |
253 getCustomDayRenderer(): (element: JQuery, currentDate: Date) => void; | |
254 | |
255 /** | |
256 * Gets the custom data source renderer. | |
257 */ | |
258 getCustomDataSourceRenderer(): (element: JQuery, currentDate: Date, events: T[]) => void; | |
259 | |
260 /** | |
261 * Gets the current data source. | |
262 */ | |
263 getDataSource(): T[]; | |
264 | |
265 /** | |
266 * Gets the disabled days. | |
267 */ | |
268 getDisableDays(): Date[]; | |
269 | |
270 /** | |
271 * Gets a value indicating whether the weeks number are displayed. | |
272 */ | |
273 getDisplayWeekNumber(): boolean; | |
274 | |
275 /** | |
276 * Gets a value indicating whether the default context menu must be displayed when right clicking on a day. | |
277 */ | |
278 getEnableContextMenu(): boolean; | |
279 | |
280 /** | |
281 * Gets a value indicating whether the user can make range selection. | |
282 */ | |
283 getEnableRangeSelection(): boolean; | |
284 | |
285 /** | |
286 * Gets the data source elements for a specified day. | |
287 * | |
288 * @param date The specified day. | |
289 */ | |
290 getEvents(Date: Date): T[]; | |
291 | |
292 /** | |
293 * Gets the language used for calendar rendering. | |
294 */ | |
295 getLanguage(): string; | |
296 | |
297 /** | |
298 * Gets the maximum date of the calendar. | |
299 */ | |
300 getMaxDate(): Date; | |
301 | |
302 /** | |
303 * Gets the minimum date of the calendar. | |
304 */ | |
305 getMinDate(): Date; | |
306 | |
307 /** | |
308 * Gets a value indicating whether the beginning and the end of each range should be displayed as rounded cells. | |
309 */ | |
310 getRoundRangeLimits(): void; | |
311 | |
312 /** | |
313 * Gets the current style used for displaying data source. | |
314 */ | |
315 getStyle(): string; | |
316 | |
317 /** | |
318 * Gets the week number for a specified date. | |
319 * | |
320 * @param date The specified date. | |
321 */ | |
322 getWeekNumber(Date: Date): number; | |
323 | |
324 /** | |
325 * Gets the year displayed on the calendar. | |
326 */ | |
327 getYear(): number; | |
328 | |
329 /** | |
330 * Sets a value indicating whether the user can select a range which overlapping an other element present in the datasource. | |
331 * | |
332 * @param allowOverlap Indicates whether the user can select a range which overlapping an other element present in the datasource. | |
333 */ | |
334 setAllowOverlap(allowOverlap: boolean): void; | |
335 | |
336 /** | |
337 * Sets a value indicating whether the beginning and the end of each range should be displayed as half selected day. | |
338 * This method causes a refresh of the calendar. | |
339 * | |
340 * @param alwaysHalfDay Indicates whether the beginning and the end of each range should be displayed as half selected day. | |
341 */ | |
342 setAlwaysHalfDay(alwaysHalfDay: boolean): void; | |
343 | |
344 /** | |
345 * Sets new context menu items. This method causes a refresh of the calendar. | |
346 * | |
347 * @param contextMenuItems The new context menu items. | |
348 */ | |
349 setContextMenuItems(contextMenuItems: CalendarContextMenuItem<T>[]): void; | |
350 | |
351 /** | |
352 * Sets the custom day renderer. | |
353 * | |
354 * @param handler The function used to render the days. This function is called during render for each day. | |
355 */ | |
356 setCustomDayRenderer(handler: (element: JQuery, currentDate: Date) => void): void; | |
357 | |
358 /** | |
359 * Sets the custom data source renderer. Works only with the style set to "custom". | |
360 * | |
361 * @param handler The function used to render the data source. This function is called during render for each day containing at least one event. | |
362 */ | |
363 setCustomDataSourceRenderer(handler: (element: JQuery, currentDate: Date, events: T[]) => void): void; | |
364 | |
365 /** | |
366 * Sets a new data source. This method causes a refresh of the calendar. | |
367 * | |
368 * @param dataSource The new data source. | |
369 */ | |
370 setDataSource(dataSource: T[]): void; | |
371 | |
372 /** | |
373 * Sets the disabled days. This method causes a refresh of the calendar. | |
374 * | |
375 * @param disableDays The disabled days to set. | |
376 */ | |
377 setDisableDays(disableDays: Date[]): void; | |
378 | |
379 /** | |
380 * Sets a value indicating whether the weeks number are displayed. This method causes a refresh of the calendar. | |
381 * | |
382 * @param displayWeekNumber Indicates whether the weeks number are displayed. | |
383 */ | |
384 setDisplayWeekNumber(displayWeekNumber: boolean): void; | |
385 | |
386 /** | |
387 * Sets a value indicating whether the default context menu must be displayed when right clicking on a day. | |
388 * This method causes a refresh of the calendar. | |
389 * | |
390 * @param enableContextMenu Indicates whether the default context menu must be displayed when right clicking on a day. | |
391 */ | |
392 setEnableContextMenu(enableContextMenu: boolean): void; | |
393 | |
394 /** | |
395 * Sets a value indicating whether the user can make range selection. This method causes a refresh of the calendar. | |
396 * | |
397 * @param enableRangeSelection Indicates whether the user can make range selection. | |
398 */ | |
399 setEnableRangeSelection(enableRangeSelection: boolean): void; | |
400 | |
401 /** | |
402 * Sets the language used for calendar rendering. This method causes a refresh of the calendar. | |
403 * | |
404 * @param language The language to use for calendar redering. | |
405 */ | |
406 setLanguage(language: string): void; | |
407 | |
408 /** | |
409 * Sets the maximum date of the calendar. This method causes a refresh of the calendar. | |
410 * | |
411 * @param maxDate The maximum date to set. | |
412 */ | |
413 setMaxDate(maxDate: Date): void; | |
414 | |
415 /** | |
416 * Sets the minimum date of the calendar. This method causes a refresh of the calendar. | |
417 * | |
418 * @param minDate The minimum date to set. | |
419 */ | |
420 setMinDate(minDate: Date): void; | |
421 | |
422 /** | |
423 * Sets a value indicating whether the beginning and the end of each range should be displayed as rounded cells. | |
424 * This method causes a refresh of the calendar. | |
425 * | |
426 * @param roundRangeLimits Indicates whether the beginning and the end of each range should be displayed as rounded cells. | |
427 */ | |
428 setRoundRangeLimits(roundRangeLimits: boolean): void; | |
429 | |
430 /** | |
431 * Sets the style to use for displaying data source. This method causes a refresh of the calendar. | |
432 * | |
433 * @param style The style to use for displaying data source ("background", "border" or "custom"). | |
434 */ | |
435 setStyle(style: string): void; | |
436 | |
437 /** | |
438 * Sets the year displayed on the calendar. | |
439 * | |
440 * @param year The year to displayed on the calendar. | |
441 */ | |
442 setYear(year: number): void; | |
443 } | |
444 | |
445 /** | |
446 * Basic calendar instance. | |
447 */ | |
448 interface BaseCalendar extends Calendar<CalendarDataSourceElement> { | |
449 | |
450 } | |
451 | |
452 interface JQuery { | |
453 | |
454 /** | |
455 * Create a new calendar. | |
456 */ | |
457 calendar(): BaseCalendar; | |
458 | |
459 /** | |
460 * Create a new calendar. | |
461 * | |
462 * @param options The customization options. | |
463 */ | |
464 calendar(options: CalendarOptions<CalendarDataSourceElement>): BaseCalendar; | |
465 | |
466 /** | |
467 * Create a new calendar. | |
468 * | |
469 * @param options The customization options. | |
470 */ | |
471 calendar<T extends CalendarDataSourceElement>(options: CalendarOptions<T>): Calendar<T>; | |
472 | |
473 | |
474 /** | |
475 * Function fired when a day is clicked (for bootstrap-year-calendar only). | |
476 * | |
477 * @param handler A function to execute each time the event is triggered. | |
478 */ | |
479 clickDay(handler: (e: CalendarClickEventObject<CalendarDataSourceElement>) => void): JQuery; | |
480 | |
481 /** | |
482 * Function fired when a day is clicked (for bootstrap-year-calendar only). | |
483 * | |
484 * @param handler A function to execute each time the event is triggered. | |
485 */ | |
486 clickDay<T extends CalendarDataSourceElement>(handler: (e: CalendarClickEventObject<T>) => void): JQuery; | |
487 | |
488 /** | |
489 * Function fired when a day is right clicked (for bootstrap-year-calendar only). | |
490 * | |
491 * @param handler A function to execute each time the event is triggered. | |
492 */ | |
493 dayContextMenu(handler: (e: CalendarDayEventObject<CalendarDataSourceElement>) => void): JQuery; | |
494 | |
495 /** | |
496 * Function fired when a day is right clicked (for bootstrap-year-calendar only). | |
497 * | |
498 * @param handler A function to execute each time the event is triggered. | |
499 */ | |
500 dayContextMenu<T extends CalendarDataSourceElement>(handler: (e: CalendarDayEventObject<T>) => void): JQuery; | |
501 | |
502 /** | |
503 * Function fired when the mouse enter on a day (for bootstrap-year-calendar only). | |
504 * | |
505 * @param handler A function to execute each time the event is triggered. | |
506 */ | |
507 mouseOnDay(handler: (e: CalendarDayEventObject<CalendarDataSourceElement>) => void): JQuery; | |
508 | |
509 /** | |
510 * Function fired when the mouse enter on a day (for bootstrap-year-calendar only). | |
511 * | |
512 * @param handler A function to execute each time the event is triggered. | |
513 */ | |
514 mouseOnDay<T extends CalendarDataSourceElement>(handler: (e: CalendarDayEventObject<T>) => void): JQuery; | |
515 | |
516 /** | |
517 * Function fired when the mouse leaves a day (for bootstrap-year-calendar only). | |
518 * | |
519 * @param handler A function to execute each time the event is triggered. | |
520 */ | |
521 mouseOutDay(handler: (e: CalendarDayEventObject<CalendarDataSourceElement>) => void): JQuery; | |
522 | |
523 /** | |
524 * Function fired when the mouse leaves a day (for bootstrap-year-calendar only). | |
525 * | |
526 * @param handler A function to execute each time the event is triggered. | |
527 */ | |
528 mouseOutDay<T extends CalendarDataSourceElement>(handler: (e: CalendarDayEventObject<T>) => void): JQuery; | |
529 | |
530 /** | |
531 * Function fired when the calendar rendering is ended (for bootstrap-year-calendar only). | |
532 * | |
533 * @param handler A function to execute each time the event is triggered. | |
534 */ | |
535 renderEnd(handler: (e: CalendarRenderEndEventObject) => void): JQuery; | |
536 | |
537 /** | |
538 * Function fired when a date range is selected (for bootstrap-year-calendar only). | |
539 * | |
540 * @param handler A function to execute each time the event is triggered. | |
541 */ | |
542 selectRange(handler: (e: CalendarRangeEventObject) => void): JQuery; | |
543 } |