diff bootstrap-year-calendar/bootstrap-year-calendar.d.ts @ 103:4043aaa41075

add bootstrap-year-calendar
author paulo
date Thu, 07 Mar 2019 00:52:02 -0800
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/bootstrap-year-calendar/bootstrap-year-calendar.d.ts	Thu Mar 07 00:52:02 2019 -0800
     1.3 @@ -0,0 +1,543 @@
     1.4 +// Type definitions for bootstrap-year-calendar v1.1.0
     1.5 +// Project: https://github.com/Paul-DS/bootstrap-year-calendar
     1.6 +// Definitions by: Paul David-Sivelle
     1.7 +// Definitions: https://github.com/borisyankov/DefinitelyTyped
     1.8 +
     1.9 +/// <reference path="../jquery/jquery.d.ts"/>
    1.10 +
    1.11 +/**
    1.12 + * Represent a context menu item for the calendar.
    1.13 + */
    1.14 +interface CalendarContextMenuItem<T> {
    1.15 +    /**
    1.16 +     * The text of the menu item.
    1.17 +     */
    1.18 +    text: string;
    1.19 +
    1.20 +    /**
    1.21 +     * A function to be called when the item is clicked.
    1.22 +     */
    1.23 +    click?: (event: T) => void;
    1.24 +
    1.25 +    /**
    1.26 +     * The list of sub menu items.
    1.27 +     */
    1.28 +    submenu?: CalendarContextMenuItem<T>[];
    1.29 +}
    1.30 +
    1.31 +/**
    1.32 + * Represent an element to display in the calendar.
    1.33 + */
    1.34 +interface CalendarDataSourceElement {
    1.35 +	/**
    1.36 +     * The name of the element. Used for context menu or specific events.
    1.37 +     */
    1.38 +    name?: string;
    1.39 +
    1.40 +    /**
    1.41 +     * The color of the element. This property will be computed automatically if not defined.
    1.42 +     */
    1.43 +    color?: string;
    1.44 +	
    1.45 +    /**
    1.46 +     * The date of the beginning of the element range.
    1.47 +     */
    1.48 +    startDate: Date;
    1.49 +
    1.50 +    /**
    1.51 +     * The date of the end of the element range.
    1.52 +     */
    1.53 +    endDate: Date;
    1.54 +	
    1.55 +	/**
    1.56 +     * Indicates whether only the half of start day of the element range should be rendered.
    1.57 +     */
    1.58 +    startHalfDay?: boolean;
    1.59 +
    1.60 +    /**
    1.61 +     * Indicates whether only the half of last day of the element range should be rendered.
    1.62 +     */
    1.63 +    endHalfDay?: boolean;
    1.64 +}
    1.65 +
    1.66 +/**
    1.67 + * Options used for calendar customization.
    1.68 + */
    1.69 +interface CalendarOptions<T extends CalendarDataSourceElement> {
    1.70 +
    1.71 +    /**
    1.72 +     * Specifies whether the user can select a range which overlapping an other element present in the datasource.
    1.73 +     */
    1.74 +    allowOverlap?: boolean;
    1.75 +
    1.76 +	/**
    1.77 +     * Specifies whether the beginning and the end of each range should be displayed as half selected day.
    1.78 +     */
    1.79 +    alwaysHalfDay?: boolean;
    1.80 +	
    1.81 +    /**
    1.82 +     * Specifies the items of the default context menu.
    1.83 +     */
    1.84 +    contextMenuItems?: CalendarContextMenuItem<T>[];
    1.85 +	
    1.86 +	/**
    1.87 +     * Specify a custom renderer for days.
    1.88 +	 * This function is called during render for each day.
    1.89 +     */
    1.90 +    customDayRenderer?: (element: JQuery, currentDate: Date) => void;
    1.91 +	
    1.92 +	/**
    1.93 +     * Specify a custom renderer for data source. Works only with the style set to "custom".
    1.94 +	 * This function is called during render for each day containing at least one event.
    1.95 +     */
    1.96 +    customDataSourceRenderer?: (element: JQuery, currentDate: Date, events: T[]) => void;
    1.97 +
    1.98 +    /**
    1.99 +     * The elements that must be displayed on the calendar.
   1.100 +     */
   1.101 +    dataSource?: T[];
   1.102 +
   1.103 +    /**
   1.104 +     * The days that must be displayed as disabled.
   1.105 +     */
   1.106 +    disableDays?: Date[];
   1.107 +
   1.108 +    /**
   1.109 +     * Specifies whether the weeks number are displayed.
   1.110 +     */
   1.111 +    displayWeekNumber?: boolean;
   1.112 +
   1.113 +    /**
   1.114 +     * Specifies whether the default context menu must be displayed when right clicking on a day.
   1.115 +     */
   1.116 +    enableContextMenu?: boolean;
   1.117 +
   1.118 +    /**
   1.119 +     * Specifies whether the range selection is enabled.
   1.120 +     */
   1.121 +    enableRangeSelection?: boolean;
   1.122 +
   1.123 +    /**
   1.124 +     * The language/culture used for calendar rendering.
   1.125 +     */
   1.126 +    language?: string;
   1.127 +
   1.128 +    /**
   1.129 +     * The date until which days are enabled.
   1.130 +     */
   1.131 +    maxDate?: Date;
   1.132 +
   1.133 +    /**
   1.134 +     * The date from which days are enabled.
   1.135 +     */
   1.136 +    minDate?: Date;
   1.137 +	
   1.138 +	/**
   1.139 +     * Specifies whether the beginning and the end of each range should be displayed as rounded cells.
   1.140 +     */
   1.141 +    roundRangeLimits?: boolean;
   1.142 +
   1.143 +    /**
   1.144 +     * The year on which the calendar should be opened.
   1.145 +     */
   1.146 +    startYear?: number;
   1.147 +
   1.148 +    /**
   1.149 +     * Specifies the style used for displaying datasource ("background", "border" or "custom").
   1.150 +     */
   1.151 +    style?: string;
   1.152 +	
   1.153 +    /**
   1.154 +     * Function fired when a day is clicked.
   1.155 +     */
   1.156 +    clickDay?: (e: CalendarClickEventObject<T>) => void;
   1.157 +
   1.158 +    /**
   1.159 +     * Function fired when a day is right clicked.
   1.160 +     */
   1.161 +    dayContextMenu?: (e: CalendarDayEventObject<T>) => void;
   1.162 +
   1.163 +    /**
   1.164 +     * Function fired when the mouse enter on a day.
   1.165 +     */
   1.166 +    mouseOnDay?: (e: CalendarDayEventObject<T>) => void;
   1.167 +
   1.168 +    /**
   1.169 +     * Function fired when the mouse leaves a day.
   1.170 +     */
   1.171 +    mouseOutDay?: (e: CalendarDayEventObject<T>) => void;
   1.172 +
   1.173 +    /**
   1.174 +     * Function fired when the calendar rendering is ended.
   1.175 +     */
   1.176 +    renderEnd?: (e: CalendarRenderEndEventObject) => void;
   1.177 +
   1.178 +    /**
   1.179 +     * Function fired when a date range is selected.
   1.180 +     */
   1.181 +    selectRange?: (e: CalendarRangeEventObject) => void;
   1.182 +}
   1.183 +
   1.184 +interface CalendarDayEventObject<T extends CalendarDataSourceElement> {
   1.185 +    /**
   1.186 +     * The element that contain the fired day.
   1.187 +     */
   1.188 +    element: JQuery;
   1.189 +
   1.190 +    /**
   1.191 +     * The fired date.
   1.192 +     */
   1.193 +    date: Date;
   1.194 +	
   1.195 +	/**
   1.196 +     * The data source elements present on the fired day.
   1.197 +     */
   1.198 +    events: T[];
   1.199 +}
   1.200 +
   1.201 +interface CalendarClickEventObject<T extends CalendarDataSourceElement> extends CalendarDayEventObject<T> {
   1.202 +    /**
   1.203 +     * The clicked button.
   1.204 +     */
   1.205 +    which: number;
   1.206 +}
   1.207 +
   1.208 +interface CalendarRenderEndEventObject {
   1.209 +    /**
   1.210 +     * The rendered year.
   1.211 +     */
   1.212 +    currentYear: number;
   1.213 +}
   1.214 +
   1.215 +interface CalendarRangeEventObject {
   1.216 +    /**
   1.217 +     * The beginning of the selected range.
   1.218 +     */
   1.219 +    startDate: Date;
   1.220 +
   1.221 +    /**
   1.222 +     * The end of the selected range.
   1.223 +     */
   1.224 +    endDate: Date;
   1.225 +}
   1.226 +
   1.227 +/**
   1.228 + * Calendar instance.
   1.229 + */
   1.230 +interface Calendar<T extends CalendarDataSourceElement> {
   1.231 +    /**
   1.232 +     * Add a new element to the data source. This method causes a refresh of the calendar.
   1.233 +     * 
   1.234 +     * @param element The element to add.
   1.235 +     */
   1.236 +    addEvent(element: T): void;
   1.237 +
   1.238 +    /**
   1.239 +     * Gets a value indicating whether the user can select a range which overlapping an other element present in the datasource.
   1.240 +     */
   1.241 +    getAllowOverlap(): boolean;
   1.242 +	
   1.243 +	/**
   1.244 +     * Gets a value indicating whether the beginning and the end of each range should be displayed as half selected day.
   1.245 +     */
   1.246 +    getAlwaysHalfDay(): boolean;
   1.247 +
   1.248 +    /**
   1.249 +     * Gets the context menu items.
   1.250 +     */
   1.251 +    getContextMenuItems(): CalendarContextMenuItem<T>[];
   1.252 +	
   1.253 +	/**
   1.254 +     * Gets the custom day renderer.
   1.255 +     */
   1.256 +    getCustomDayRenderer(): (element: JQuery, currentDate: Date) => void;
   1.257 +	
   1.258 +	/**
   1.259 +     * Gets the custom data source renderer.
   1.260 +     */
   1.261 +    getCustomDataSourceRenderer(): (element: JQuery, currentDate: Date, events: T[]) => void;
   1.262 +
   1.263 +    /**
   1.264 +     * Gets the current data source.
   1.265 +     */
   1.266 +    getDataSource(): T[];
   1.267 +
   1.268 +    /**
   1.269 +     * Gets the disabled days.
   1.270 +     */
   1.271 +    getDisableDays(): Date[];
   1.272 +
   1.273 +    /**
   1.274 +     * Gets a value indicating whether the weeks number are displayed.
   1.275 +     */
   1.276 +    getDisplayWeekNumber(): boolean;
   1.277 +
   1.278 +    /**
   1.279 +     * Gets a value indicating whether the default context menu must be displayed when right clicking on a day.
   1.280 +     */
   1.281 +    getEnableContextMenu(): boolean;
   1.282 +
   1.283 +    /**
   1.284 +     * Gets a value indicating whether the user can make range selection.
   1.285 +     */
   1.286 +    getEnableRangeSelection(): boolean;
   1.287 +
   1.288 +    /**
   1.289 +     * Gets the data source elements for a specified day.
   1.290 +     *
   1.291 +     * @param date The specified day.
   1.292 +     */
   1.293 +    getEvents(Date: Date): T[];
   1.294 +
   1.295 +    /**
   1.296 +     * Gets the language used for calendar rendering.
   1.297 +     */
   1.298 +    getLanguage(): string;
   1.299 +
   1.300 +    /**
   1.301 +     * Gets the maximum date of the calendar.
   1.302 +     */
   1.303 +    getMaxDate(): Date;
   1.304 +
   1.305 +    /**
   1.306 +     * Gets the minimum date of the calendar.
   1.307 +     */
   1.308 +    getMinDate(): Date;
   1.309 +	
   1.310 +	/**
   1.311 +     * Gets a value indicating whether the beginning and the end of each range should be displayed as rounded cells.
   1.312 +     */
   1.313 +    getRoundRangeLimits(): void;
   1.314 +
   1.315 +    /**
   1.316 +     * Gets the current style used for displaying data source.
   1.317 +     */
   1.318 +    getStyle(): string;
   1.319 +
   1.320 +    /**
   1.321 +     * Gets the week number for a specified date.
   1.322 +     *
   1.323 +     * @param date The specified date.
   1.324 +     */
   1.325 +    getWeekNumber(Date: Date): number;
   1.326 +
   1.327 +    /**
   1.328 +     * Gets the year displayed on the calendar.
   1.329 +     */
   1.330 +    getYear(): number;
   1.331 +	
   1.332 +    /**
   1.333 +     * Sets a value indicating whether the user can select a range which overlapping an other element present in the datasource.
   1.334 +     *
   1.335 +     * @param allowOverlap Indicates whether the user can select a range which overlapping an other element present in the datasource.
   1.336 +     */
   1.337 +    setAllowOverlap(allowOverlap: boolean): void;
   1.338 +
   1.339 +	/**
   1.340 +     * Sets a value indicating whether the beginning and the end of each range should be displayed as half selected day.
   1.341 +	 * This method causes a refresh of the calendar.
   1.342 +     *
   1.343 +     * @param alwaysHalfDay Indicates whether the beginning and the end of each range should be displayed as half selected day.
   1.344 +     */
   1.345 +    setAlwaysHalfDay(alwaysHalfDay: boolean): void;
   1.346 +	
   1.347 +    /**
   1.348 +     * Sets new context menu items. This method causes a refresh of the calendar.
   1.349 +     *
   1.350 +     * @param contextMenuItems The new context menu items.
   1.351 +     */
   1.352 +    setContextMenuItems(contextMenuItems: CalendarContextMenuItem<T>[]): void;
   1.353 +	
   1.354 +	/**
   1.355 +     * Sets the custom day renderer.
   1.356 +	 *
   1.357 +	  * @param handler The function used to render the days. This function is called during render for each day.
   1.358 +     */
   1.359 +    setCustomDayRenderer(handler: (element: JQuery, currentDate: Date) => void): void;
   1.360 +	
   1.361 +	/**
   1.362 +     * Sets the custom data source renderer. Works only with the style set to "custom".
   1.363 +	 *
   1.364 +	  * @param handler The function used to render the data source. This function is called during render for each day containing at least one event.
   1.365 +     */
   1.366 +    setCustomDataSourceRenderer(handler: (element: JQuery, currentDate: Date, events: T[]) => void): void;
   1.367 +
   1.368 +    /**
   1.369 +     * Sets a new data source. This method causes a refresh of the calendar.
   1.370 +     *
   1.371 +     * @param dataSource The new data source.
   1.372 +     */
   1.373 +    setDataSource(dataSource: T[]): void;
   1.374 +
   1.375 +    /**
   1.376 +     * Sets the disabled days. This method causes a refresh of the calendar.
   1.377 +     *
   1.378 +     * @param disableDays The disabled days to set.
   1.379 +     */
   1.380 +    setDisableDays(disableDays: Date[]): void;
   1.381 +
   1.382 +    /**
   1.383 +     * Sets a value indicating whether the weeks number are displayed. This method causes a refresh of the calendar.
   1.384 +     *
   1.385 +     * @param  displayWeekNumber Indicates whether the weeks number are displayed.
   1.386 +     */
   1.387 +    setDisplayWeekNumber(displayWeekNumber: boolean): void;
   1.388 +
   1.389 +    /**
   1.390 +     * Sets a value indicating whether the default context menu must be displayed when right clicking on a day. 
   1.391 +     * This method causes a refresh of the calendar.
   1.392 +     * 
   1.393 +     * @param enableContextMenu Indicates whether the default context menu must be displayed when right clicking on a day.
   1.394 +     */
   1.395 +    setEnableContextMenu(enableContextMenu: boolean): void;
   1.396 +
   1.397 +    /**
   1.398 +     * Sets a value indicating whether the user can make range selection. This method causes a refresh of the calendar.
   1.399 +     *
   1.400 +     * @param enableRangeSelection Indicates whether the user can make range selection.
   1.401 +     */
   1.402 +    setEnableRangeSelection(enableRangeSelection: boolean): void;
   1.403 +
   1.404 +    /**
   1.405 +     * Sets the language used for calendar rendering. This method causes a refresh of the calendar.
   1.406 +     *
   1.407 +     * @param language The language to use for calendar redering.
   1.408 +     */
   1.409 +    setLanguage(language: string): void;
   1.410 +
   1.411 +    /**
   1.412 +     * Sets the maximum date of the calendar. This method causes a refresh of the calendar.
   1.413 +     *
   1.414 +     * @param maxDate The maximum date to set.
   1.415 +     */
   1.416 +    setMaxDate(maxDate: Date): void;
   1.417 +
   1.418 +    /**
   1.419 +     * Sets the minimum date of the calendar. This method causes a refresh of the calendar.
   1.420 +     *
   1.421 +     * @param minDate The minimum date to set.
   1.422 +     */
   1.423 +    setMinDate(minDate: Date): void;
   1.424 +	
   1.425 +	/**
   1.426 +     * Sets a value indicating whether the beginning and the end of each range should be displayed as rounded cells.
   1.427 +	 * This method causes a refresh of the calendar.
   1.428 +     *
   1.429 +     * @param roundRangeLimits Indicates whether the beginning and the end of each range should be displayed as rounded cells. 
   1.430 +     */
   1.431 +    setRoundRangeLimits(roundRangeLimits: boolean): void;
   1.432 +
   1.433 +    /**
   1.434 +     * Sets the style to use for displaying data source. This method causes a refresh of the calendar.
   1.435 +     *
   1.436 +     * @param style The style to use for displaying data source ("background", "border" or "custom").
   1.437 +     */
   1.438 +    setStyle(style: string): void;
   1.439 +
   1.440 +    /**
   1.441 +     * Sets the year displayed on the calendar.
   1.442 +     *
   1.443 +     * @param year The year to displayed on the calendar.
   1.444 +     */
   1.445 +    setYear(year: number): void;
   1.446 +}
   1.447 +
   1.448 +/**
   1.449 + * Basic calendar instance.
   1.450 + */
   1.451 +interface BaseCalendar extends Calendar<CalendarDataSourceElement> {
   1.452 +
   1.453 +}
   1.454 +
   1.455 +interface JQuery {
   1.456 +
   1.457 +    /**
   1.458 +     * Create a new calendar.
   1.459 +     */
   1.460 +    calendar(): BaseCalendar;
   1.461 +
   1.462 +    /**
   1.463 +     * Create a new calendar.
   1.464 +     *
   1.465 +     * @param options The customization options.
   1.466 +     */
   1.467 +    calendar(options: CalendarOptions<CalendarDataSourceElement>): BaseCalendar;
   1.468 +
   1.469 +    /**
   1.470 +     * Create a new calendar.
   1.471 +     *
   1.472 +     * @param options The customization options.
   1.473 +     */
   1.474 +    calendar<T extends CalendarDataSourceElement>(options: CalendarOptions<T>): Calendar<T>;
   1.475 +	
   1.476 +
   1.477 +    /**
   1.478 +     * Function fired when a day is clicked (for bootstrap-year-calendar only).
   1.479 +     *
   1.480 +     * @param handler A function to execute each time the event is triggered.
   1.481 +     */
   1.482 +    clickDay(handler: (e: CalendarClickEventObject<CalendarDataSourceElement>) => void): JQuery;
   1.483 +
   1.484 +    /**
   1.485 +     * Function fired when a day is clicked (for bootstrap-year-calendar only).
   1.486 +     *
   1.487 +     * @param handler A function to execute each time the event is triggered.
   1.488 +     */
   1.489 +    clickDay<T extends CalendarDataSourceElement>(handler: (e: CalendarClickEventObject<T>) => void): JQuery;
   1.490 +
   1.491 +    /**
   1.492 +     * Function fired when a day is right clicked (for bootstrap-year-calendar only).
   1.493 +     *
   1.494 +     * @param handler A function to execute each time the event is triggered.
   1.495 +     */
   1.496 +    dayContextMenu(handler: (e: CalendarDayEventObject<CalendarDataSourceElement>) => void): JQuery;
   1.497 +
   1.498 +    /**
   1.499 +     * Function fired when a day is right clicked (for bootstrap-year-calendar only).
   1.500 +     *
   1.501 +     * @param handler A function to execute each time the event is triggered.
   1.502 +     */
   1.503 +    dayContextMenu<T extends CalendarDataSourceElement>(handler: (e: CalendarDayEventObject<T>) => void): JQuery;
   1.504 +
   1.505 +    /**
   1.506 +     * Function fired when the mouse enter on a day (for bootstrap-year-calendar only).
   1.507 +     *
   1.508 +     * @param handler A function to execute each time the event is triggered.
   1.509 +     */
   1.510 +    mouseOnDay(handler: (e: CalendarDayEventObject<CalendarDataSourceElement>) => void): JQuery;
   1.511 +
   1.512 +    /**
   1.513 +     * Function fired when the mouse enter on a day (for bootstrap-year-calendar only).
   1.514 +     *
   1.515 +     * @param handler A function to execute each time the event is triggered.
   1.516 +     */
   1.517 +    mouseOnDay<T extends CalendarDataSourceElement>(handler: (e: CalendarDayEventObject<T>) => void): JQuery;
   1.518 +
   1.519 +    /**
   1.520 +     * Function fired when the mouse leaves a day (for bootstrap-year-calendar only).
   1.521 +     *
   1.522 +     * @param handler A function to execute each time the event is triggered.
   1.523 +     */
   1.524 +    mouseOutDay(handler: (e: CalendarDayEventObject<CalendarDataSourceElement>) => void): JQuery;
   1.525 +
   1.526 +    /**
   1.527 +     * Function fired when the mouse leaves a day (for bootstrap-year-calendar only).
   1.528 +     *
   1.529 +     * @param handler A function to execute each time the event is triggered.
   1.530 +     */
   1.531 +    mouseOutDay<T extends CalendarDataSourceElement>(handler: (e: CalendarDayEventObject<T>) => void): JQuery;
   1.532 +
   1.533 +    /**
   1.534 +     * Function fired when the calendar rendering is ended (for bootstrap-year-calendar only).
   1.535 +     *
   1.536 +     * @param handler A function to execute each time the event is triggered.
   1.537 +     */
   1.538 +    renderEnd(handler: (e: CalendarRenderEndEventObject) => void): JQuery;
   1.539 +
   1.540 +    /**
   1.541 +     * Function fired when a date range is selected (for bootstrap-year-calendar only).
   1.542 +     *
   1.543 +     * @param handler A function to execute each time the event is triggered.
   1.544 +     */
   1.545 +    selectRange(handler: (e: CalendarRangeEventObject) => void): JQuery;
   1.546 +}