paulo@103: // Type definitions for bootstrap-year-calendar v1.1.0 paulo@103: // Project: https://github.com/Paul-DS/bootstrap-year-calendar paulo@103: // Definitions by: Paul David-Sivelle paulo@103: // Definitions: https://github.com/borisyankov/DefinitelyTyped paulo@103: paulo@103: /// paulo@103: paulo@103: /** paulo@103: * Represent a context menu item for the calendar. paulo@103: */ paulo@103: interface CalendarContextMenuItem { paulo@103: /** paulo@103: * The text of the menu item. paulo@103: */ paulo@103: text: string; paulo@103: paulo@103: /** paulo@103: * A function to be called when the item is clicked. paulo@103: */ paulo@103: click?: (event: T) => void; paulo@103: paulo@103: /** paulo@103: * The list of sub menu items. paulo@103: */ paulo@103: submenu?: CalendarContextMenuItem[]; paulo@103: } paulo@103: paulo@103: /** paulo@103: * Represent an element to display in the calendar. paulo@103: */ paulo@103: interface CalendarDataSourceElement { paulo@103: /** paulo@103: * The name of the element. Used for context menu or specific events. paulo@103: */ paulo@103: name?: string; paulo@103: paulo@103: /** paulo@103: * The color of the element. This property will be computed automatically if not defined. paulo@103: */ paulo@103: color?: string; paulo@103: paulo@103: /** paulo@103: * The date of the beginning of the element range. paulo@103: */ paulo@103: startDate: Date; paulo@103: paulo@103: /** paulo@103: * The date of the end of the element range. paulo@103: */ paulo@103: endDate: Date; paulo@103: paulo@103: /** paulo@103: * Indicates whether only the half of start day of the element range should be rendered. paulo@103: */ paulo@103: startHalfDay?: boolean; paulo@103: paulo@103: /** paulo@103: * Indicates whether only the half of last day of the element range should be rendered. paulo@103: */ paulo@103: endHalfDay?: boolean; paulo@103: } paulo@103: paulo@103: /** paulo@103: * Options used for calendar customization. paulo@103: */ paulo@103: interface CalendarOptions { paulo@103: paulo@103: /** paulo@103: * Specifies whether the user can select a range which overlapping an other element present in the datasource. paulo@103: */ paulo@103: allowOverlap?: boolean; paulo@103: paulo@103: /** paulo@103: * Specifies whether the beginning and the end of each range should be displayed as half selected day. paulo@103: */ paulo@103: alwaysHalfDay?: boolean; paulo@103: paulo@103: /** paulo@103: * Specifies the items of the default context menu. paulo@103: */ paulo@103: contextMenuItems?: CalendarContextMenuItem[]; paulo@103: paulo@103: /** paulo@103: * Specify a custom renderer for days. paulo@103: * This function is called during render for each day. paulo@103: */ paulo@103: customDayRenderer?: (element: JQuery, currentDate: Date) => void; paulo@103: paulo@103: /** paulo@103: * Specify a custom renderer for data source. Works only with the style set to "custom". paulo@103: * This function is called during render for each day containing at least one event. paulo@103: */ paulo@103: customDataSourceRenderer?: (element: JQuery, currentDate: Date, events: T[]) => void; paulo@103: paulo@103: /** paulo@103: * The elements that must be displayed on the calendar. paulo@103: */ paulo@103: dataSource?: T[]; paulo@103: paulo@103: /** paulo@103: * The days that must be displayed as disabled. paulo@103: */ paulo@103: disableDays?: Date[]; paulo@103: paulo@103: /** paulo@103: * Specifies whether the weeks number are displayed. paulo@103: */ paulo@103: displayWeekNumber?: boolean; paulo@103: paulo@103: /** paulo@103: * Specifies whether the default context menu must be displayed when right clicking on a day. paulo@103: */ paulo@103: enableContextMenu?: boolean; paulo@103: paulo@103: /** paulo@103: * Specifies whether the range selection is enabled. paulo@103: */ paulo@103: enableRangeSelection?: boolean; paulo@103: paulo@103: /** paulo@103: * The language/culture used for calendar rendering. paulo@103: */ paulo@103: language?: string; paulo@103: paulo@103: /** paulo@103: * The date until which days are enabled. paulo@103: */ paulo@103: maxDate?: Date; paulo@103: paulo@103: /** paulo@103: * The date from which days are enabled. paulo@103: */ paulo@103: minDate?: Date; paulo@103: paulo@103: /** paulo@103: * Specifies whether the beginning and the end of each range should be displayed as rounded cells. paulo@103: */ paulo@103: roundRangeLimits?: boolean; paulo@103: paulo@103: /** paulo@103: * The year on which the calendar should be opened. paulo@103: */ paulo@103: startYear?: number; paulo@103: paulo@103: /** paulo@103: * Specifies the style used for displaying datasource ("background", "border" or "custom"). paulo@103: */ paulo@103: style?: string; paulo@103: paulo@103: /** paulo@103: * Function fired when a day is clicked. paulo@103: */ paulo@103: clickDay?: (e: CalendarClickEventObject) => void; paulo@103: paulo@103: /** paulo@103: * Function fired when a day is right clicked. paulo@103: */ paulo@103: dayContextMenu?: (e: CalendarDayEventObject) => void; paulo@103: paulo@103: /** paulo@103: * Function fired when the mouse enter on a day. paulo@103: */ paulo@103: mouseOnDay?: (e: CalendarDayEventObject) => void; paulo@103: paulo@103: /** paulo@103: * Function fired when the mouse leaves a day. paulo@103: */ paulo@103: mouseOutDay?: (e: CalendarDayEventObject) => void; paulo@103: paulo@103: /** paulo@103: * Function fired when the calendar rendering is ended. paulo@103: */ paulo@103: renderEnd?: (e: CalendarRenderEndEventObject) => void; paulo@103: paulo@103: /** paulo@103: * Function fired when a date range is selected. paulo@103: */ paulo@103: selectRange?: (e: CalendarRangeEventObject) => void; paulo@103: } paulo@103: paulo@103: interface CalendarDayEventObject { paulo@103: /** paulo@103: * The element that contain the fired day. paulo@103: */ paulo@103: element: JQuery; paulo@103: paulo@103: /** paulo@103: * The fired date. paulo@103: */ paulo@103: date: Date; paulo@103: paulo@103: /** paulo@103: * The data source elements present on the fired day. paulo@103: */ paulo@103: events: T[]; paulo@103: } paulo@103: paulo@103: interface CalendarClickEventObject extends CalendarDayEventObject { paulo@103: /** paulo@103: * The clicked button. paulo@103: */ paulo@103: which: number; paulo@103: } paulo@103: paulo@103: interface CalendarRenderEndEventObject { paulo@103: /** paulo@103: * The rendered year. paulo@103: */ paulo@103: currentYear: number; paulo@103: } paulo@103: paulo@103: interface CalendarRangeEventObject { paulo@103: /** paulo@103: * The beginning of the selected range. paulo@103: */ paulo@103: startDate: Date; paulo@103: paulo@103: /** paulo@103: * The end of the selected range. paulo@103: */ paulo@103: endDate: Date; paulo@103: } paulo@103: paulo@103: /** paulo@103: * Calendar instance. paulo@103: */ paulo@103: interface Calendar { paulo@103: /** paulo@103: * Add a new element to the data source. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param element The element to add. paulo@103: */ paulo@103: addEvent(element: T): void; paulo@103: paulo@103: /** paulo@103: * Gets a value indicating whether the user can select a range which overlapping an other element present in the datasource. paulo@103: */ paulo@103: getAllowOverlap(): boolean; paulo@103: paulo@103: /** paulo@103: * Gets a value indicating whether the beginning and the end of each range should be displayed as half selected day. paulo@103: */ paulo@103: getAlwaysHalfDay(): boolean; paulo@103: paulo@103: /** paulo@103: * Gets the context menu items. paulo@103: */ paulo@103: getContextMenuItems(): CalendarContextMenuItem[]; paulo@103: paulo@103: /** paulo@103: * Gets the custom day renderer. paulo@103: */ paulo@103: getCustomDayRenderer(): (element: JQuery, currentDate: Date) => void; paulo@103: paulo@103: /** paulo@103: * Gets the custom data source renderer. paulo@103: */ paulo@103: getCustomDataSourceRenderer(): (element: JQuery, currentDate: Date, events: T[]) => void; paulo@103: paulo@103: /** paulo@103: * Gets the current data source. paulo@103: */ paulo@103: getDataSource(): T[]; paulo@103: paulo@103: /** paulo@103: * Gets the disabled days. paulo@103: */ paulo@103: getDisableDays(): Date[]; paulo@103: paulo@103: /** paulo@103: * Gets a value indicating whether the weeks number are displayed. paulo@103: */ paulo@103: getDisplayWeekNumber(): boolean; paulo@103: paulo@103: /** paulo@103: * Gets a value indicating whether the default context menu must be displayed when right clicking on a day. paulo@103: */ paulo@103: getEnableContextMenu(): boolean; paulo@103: paulo@103: /** paulo@103: * Gets a value indicating whether the user can make range selection. paulo@103: */ paulo@103: getEnableRangeSelection(): boolean; paulo@103: paulo@103: /** paulo@103: * Gets the data source elements for a specified day. paulo@103: * paulo@103: * @param date The specified day. paulo@103: */ paulo@103: getEvents(Date: Date): T[]; paulo@103: paulo@103: /** paulo@103: * Gets the language used for calendar rendering. paulo@103: */ paulo@103: getLanguage(): string; paulo@103: paulo@103: /** paulo@103: * Gets the maximum date of the calendar. paulo@103: */ paulo@103: getMaxDate(): Date; paulo@103: paulo@103: /** paulo@103: * Gets the minimum date of the calendar. paulo@103: */ paulo@103: getMinDate(): Date; paulo@103: paulo@103: /** paulo@103: * Gets a value indicating whether the beginning and the end of each range should be displayed as rounded cells. paulo@103: */ paulo@103: getRoundRangeLimits(): void; paulo@103: paulo@103: /** paulo@103: * Gets the current style used for displaying data source. paulo@103: */ paulo@103: getStyle(): string; paulo@103: paulo@103: /** paulo@103: * Gets the week number for a specified date. paulo@103: * paulo@103: * @param date The specified date. paulo@103: */ paulo@103: getWeekNumber(Date: Date): number; paulo@103: paulo@103: /** paulo@103: * Gets the year displayed on the calendar. paulo@103: */ paulo@103: getYear(): number; paulo@103: paulo@103: /** paulo@103: * Sets a value indicating whether the user can select a range which overlapping an other element present in the datasource. paulo@103: * paulo@103: * @param allowOverlap Indicates whether the user can select a range which overlapping an other element present in the datasource. paulo@103: */ paulo@103: setAllowOverlap(allowOverlap: boolean): void; paulo@103: paulo@103: /** paulo@103: * Sets a value indicating whether the beginning and the end of each range should be displayed as half selected day. paulo@103: * This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param alwaysHalfDay Indicates whether the beginning and the end of each range should be displayed as half selected day. paulo@103: */ paulo@103: setAlwaysHalfDay(alwaysHalfDay: boolean): void; paulo@103: paulo@103: /** paulo@103: * Sets new context menu items. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param contextMenuItems The new context menu items. paulo@103: */ paulo@103: setContextMenuItems(contextMenuItems: CalendarContextMenuItem[]): void; paulo@103: paulo@103: /** paulo@103: * Sets the custom day renderer. paulo@103: * paulo@103: * @param handler The function used to render the days. This function is called during render for each day. paulo@103: */ paulo@103: setCustomDayRenderer(handler: (element: JQuery, currentDate: Date) => void): void; paulo@103: paulo@103: /** paulo@103: * Sets the custom data source renderer. Works only with the style set to "custom". paulo@103: * paulo@103: * @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: */ paulo@103: setCustomDataSourceRenderer(handler: (element: JQuery, currentDate: Date, events: T[]) => void): void; paulo@103: paulo@103: /** paulo@103: * Sets a new data source. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param dataSource The new data source. paulo@103: */ paulo@103: setDataSource(dataSource: T[]): void; paulo@103: paulo@103: /** paulo@103: * Sets the disabled days. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param disableDays The disabled days to set. paulo@103: */ paulo@103: setDisableDays(disableDays: Date[]): void; paulo@103: paulo@103: /** paulo@103: * Sets a value indicating whether the weeks number are displayed. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param displayWeekNumber Indicates whether the weeks number are displayed. paulo@103: */ paulo@103: setDisplayWeekNumber(displayWeekNumber: boolean): void; paulo@103: paulo@103: /** paulo@103: * Sets a value indicating whether the default context menu must be displayed when right clicking on a day. paulo@103: * This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param enableContextMenu Indicates whether the default context menu must be displayed when right clicking on a day. paulo@103: */ paulo@103: setEnableContextMenu(enableContextMenu: boolean): void; paulo@103: paulo@103: /** paulo@103: * Sets a value indicating whether the user can make range selection. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param enableRangeSelection Indicates whether the user can make range selection. paulo@103: */ paulo@103: setEnableRangeSelection(enableRangeSelection: boolean): void; paulo@103: paulo@103: /** paulo@103: * Sets the language used for calendar rendering. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param language The language to use for calendar redering. paulo@103: */ paulo@103: setLanguage(language: string): void; paulo@103: paulo@103: /** paulo@103: * Sets the maximum date of the calendar. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param maxDate The maximum date to set. paulo@103: */ paulo@103: setMaxDate(maxDate: Date): void; paulo@103: paulo@103: /** paulo@103: * Sets the minimum date of the calendar. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param minDate The minimum date to set. paulo@103: */ paulo@103: setMinDate(minDate: Date): void; paulo@103: paulo@103: /** paulo@103: * Sets a value indicating whether the beginning and the end of each range should be displayed as rounded cells. paulo@103: * This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param roundRangeLimits Indicates whether the beginning and the end of each range should be displayed as rounded cells. paulo@103: */ paulo@103: setRoundRangeLimits(roundRangeLimits: boolean): void; paulo@103: paulo@103: /** paulo@103: * Sets the style to use for displaying data source. This method causes a refresh of the calendar. paulo@103: * paulo@103: * @param style The style to use for displaying data source ("background", "border" or "custom"). paulo@103: */ paulo@103: setStyle(style: string): void; paulo@103: paulo@103: /** paulo@103: * Sets the year displayed on the calendar. paulo@103: * paulo@103: * @param year The year to displayed on the calendar. paulo@103: */ paulo@103: setYear(year: number): void; paulo@103: } paulo@103: paulo@103: /** paulo@103: * Basic calendar instance. paulo@103: */ paulo@103: interface BaseCalendar extends Calendar { paulo@103: paulo@103: } paulo@103: paulo@103: interface JQuery { paulo@103: paulo@103: /** paulo@103: * Create a new calendar. paulo@103: */ paulo@103: calendar(): BaseCalendar; paulo@103: paulo@103: /** paulo@103: * Create a new calendar. paulo@103: * paulo@103: * @param options The customization options. paulo@103: */ paulo@103: calendar(options: CalendarOptions): BaseCalendar; paulo@103: paulo@103: /** paulo@103: * Create a new calendar. paulo@103: * paulo@103: * @param options The customization options. paulo@103: */ paulo@103: calendar(options: CalendarOptions): Calendar; paulo@103: paulo@103: paulo@103: /** paulo@103: * Function fired when a day is clicked (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: clickDay(handler: (e: CalendarClickEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when a day is clicked (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: clickDay(handler: (e: CalendarClickEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when a day is right clicked (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: dayContextMenu(handler: (e: CalendarDayEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when a day is right clicked (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: dayContextMenu(handler: (e: CalendarDayEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when the mouse enter on a day (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: mouseOnDay(handler: (e: CalendarDayEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when the mouse enter on a day (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: mouseOnDay(handler: (e: CalendarDayEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when the mouse leaves a day (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: mouseOutDay(handler: (e: CalendarDayEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when the mouse leaves a day (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: mouseOutDay(handler: (e: CalendarDayEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when the calendar rendering is ended (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: renderEnd(handler: (e: CalendarRenderEndEventObject) => void): JQuery; paulo@103: paulo@103: /** paulo@103: * Function fired when a date range is selected (for bootstrap-year-calendar only). paulo@103: * paulo@103: * @param handler A function to execute each time the event is triggered. paulo@103: */ paulo@103: selectRange(handler: (e: CalendarRangeEventObject) => void): JQuery; paulo@103: }