From 3fabdefc7754e17bb91cc11a2d02e0e80b6c58f4 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 26 Jul 2011 08:50:39 +0200 Subject: [PATCH] Snap allday events to day start when dragging; disable freebusy features if backend doesn't support it --- plugins/calendar/calendar.php | 2 +- plugins/calendar/calendar_ui.js | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 1c5801a1..f03417c7 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1182,7 +1182,7 @@ class calendar extends rcube_plugin $event['attendees'][$i]['role'] = 'ORGANIZER'; } else if (!$organizer && $identity['email']) { - $event['attendees'][] = array('role' => 'ORGANIZER', 'name' => $identity['name'], 'email' => $identity['email'], 'status' => 'ACCEPTED'); + array_unshift($event['attendees'], array('role' => 'ORGANIZER', 'name' => $identity['name'], 'email' => $identity['email'], 'status' => 'ACCEPTED')); } } } diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index bfa2614d..9c4c849d 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -448,6 +448,7 @@ function rcube_calendar_ui(settings) for (var j=0; j < event.attendees.length; j++) add_attendee(event.attendees[j], true); } + $('#edit-attendee-schedule')[(calendar.freebusy?'show':'hide')](); // attachments if (calendar.attachments) { @@ -626,8 +627,8 @@ function rcube_calendar_ui(settings) freebusy_ui.endtime = $('#schedule-endtime').val($.fullCalendar.formatDate(event.end, settings['time_format'])).show(); if (allday.checked) { - starttime.val("00:00").hide(); - endtime.val("23:59").hide(); + freebusy_ui.starttime.val("00:00").hide(); + freebusy_ui.endtime.val("23:59").hide(); event.allDay = true; } @@ -826,12 +827,21 @@ function rcube_calendar_ui(settings) var range_t = freebusy_ui.end.getTime() - freebusy_ui.start.getTime(); var newstart = new Date(freebusy_ui.start.getTime() + px * (range_t / range_p)); newstart.setSeconds(0); newstart.setMilliseconds(0); - // round to 5 minutes - var round = newstart.getMinutes() % 5; - if (round > 2.5) newstart.setTime(newstart.getTime() + (5 - round) * 60000); - else if (round > 0) newstart.setTime(newstart.getTime() - round * 60000); - // update event times + // set time to 00:00 + if (me.selected_event.allDay) { + newstart.setMinutes(0); + newstart.setHours(0); + } + else { + // round to 5 minutes + var round = newstart.getMinutes() % 5; + if (round > 2.5) newstart.setTime(newstart.getTime() + (5 - round) * 60000); + else if (round > 0) newstart.setTime(newstart.getTime() - round * 60000); + } + // update event times and display update_freebusy_dates(newstart, new Date(newstart.getTime() + freebusy_ui.startdate.data('duration') * 1000)); + if (me.selected_event.allDay) + render_freebusy_overlay(); } }).data('isdraggable', true); } @@ -1131,6 +1141,12 @@ function rcube_calendar_ui(settings) // load free-busy status from server and update icon accordingly var check_freebusy_status = function(icon, email, event) { + var calendar = event.calendar && me.calendars[event.calendar] ? me.calendars[event.calendar] : { freebusy:false }; + if (!calendar) { + $(icon).removeClass().addClass('availabilityicon unknown'); + return; + } + icon = $(icon).removeClass().addClass('availabilityicon loading'); $.ajax({