view bootstrap-year-calendar/bootstrap-year-calendar.d.ts @ 142:2ed8cf5f36bf

myrss2: fix handling of null feed title or links; miscellaneous URL updates
author paulo
date Mon, 18 Dec 2023 20:10:27 +0000
parents
children
line source
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
6 /// <reference path="../jquery/jquery.d.ts"/>
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;
17 /**
18 * A function to be called when the item is clicked.
19 */
20 click?: (event: T) => void;
22 /**
23 * The list of sub menu items.
24 */
25 submenu?: CalendarContextMenuItem<T>[];
26 }
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;
37 /**
38 * The color of the element. This property will be computed automatically if not defined.
39 */
40 color?: string;
42 /**
43 * The date of the beginning of the element range.
44 */
45 startDate: Date;
47 /**
48 * The date of the end of the element range.
49 */
50 endDate: Date;
52 /**
53 * Indicates whether only the half of start day of the element range should be rendered.
54 */
55 startHalfDay?: boolean;
57 /**
58 * Indicates whether only the half of last day of the element range should be rendered.
59 */
60 endHalfDay?: boolean;
61 }
63 /**
64 * Options used for calendar customization.
65 */
66 interface CalendarOptions<T extends CalendarDataSourceElement> {
68 /**
69 * Specifies whether the user can select a range which overlapping an other element present in the datasource.
70 */
71 allowOverlap?: boolean;
73 /**
74 * Specifies whether the beginning and the end of each range should be displayed as half selected day.
75 */
76 alwaysHalfDay?: boolean;
78 /**
79 * Specifies the items of the default context menu.
80 */
81 contextMenuItems?: CalendarContextMenuItem<T>[];
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;
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;
95 /**
96 * The elements that must be displayed on the calendar.
97 */
98 dataSource?: T[];
100 /**
101 * The days that must be displayed as disabled.
102 */
103 disableDays?: Date[];
105 /**
106 * Specifies whether the weeks number are displayed.
107 */
108 displayWeekNumber?: boolean;
110 /**
111 * Specifies whether the default context menu must be displayed when right clicking on a day.
112 */
113 enableContextMenu?: boolean;
115 /**
116 * Specifies whether the range selection is enabled.
117 */
118 enableRangeSelection?: boolean;
120 /**
121 * The language/culture used for calendar rendering.
122 */
123 language?: string;
125 /**
126 * The date until which days are enabled.
127 */
128 maxDate?: Date;
130 /**
131 * The date from which days are enabled.
132 */
133 minDate?: Date;
135 /**
136 * Specifies whether the beginning and the end of each range should be displayed as rounded cells.
137 */
138 roundRangeLimits?: boolean;
140 /**
141 * The year on which the calendar should be opened.
142 */
143 startYear?: number;
145 /**
146 * Specifies the style used for displaying datasource ("background", "border" or "custom").
147 */
148 style?: string;
150 /**
151 * Function fired when a day is clicked.
152 */
153 clickDay?: (e: CalendarClickEventObject<T>) => void;
155 /**
156 * Function fired when a day is right clicked.
157 */
158 dayContextMenu?: (e: CalendarDayEventObject<T>) => void;
160 /**
161 * Function fired when the mouse enter on a day.
162 */
163 mouseOnDay?: (e: CalendarDayEventObject<T>) => void;
165 /**
166 * Function fired when the mouse leaves a day.
167 */
168 mouseOutDay?: (e: CalendarDayEventObject<T>) => void;
170 /**
171 * Function fired when the calendar rendering is ended.
172 */
173 renderEnd?: (e: CalendarRenderEndEventObject) => void;
175 /**
176 * Function fired when a date range is selected.
177 */
178 selectRange?: (e: CalendarRangeEventObject) => void;
179 }
181 interface CalendarDayEventObject<T extends CalendarDataSourceElement> {
182 /**
183 * The element that contain the fired day.
184 */
185 element: JQuery;
187 /**
188 * The fired date.
189 */
190 date: Date;
192 /**
193 * The data source elements present on the fired day.
194 */
195 events: T[];
196 }
198 interface CalendarClickEventObject<T extends CalendarDataSourceElement> extends CalendarDayEventObject<T> {
199 /**
200 * The clicked button.
201 */
202 which: number;
203 }
205 interface CalendarRenderEndEventObject {
206 /**
207 * The rendered year.
208 */
209 currentYear: number;
210 }
212 interface CalendarRangeEventObject {
213 /**
214 * The beginning of the selected range.
215 */
216 startDate: Date;
218 /**
219 * The end of the selected range.
220 */
221 endDate: Date;
222 }
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;
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;
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;
245 /**
246 * Gets the context menu items.
247 */
248 getContextMenuItems(): CalendarContextMenuItem<T>[];
250 /**
251 * Gets the custom day renderer.
252 */
253 getCustomDayRenderer(): (element: JQuery, currentDate: Date) => void;
255 /**
256 * Gets the custom data source renderer.
257 */
258 getCustomDataSourceRenderer(): (element: JQuery, currentDate: Date, events: T[]) => void;
260 /**
261 * Gets the current data source.
262 */
263 getDataSource(): T[];
265 /**
266 * Gets the disabled days.
267 */
268 getDisableDays(): Date[];
270 /**
271 * Gets a value indicating whether the weeks number are displayed.
272 */
273 getDisplayWeekNumber(): boolean;
275 /**
276 * Gets a value indicating whether the default context menu must be displayed when right clicking on a day.
277 */
278 getEnableContextMenu(): boolean;
280 /**
281 * Gets a value indicating whether the user can make range selection.
282 */
283 getEnableRangeSelection(): boolean;
285 /**
286 * Gets the data source elements for a specified day.
287 *
288 * @param date The specified day.
289 */
290 getEvents(Date: Date): T[];
292 /**
293 * Gets the language used for calendar rendering.
294 */
295 getLanguage(): string;
297 /**
298 * Gets the maximum date of the calendar.
299 */
300 getMaxDate(): Date;
302 /**
303 * Gets the minimum date of the calendar.
304 */
305 getMinDate(): Date;
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;
312 /**
313 * Gets the current style used for displaying data source.
314 */
315 getStyle(): string;
317 /**
318 * Gets the week number for a specified date.
319 *
320 * @param date The specified date.
321 */
322 getWeekNumber(Date: Date): number;
324 /**
325 * Gets the year displayed on the calendar.
326 */
327 getYear(): number;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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 }
445 /**
446 * Basic calendar instance.
447 */
448 interface BaseCalendar extends Calendar<CalendarDataSourceElement> {
450 }
452 interface JQuery {
454 /**
455 * Create a new calendar.
456 */
457 calendar(): BaseCalendar;
459 /**
460 * Create a new calendar.
461 *
462 * @param options The customization options.
463 */
464 calendar(options: CalendarOptions<CalendarDataSourceElement>): BaseCalendar;
466 /**
467 * Create a new calendar.
468 *
469 * @param options The customization options.
470 */
471 calendar<T extends CalendarDataSourceElement>(options: CalendarOptions<T>): Calendar<T>;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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 }