Adds module support to Pikaday

This commit is contained in:
Mikael Selander
2016-01-26 12:42:15 +01:00
parent 46719185c5
commit 037a4d8bbc
2 changed files with 49 additions and 40 deletions
+3 -1
View File
@@ -2,6 +2,8 @@
/// <reference path="../moment/moment.d.ts" />
/// <reference path="pikaday.d.ts" />
import * as Pikaday from "pikaday";
new Pikaday({field: document.getElementById('datepicker')});
new Pikaday({field: $('#datepicker')[0]});
@@ -46,7 +48,7 @@ new Pikaday({field: $('#datepicker')[0]});
})();
(() => {
var i18n:PikadayI18nConfig = {
var i18n: Pikaday.PikadayI18nConfig = {
previousMonth: 'Previous Month',
nextMonth: 'Next Month',
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
+46 -39
View File
@@ -5,48 +5,10 @@
/// <reference path="../moment/moment.d.ts" />
interface PikadayI18nConfig {
previousMonth: string;
nextMonth: string;
months: string[];
weekdays: string[];
weekdaysShort: string[];
}
interface PikadayOptions {
field?: HTMLElement;
format?: string;
trigger?: HTMLElement;
bound?: boolean;
position?: string;
reposition?: boolean;
container?: HTMLElement;
defaultDate?: Date;
setDefaultDate?: boolean;
firstDay?: number;
minDate?: Date;
maxDate?: Date;
disableWeekends?: boolean;
disableDayFn?: (date:Date) => boolean;
yearRange?: number[];
showWeekNumber?: boolean;
isRTL?: boolean;
i18n?: PikadayI18nConfig;
yearSuffix?: string;
showMonthAfterYear?: boolean;
numberOfMonths?: number;
mainCalendar?: string;
theme?: string;
onSelect?: (date:Date) => void;
onOpen?: () => void;
onClose?: () => void;
onDraw?: () => void;
}
declare class Pikaday {
el:HTMLElement;
constructor(options:PikadayOptions);
constructor(options: Pikaday.PikadayOptions);
toString():string;
toString(format:string):string;
@@ -87,3 +49,48 @@ declare class Pikaday {
destroy():void;
}
// merge the Pikaday class declaration with a module
declare module Pikaday {
interface PikadayI18nConfig {
previousMonth: string;
nextMonth: string;
months: string[];
weekdays: string[];
weekdaysShort: string[];
}
interface PikadayOptions {
field?: HTMLElement;
format?: string;
trigger?: HTMLElement;
bound?: boolean;
position?: string;
reposition?: boolean;
container?: HTMLElement;
defaultDate?: Date;
setDefaultDate?: boolean;
firstDay?: number;
minDate?: Date;
maxDate?: Date;
disableWeekends?: boolean;
disableDayFn?: (date:Date) => boolean;
yearRange?: number[];
showWeekNumber?: boolean;
isRTL?: boolean;
i18n?: PikadayI18nConfig;
yearSuffix?: string;
showMonthAfterYear?: boolean;
numberOfMonths?: number;
mainCalendar?: string;
theme?: string;
onSelect?: (date:Date) => void;
onOpen?: () => void;
onClose?: () => void;
onDraw?: () => void;
}
}
declare module "pikaday" {
export = Pikaday;
}