(function($){'use strict';$(document).ready(function(){var selectedEvent;$('#calendar_month').pagescalendar({events:[{title:'Call Dave',class:'bg-success-lighter',start:'2014-10-07T06:00:00',end:'2014-10-07T08:00:24',other:{}},{title:'Meeting Roundup',class:'bg-success-lighter',start:'2014-11-07T06:00:00'},{title:'Double click Any where',class:'bg-complete-lighter',start:moment().startOf('week').add(1,'days').add(2,'hours').format(),end:moment().startOf('week').add(1,'days').add(6,'hours').format(),other:{note:'test'}},{title:'Drag Me',class:'bg-success-lighter',start:moment().startOf('week').add(2,'days').add(2,'hours').format(),end:moment().startOf('week').add(2,'days').add(3,'hours').format(),other:{note:'test'}},{title:'Click me',class:'bg-danger-lighter',start:moment().startOf('week').add(2,'days').add(5,'hours').format(),end:moment().startOf('week').add(2,'days').add(6,'hours').format(),other:{note:'test'}},],view:"month",onViewRenderComplete:function(){},onEventClick:function(event){if(!$('#calendar-event').hasClass('open'))
$('#calendar-event').addClass('open');selectedEvent=event;setEventDetailsToForm(selectedEvent);},onEventDragComplete:function(event){selectedEvent=event;setEventDetailsToForm(selectedEvent);},onEventResizeComplete:function(event){selectedEvent=event;setEventDetailsToForm(selectedEvent);},onTimeSlotDblClick:function(timeSlot){$('#calendar-event').removeClass('open');var newEvent={title:'my new event',class:'bg-success-lighter',start:timeSlot.date,end:moment(timeSlot.date).add(1,'hour').format(),allDay:false,other:{note:'test'}};selectedEvent=newEvent;$('#calendar_month').pagescalendar('addEvent',newEvent);setEventDetailsToForm(selectedEvent);}});function setEventDetailsToForm(event){$('#eventIndex').val();$('#txtEventName').val();$('#txtEventCode').val();$('#txtEventLocation').val();$('#event-date').html(moment(event.start).format('MMM, D dddd'));$('#lblfromTime').html(moment(event.start).format('h:mm A'));$('#lbltoTime').html(moment(event.end).format('H:mm A'));$('#eventIndex').val(event.index);$('#txtEventName').val(event.title);$('#txtEventCode').val(event.other.code);$('#txtEventLocation').val(event.other.location);}
$('#eventSave').on('click',function(){selectedEvent.title=$('#txtEventName').val();selectedEvent.other.code=$('#txtEventCode').val();selectedEvent.other.location=$('#txtEventLocation').val();$('#calendar_month').pagescalendar('updateEvent',selectedEvent);$('#calendar-event').removeClass('open');});$('#eventDelete').on('click',function(){$('#calendar_month').pagescalendar('removeEvent',$('#eventIndex').val());$('#calendar-event').removeClass('open');});});})(window.jQuery);