/**
 * Created by liyanjun1 on 17/1/22.
 */

var daymeeting_calendar = null;
function show_meeting_agenda(meetingroomid){

    if (meetingroomid == "undefined" || meetingroomid == "")
        return;

    var curDate = getNowFormatDate();
    var url_events = '/Handler/Meeting.ashx?Action=SelectMeetingForCalendar' + "&id=" + meetingroomid;

    if (daymeeting_calendar != null) {

    //    $('#daymeeting_calendar').fullCalendar( 'refetchEventSources', url_events );
        $('#daymeeting_calendar').fullCalendar('removeEvents');
        $('#daymeeting_calendar').fullCalendar('addEventSource', url_events);
        //$('#daymeeting_calendar').fullCalendar('refetchResources');
        return;
    }

    var nowDate = getNowFormatDate();
    daymeeting_calendar = $('#daymeeting_calendar').fullCalendar({
        locale: 'zh-cn',
        buttonText: { today: '今天', month: '月', week: '周', day: '日' },
        now: nowDate,
        header: {
            center: 'title',
            left: 'listDay'
        },
        // customize the button names,
        // otherwise they'd all just say "list"
        views: {
            listDay: { buttonText: '会议议程' },
        },

        defaultView: 'listDay',
        editable: true,
        eventLimit: true, // allow "more" link when too many events
        selectable:true,
        eventClick:function(calEvent, jsEvent, view) {

           // alert('Event: ' + calEvent.title + 'View: ' + view.name);

            // change the border color just for fun
            $(this).css('border-color', 'red');

        },
        dayClick: function(date, jsEvent, view) {
            //alert('Clicked on: ' + date.format() + 'Current view: ' + view.name);

            // change the day's background color just for fun
            $(this).css('background-color', 'red');

        },
        navLinks: true,
        navLinkDayClick: function(date, jsEvent) {
            console.log('day', date.format()); // date is a moment
            console.log('coords', jsEvent.pageX, jsEvent.pageY);
        },
        events: url_events
    });



}