$('#datetimepicker1').datepicker({});
$.get("server/adapter.php", function(data){
disabledDates = data.split(',');
$('#datetimepicker2').datepicker({
format: 'yyyy-mm-dd',
datesDisabled: disabledDates,
});
});
$.get("server/adapter.php", function(data){
disabledDates = data.split(',');
$('#datetimepicker3').datepicker({
format: 'yyyy-mm-dd',
datesDisabled: disabledDates,
First Day = Tuesday,
language: 'de'
});
});
$('.calendar').map(function(index) {
$(this).datepicker({
defaultViewDate: {
year: (new Date()).getFullYear(),
month: (new Date()).getMonth() + index,
date: 1
},
multidate: true,
updateViewDate: false
});
});
// keep month in sync
var orderMonth = function(e) {
var target = e.target;
var date = e.date;
var calendars = $('.calendar');
var positionOfTarget = calendars.index(target);
calendars.each(function(index) {
if (this === target) {
return;
}
var newDate = new Date(date);
newDate.setUTCDate(1);
newDate.setMonth(
date.getMonth() + index - positionOfTarget
);
$(this).datepicker('_setDate', newDate, 'view');
});
};
$('.calendar').on('changeMonth', orderMonth);
// keep dates in sync
$('.calendar').on('changeDate', function(e) {
var calendars = $('.calendar');
var target = e.target;
var newDates = $(target).datepicker('getUTCDates');
calendars.each(function() {
if (this === e.target) {
return;
}
// setUTCDates triggers changeDate event
// could easily run into an infinite loop
// therefore we check if currentDates equal newDates
var currentDates = $(this).datepicker('getUTCDates');
if (
currentDates &&
currentDates.length === newDates.length &&
currentDates.every(function(currentDate) {
return newDates.some(function(newDate) {
return currentDate.toISOString() === newDate.toISOString();
})
})
) {
return;
}
$(this).datepicker('setUTCDates', newDates);
});
});