﻿declare namespace web2cal {
    interface GroupData {
        name: string;
        groupId: string;
        show?: boolean;
        events: Array<EventData>;
        color?: ItemColor;
    }

    interface CalendarGroup {
        color: ItemColor;
        entities: Array<any>;
        groupId: string;
        groupName: string;
        workDay: Array<any>;
    }

    interface ItemColor {
        color: string;
        css: string;
    }

    interface ScheduledEvent {
        endTime: Date;
        startTime: Date;
    }

    interface EventData extends ScheduledEvent {
        eventId: number;

        groupId: string;

        name: string;
        eventName?: string;

        description: string;

        _startTime?: UTC,
        _endTime?: UTC,
        formattedStartTime?: string;
        formattedEndTime?: string;

        location: string;
        instructor: string;
        allDay: boolean;

        repeatEvent: any;
        color?: ItemColor;
        movable?: boolean;
        resizable?: boolean;
    }


    interface Web2CalPlugins {
        onNewEvent(obj: ScheduledEvent, groups: Array<CalendarGroup>, allday: boolean): void;
        getNewEventObject(): any;
    }

    interface Web2CalOptions {
        previewTemplate?: string,
        newEventTemplate?: string,
        loadEvents(): void;
        onPreview(evt: HTMLElement, dataObj: EventData, html: JQuery): void;
        onNewEvent(obj: ScheduledEvent, groups: Array<CalendarGroup>, allday: boolean): void;
    }
}


declare class UTC {
    constructor(time?: number);

    addDays(numofDays: number): void;

    getDateObj(): any;
}

declare class Web2Cal {
    constructor(selector:string,options:web2cal.Web2CalOptions);
    showPreview(evt:HTMLElement,html:JQuery) :void;
    build() : void;
    render(data: Array<web2cal.GroupData>) :void ;
    updateEvent(event: web2cal.EventData): void;
    addEvent(newev:web2cal.EventData):void;
    getEventById(evId:number) : any;
    closeAddEvent():void;
    hidePreview() : void;

    static defaultPlugins: web2cal.Web2CalPlugins;
}

declare module Web2Cal {
    export class TimeControl {
        constructor(eventStartTime: HTMLElement, eventEndTime?: HTMLElement, options?:Object);
    }
}

declare var updateDateForTime: Function;