Fullcalendarjs
// Reff: http://stackoverflow.com/questions/26483551/how-to-non-clickable-dates-from-last-and-next-month-days-in-fullcalendar
// http://fullcalendar.io/docs/views/View_Object/
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: '2015-02-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
dayClick: function(date, allDay, jsEvent, view) {
// var a = new Date();
//var firstDay = new Date(a.getFullYear(), a.getMonth(), 1);
// var lastDay = new Date(a.getFullYear(), a.getMonth() + 1, 0);
//alert(firstDay);
var newDt = date.format();
//if( newDt < firstDay && newDt > lastDay){
//alert('hi');
// return false;
// } else {
// $(this).css('background-color', 'red');
// }
//alert('Clicked on: ' + date.format());
//alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
//alert('Current view: ' + view.name);
// disable all functions on previous and next month days in current month view
var view = $('#calendar').fullCalendar( 'getView' );
//return date.month() == view.intervalStart.month();
if(date.month() != view.intervalStart.month()) {
//do nothing..
alert('Event is barred on ' + newDt);
} else {
$(this).css('background-color', 'red');
}
},
events: [
{
title: 'All Day Event',
start: '2015-02-01'
},
{
title: 'Long Event',
start: '2015-02-07',
end: '2015-02-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2015-02-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2015-02-16T16:00:00'
},
{
title: 'Conference',
start: '2015-02-11',
end: '2015-02-13'
},
{
title: 'Meeting',
start: '2015-02-12T10:30:00',
end: '2015-02-12T12:30:00'
},
{
title: 'Lunch',
start: '2015-02-12T12:00:00'
},
{
title: 'Meeting',
start: '2015-02-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2015-02-12T17:30:00'
},
{
title: 'Dinner',
start: '2015-02-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2015-02-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2015-02-28'
}
]
});
});