annotate bootstrap-year-calendar/bootstrap-year-calendar.d.ts @ 107:24a967efbf3e

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