2009-07-19 18:41:42 +02:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2008-08-28 16:48:45 +02:00
|
|
|
|
2006-08-31 01:13:18 +02:00
|
|
|
var listFilter = 'view_today';
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
var listOfSelection = null;
|
2010-08-26 16:14:10 +02:00
|
|
|
var selectedCalendarCell = null;
|
2006-10-12 23:05:32 +02:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
var showCompletedTasks;
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
var currentDay = '';
|
2010-02-13 00:24:24 +01:00
|
|
|
var selectedDayNumber = -1;
|
|
|
|
var selectedDayDate = '';
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
var cachedDateSelectors = [];
|
2006-09-07 17:50:03 +02:00
|
|
|
|
2006-10-14 01:37:27 +02:00
|
|
|
var contactSelectorAction = 'calendars-contacts';
|
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
var eventsToDelete = [];
|
|
|
|
var calendarsOfEventsToDelete = [];
|
2006-10-18 23:53:47 +02:00
|
|
|
|
2008-12-23 16:51:12 +01:00
|
|
|
var usersRightsWindowHeight = 215;
|
2007-04-28 00:06:58 +02:00
|
|
|
var usersRightsWindowWidth = 502;
|
|
|
|
|
2008-07-16 04:12:18 +02:00
|
|
|
var calendarEvents = null;
|
|
|
|
|
2009-08-18 20:23:13 +02:00
|
|
|
var preventAutoScroll = false;
|
|
|
|
|
2010-05-05 16:40:53 +02:00
|
|
|
var userStates = [ "needs-action", "accepted", "declined", "tentative", "delegated" ];
|
2008-07-16 23:48:54 +02:00
|
|
|
|
2010-02-12 18:23:47 +01:00
|
|
|
var calendarHeaderAdjusted = false;
|
|
|
|
|
2010-05-16 19:27:25 +02:00
|
|
|
var categoriesStyles = new Hash();
|
|
|
|
var categoriesStyleSheet = null;
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
var clipboard = null;
|
|
|
|
var eventsToCopy = [];
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
function newEvent(type, day, hour, duration) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var folder = getSelectedFolder();
|
|
|
|
var folderID = folder.readAttribute("id");
|
|
|
|
var urlstr = ApplicationBaseURL + folderID + "/new" + type;
|
|
|
|
var params = [];
|
2010-02-11 03:36:43 +01:00
|
|
|
if (!day)
|
|
|
|
day = currentDay;
|
|
|
|
params.push("day=" + day);
|
2009-07-19 18:41:42 +02:00
|
|
|
if (hour)
|
|
|
|
params.push("hm=" + hour);
|
2010-02-11 03:36:43 +01:00
|
|
|
if (duration)
|
|
|
|
params.push("duration=" + duration);
|
2009-07-19 18:41:42 +02:00
|
|
|
if (params.length > 0)
|
|
|
|
urlstr += "?" + params.join("&");
|
|
|
|
|
|
|
|
window.open(urlstr, "", "width=490,height=470,resizable=0");
|
2010-02-15 16:16:13 +01:00
|
|
|
|
2010-02-15 16:18:57 +01:00
|
|
|
return false; /* stop following the link */
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function newEventFromWidget(sender, type) {
|
|
|
|
var day = $(sender).readAttribute("day");
|
|
|
|
var hour = sender.readAttribute("hour");
|
|
|
|
|
2010-02-15 16:18:57 +01:00
|
|
|
return newEvent(type, day, hour);
|
2007-05-22 16:38:54 +02:00
|
|
|
}
|
2006-08-15 22:52:23 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
function minutesToHM(minutes) {
|
|
|
|
var hours = Math.floor(minutes / 60);
|
|
|
|
if (hours < 10)
|
|
|
|
hours = "0" + hours;
|
|
|
|
var mins = minutes % 60;
|
|
|
|
if (mins < 10)
|
|
|
|
mins = "0" + mins;
|
|
|
|
|
|
|
|
return "" + hours + mins;
|
|
|
|
}
|
|
|
|
|
|
|
|
function newEventFromDragging(controller, day, coordinates) {
|
2010-02-11 20:48:09 +01:00
|
|
|
var startHm;
|
|
|
|
if (controller.eventType == "multiday")
|
|
|
|
startHm = minutesToHM(coordinates.start * 15);
|
|
|
|
else
|
|
|
|
startHm = "allday";
|
2010-02-11 03:36:43 +01:00
|
|
|
var lengthHm = minutesToHM(coordinates.duration * 15);
|
|
|
|
newEvent("event", day, startHm, lengthHm);
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateEventFromDragging(controller, eventCells, eventDelta) {
|
|
|
|
if (eventDelta.dayNumber || eventDelta.start || eventDelta.duration) {
|
|
|
|
var params = ("days=" + eventDelta.dayNumber
|
|
|
|
+ "&start=" + eventDelta.start * 15
|
|
|
|
+ "&duration=" + eventDelta.duration * 15);
|
|
|
|
// log("eventCells: " + eventCells.length);
|
|
|
|
var eventCell = eventCells[0];
|
|
|
|
// log(" time: " + eventCell.recurrenceTime);
|
|
|
|
// log(" exception: " + eventCell.isException);
|
|
|
|
|
|
|
|
if (eventCell.recurrenceTime && !eventCell.isException)
|
|
|
|
_editRecurrenceDialog(eventCell, "confirmAdjustment", params);
|
|
|
|
else {
|
|
|
|
var urlstr = (ApplicationBaseURL
|
|
|
|
+ eventCell.calendar + "/" + eventCell.cname);
|
|
|
|
if (eventCell.recurrenceTime)
|
|
|
|
urlstr += "/occurence" + eventCell.recurrenceTime;
|
|
|
|
urlstr += ("/adjust?" + params);
|
|
|
|
// log(" urlstr: " + urlstr);
|
|
|
|
triggerAjaxRequest(urlstr, updateEventFromDraggingCallback,
|
|
|
|
{ controller: controller,
|
|
|
|
eventCell: eventCell });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function performEventAdjustment(folder, event, recurrence, params) {
|
|
|
|
var urlstr = ApplicationBaseURL + folder + "/" + event;
|
|
|
|
if (recurrence)
|
|
|
|
urlstr += "/" + recurrence;
|
|
|
|
urlstr += "/adjust" + generateQueryString(params);
|
|
|
|
triggerAjaxRequest(urlstr, updateEventFromDraggingCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateEventFromDraggingCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
2010-02-17 22:27:02 +01:00
|
|
|
refreshEventsAndDisplay();
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function getSelectedFolder() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var folder;
|
|
|
|
var list = $("calendarList");
|
|
|
|
var nodes = list.getSelectedRows();
|
|
|
|
if (nodes.length > 0)
|
|
|
|
folder = nodes[0];
|
|
|
|
else
|
2010-08-26 16:14:10 +02:00
|
|
|
folder = list.down("li"); // personal calendar
|
2007-09-15 00:01:02 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return folder;
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMenuNewEventClick(event) {
|
2010-02-11 03:36:43 +01:00
|
|
|
newEventFromWidget(this, "event");
|
2007-05-22 16:38:54 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMenuNewTaskClick(event) {
|
2010-02-11 03:36:43 +01:00
|
|
|
newEventFromWidget(this, "task");
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
function _editEventId(id, calendar, recurrence) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var targetname = "SOGo_edit_" + id;
|
|
|
|
var urlstr = ApplicationBaseURL + calendar + "/" + id;
|
|
|
|
if (recurrence) {
|
|
|
|
urlstr += "/" + recurrence;
|
|
|
|
targetname += recurrence;
|
|
|
|
}
|
|
|
|
urlstr += "/edit";
|
|
|
|
var win = window.open(urlstr, "_blank",
|
|
|
|
"width=490,height=470,resizable=0");
|
|
|
|
if (win)
|
|
|
|
win.focus();
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function editEvent() {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (listOfSelection) {
|
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
|
|
|
|
|
|
|
if (nodes.length == 0) {
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("Please select an event or a task."));
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < nodes.length; i++)
|
|
|
|
_editEventId(nodes[i].cname,
|
|
|
|
nodes[i].calendar);
|
|
|
|
} else if (selectedCalendarCell) {
|
|
|
|
if (selectedCalendarCell[0].recurrenceTime && !selectedCalendarCell[0].isException)
|
|
|
|
_editRecurrenceDialog(selectedCalendarCell[0], "confirmEditing");
|
|
|
|
else
|
|
|
|
_editEventId(selectedCalendarCell[0].cname,
|
|
|
|
selectedCalendarCell[0].calendar);
|
|
|
|
} else {
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("Please select an event or a task."));
|
2007-12-03 15:13:10 +01:00
|
|
|
}
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false; /* stop following the link */
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
function _batchDeleteEvents() {
|
2010-01-21 21:44:17 +01:00
|
|
|
// Delete the next event from the batch
|
2009-07-19 18:41:42 +02:00
|
|
|
var events = eventsToDelete.shift();
|
|
|
|
var calendar = calendarsOfEventsToDelete.shift();
|
|
|
|
var urlstr = (ApplicationBaseURL + calendar
|
|
|
|
+ "/batchDelete?ids=" + events.join('/'));
|
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
deleteEventCallback,
|
|
|
|
{ calendar: calendar,
|
|
|
|
events: events });
|
2006-10-17 00:35:22 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteEvent() {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (listOfSelection) {
|
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
var label = "";
|
|
|
|
if (listOfSelection == $("tasksList"))
|
2010-06-02 21:11:15 +02:00
|
|
|
label = _("taskDeleteConfirmation");
|
2009-07-19 18:41:42 +02:00
|
|
|
else
|
2010-06-02 21:11:15 +02:00
|
|
|
label = _("eventDeleteConfirmation");
|
2009-07-19 18:41:42 +02:00
|
|
|
|
|
|
|
if (nodes.length == 1
|
|
|
|
&& nodes[0].recurrenceTime) {
|
2010-08-26 16:14:10 +02:00
|
|
|
if (nodes[0].erasable)
|
|
|
|
_editRecurrenceDialog(nodes[0], "confirmDeletion");
|
|
|
|
else
|
|
|
|
showAlertDialog(_("You don't have the required privileges to perform the operation."));
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
else {
|
2010-08-26 16:14:10 +02:00
|
|
|
var canDelete;
|
|
|
|
var sortedNodes = [];
|
|
|
|
var calendars = [];
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
canDelete = nodes[i].erasable || IsSuperUser;
|
|
|
|
if (canDelete) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var calendar = nodes[i].calendar;
|
|
|
|
if (!sortedNodes[calendar]) {
|
|
|
|
sortedNodes[calendar] = [];
|
|
|
|
calendars.push(calendar);
|
|
|
|
}
|
|
|
|
sortedNodes[calendar].push(nodes[i].cname);
|
|
|
|
}
|
|
|
|
}
|
2010-08-26 16:14:10 +02:00
|
|
|
for (i = 0; i < calendars.length; i++) {
|
|
|
|
calendarsOfEventsToDelete.push(calendars[i]);
|
|
|
|
eventsToDelete.push(sortedNodes[calendars[i]]);
|
|
|
|
}
|
|
|
|
if (i > 0)
|
|
|
|
showConfirmDialog(_("Warning"), label, deleteEventFromListConfirm);
|
|
|
|
else
|
|
|
|
showAlertDialog(_("You don't have the required privileges to perform the operation."));
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2010-08-26 16:14:10 +02:00
|
|
|
else
|
|
|
|
showAlertDialog(_("Please select an event or a task."));
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
else if (selectedCalendarCell) {
|
2010-07-30 22:10:00 +02:00
|
|
|
if (selectedCalendarCell.length == 1
|
|
|
|
&& selectedCalendarCell[0].recurrenceTime) {
|
2010-08-26 16:14:10 +02:00
|
|
|
if (selectedCalendarCell[0].erasable)
|
|
|
|
_editRecurrenceDialog(selectedCalendarCell[0], "confirmDeletion");
|
|
|
|
else
|
|
|
|
showAlertDialog(_("You don't have the required privileges to perform the operation."));
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2010-08-26 16:14:10 +02:00
|
|
|
else {
|
|
|
|
var canDelete;
|
2010-07-30 22:10:00 +02:00
|
|
|
var sortedNodes = [];
|
|
|
|
var calendars = [];
|
|
|
|
for (var i = 0; i < selectedCalendarCell.length; i++) {
|
2010-08-26 16:14:10 +02:00
|
|
|
canDelete = selectedCalendarCell[i].erasable || IsSuperUser;
|
2010-07-30 22:10:00 +02:00
|
|
|
if (canDelete) {
|
|
|
|
var calendar = selectedCalendarCell[i].calendar;
|
|
|
|
if (!sortedNodes[calendar]) {
|
|
|
|
sortedNodes[calendar] = [];
|
|
|
|
calendars.push(calendar);
|
|
|
|
}
|
|
|
|
sortedNodes[calendar].push(selectedCalendarCell[i].cname);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2010-07-30 22:10:00 +02:00
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
for (i = 0; i < calendars.length; i++) {
|
2010-07-30 22:10:00 +02:00
|
|
|
calendarsOfEventsToDelete.push(calendars[i]);
|
|
|
|
eventsToDelete.push(sortedNodes[calendars[i]]);
|
|
|
|
}
|
2010-08-26 16:14:10 +02:00
|
|
|
if (i > 0)
|
2010-10-08 18:08:10 +02:00
|
|
|
showConfirmDialog(_("Warning"), _("eventDeleteConfirmation"),
|
|
|
|
deleteEventFromViewConfirm, deleteEventFromViewCancel);
|
2010-08-26 16:14:10 +02:00
|
|
|
else
|
|
|
|
showAlertDialog(_("You don't have the required privileges to perform the operation."));
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2008-01-24 22:36:51 +01:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
else
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("Please select an event or a task."));
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
function deleteEventFromListConfirm() {
|
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
_batchDeleteEvents();
|
|
|
|
disposeDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteEventFromViewConfirm() {
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
selectedCalendarCell = null;
|
|
|
|
_batchDeleteEvents();
|
|
|
|
disposeDialog();
|
|
|
|
}
|
|
|
|
|
2010-10-08 18:08:10 +02:00
|
|
|
function deleteEventFromViewCancel(event) {
|
|
|
|
calendarsOfEventsToDelete = [];
|
|
|
|
eventsToDelete = [];
|
|
|
|
disposeDialog();
|
|
|
|
}
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
function copyEventToClipboard() {
|
|
|
|
if (listOfSelection) {
|
|
|
|
clipboard = new Array();
|
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
|
|
|
for (var i = 0; i < nodes.length; i++)
|
|
|
|
clipboard.push(nodes[i].calendar + "/" + nodes[i].cname);
|
|
|
|
}
|
|
|
|
else if (selectedCalendarCell) {
|
|
|
|
clipboard = new Array();
|
|
|
|
for (var i = 0; i < selectedCalendarCell.length; i++)
|
|
|
|
clipboard.push(selectedCalendarCell[i].calendar + "/" + selectedCalendarCell[i].cname);
|
|
|
|
}
|
|
|
|
log ("clipboard : " + clipboard.join(", "));
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyEventFromClipboard() {
|
|
|
|
if (clipboard && clipboard.length > 0) {
|
|
|
|
var folder = getSelectedFolder();
|
|
|
|
var folderID = folder.readAttribute("id").substr(1);
|
|
|
|
eventsToCopy = [];
|
|
|
|
for (var i = 0; i < clipboard.length; i++)
|
|
|
|
eventsToCopy[i] = clipboard[i] + "/copy?destination=" + folderID;
|
|
|
|
copyEvents();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyEventToPersonalCalendar(event) {
|
|
|
|
var calendar = selectedCalendarCell[0].calendar;
|
|
|
|
var cname = selectedCalendarCell[0].cname;
|
|
|
|
eventsToCopy = [calendar + "/" + cname + "/copy"];
|
|
|
|
copyEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyEvents() {
|
|
|
|
var path = eventsToCopy.shift();
|
|
|
|
var urlstr = ApplicationBaseURL + path; log (urlstr);
|
|
|
|
triggerAjaxRequest(urlstr,
|
|
|
|
copyEventCallback);
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyEventCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
if (eventsToCopy.length)
|
|
|
|
copyEvents();
|
|
|
|
else
|
|
|
|
refreshEventsAndDisplay();
|
|
|
|
}
|
|
|
|
else if (parseInt(http.status) == 403)
|
|
|
|
showAlertDialog(_("You don't have the required privileges to perform the operation."));
|
|
|
|
else if (parseInt(http.status) == 400)
|
|
|
|
showAlertDialog(_("DestinationCalendarError"));
|
|
|
|
else
|
|
|
|
showAlertDialog(_("EventCopyError"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-10 20:31:20 +02:00
|
|
|
function modifyEvent(sender, modification, parameters) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var currentLocation = '' + window.location;
|
|
|
|
var arr = currentLocation.split("/");
|
|
|
|
arr[arr.length-1] = modification;
|
2006-11-15 01:10:53 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
document.modifyEventAjaxRequest = triggerAjaxRequest(arr.join("/"),
|
|
|
|
modifyEventCallback,
|
2009-09-10 20:31:20 +02:00
|
|
|
modification,
|
|
|
|
parameters,
|
|
|
|
{ "Content-type": "application/x-www-form-urlencoded" });
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-11-15 01:10:53 +01:00
|
|
|
}
|
|
|
|
|
2007-01-04 23:30:48 +01:00
|
|
|
function closeInvitationWindow() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var closeDiv = document.createElement("div");
|
|
|
|
document.body.appendChild(closeDiv);
|
|
|
|
closeDiv.addClassName("javascriptPopupBackground");
|
2007-10-04 19:26:21 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var closePseudoWin = document.createElement("div");
|
|
|
|
document.body.appendChild(closePseudoWin);
|
|
|
|
closePseudoWin.addClassName("javascriptMessagePseudoTopWindow");
|
|
|
|
closePseudoWin.style.top = "0px;";
|
|
|
|
closePseudoWin.style.left = "0px;";
|
|
|
|
closePseudoWin.style.right = "0px;";
|
2010-06-02 21:11:15 +02:00
|
|
|
closePseudoWin.appendChild(document.createTextNode(_("closeThisWindowMessage")));
|
2007-10-04 19:26:21 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var calLink = document.createElement("a");
|
|
|
|
closePseudoWin.appendChild(calLink);
|
|
|
|
calLink.href = ApplicationBaseURL;
|
2010-06-02 21:11:15 +02:00
|
|
|
calLink.appendChild(document.createTextNode(_("Calendar").toLowerCase()));
|
2007-01-04 23:30:48 +01:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
function modifyEventCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4) {
|
2010-05-05 16:40:53 +02:00
|
|
|
if (isHttpStatus204(http.status) || http.status == 200) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var mailInvitation = queryParameters["mail-invitation"];
|
|
|
|
if (mailInvitation && mailInvitation.toLowerCase() == "yes")
|
|
|
|
closeInvitationWindow();
|
|
|
|
else {
|
|
|
|
window.opener.setTimeout("refreshEventsAndDisplay();", 100);
|
|
|
|
window.setTimeout("window.close();", 100);
|
|
|
|
}
|
|
|
|
}
|
2009-09-10 20:31:20 +02:00
|
|
|
else if (http.status == 403) {
|
|
|
|
var data = http.responseText;
|
2010-02-19 18:07:18 +01:00
|
|
|
var msg;
|
|
|
|
if (data.indexOf("An error occurred during object publishing") >
|
|
|
|
-1) {
|
|
|
|
msg = data.replace(/^(.*\n)*.*<p>((.*\n)*.*)<\/p>(.*\n)*.*$/, "$2");
|
|
|
|
} else {
|
|
|
|
msg = "delegate is a participant";
|
|
|
|
}
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_(msg));
|
2009-09-10 20:31:20 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
else {
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("eventPartStatModificationError"));
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
document.modifyEventAjaxRequest = null;
|
2007-08-24 00:10:01 +02:00
|
|
|
}
|
2006-11-07 19:14:29 +01:00
|
|
|
}
|
|
|
|
|
2010-01-21 21:44:17 +01:00
|
|
|
function _deleteCalendarEventBlocks(calendar, cname, occurenceTime) {
|
|
|
|
// Delete event (or occurence) from the specified calendar
|
|
|
|
var ownerIsOrganizer = false;
|
2009-07-19 18:41:42 +02:00
|
|
|
var events = calendarEvents[calendar];
|
|
|
|
if (events) {
|
|
|
|
var occurences = events[cname];
|
2010-01-21 21:44:17 +01:00
|
|
|
if (occurences) {
|
2009-07-19 18:41:42 +02:00
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
|
|
|
var nodes = occurences[i].blocks;
|
|
|
|
for (var j = 0; j < nodes.length; j++) {
|
|
|
|
var node = nodes[j];
|
2010-01-21 21:44:17 +01:00
|
|
|
if (occurenceTime == null
|
|
|
|
|| occurenceTime == node.recurrenceTime) {
|
|
|
|
ownerIsOrganizer = node.ownerIsOrganizer;
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2010-01-21 21:44:17 +01:00
|
|
|
if (ownerIsOrganizer)
|
|
|
|
// Search for the same event in other calendars (using the cache)
|
|
|
|
// only if the delete operation is triggered from the organizer's
|
|
|
|
// calendar.
|
|
|
|
for (var otherCalendar in calendarEvents) {
|
|
|
|
if (calendar != otherCalendar) {
|
|
|
|
occurences = calendarEvents[otherCalendar][cname];
|
|
|
|
if (occurences) {
|
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
|
|
|
var occurence = occurences[i];
|
2010-05-18 20:35:47 +02:00
|
|
|
if (occurenceTime == null || occurenceTime == occurence[15]) {
|
2010-01-21 21:44:17 +01:00
|
|
|
var nodes = occurence.blocks;
|
|
|
|
for (var j = 0; j < nodes.length; j++) {
|
|
|
|
var node = nodes[j];
|
|
|
|
if (node.parentNode)
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2008-08-03 01:16:50 +02:00
|
|
|
}
|
|
|
|
|
2010-01-21 21:44:17 +01:00
|
|
|
function _deleteEventFromTables(calendar, cname, occurenceTime) {
|
|
|
|
var basename = "-" + cname;
|
|
|
|
if (occurenceTime) {
|
|
|
|
basename = basename + "-" + occurenceTime;
|
|
|
|
}
|
2010-05-05 17:20:41 +02:00
|
|
|
if (calendarEvents[calendar]) {
|
|
|
|
var occurences = calendarEvents[calendar][cname];
|
|
|
|
if (occurences) {
|
|
|
|
var occurence = occurences.first();
|
2010-05-18 20:35:47 +02:00
|
|
|
var ownerIsOrganizer = occurence[19];
|
2010-05-05 17:20:41 +02:00
|
|
|
|
|
|
|
// Delete event from events list
|
|
|
|
var table = $("eventsList");
|
|
|
|
var rows = table.tBodies[0].rows;
|
|
|
|
for (var j = rows.length; j > 0; j--) {
|
|
|
|
var row = $(rows[j - 1]);
|
|
|
|
var id = row.getAttribute("id");
|
|
|
|
var pos = id.indexOf(basename);
|
|
|
|
if (pos > 0) {
|
|
|
|
var otherCalendar = id.substr(0, pos);
|
|
|
|
occurences = calendarEvents[otherCalendar][cname];
|
|
|
|
if (occurences) {
|
|
|
|
for (var k = 0; k < occurences.length; k++) {
|
|
|
|
var occurence = occurences[k];
|
|
|
|
if (calendar == otherCalendar || ownerIsOrganizer) {
|
|
|
|
// This is the specified event or the same event in another
|
|
|
|
// calendar. In this case, remove it only if the delete
|
|
|
|
// operation is triggered from the organizer's calendar.
|
2010-05-18 20:35:47 +02:00
|
|
|
if (occurenceTime == null || occurenceTime == occurence[15]) {
|
2010-05-05 17:20:41 +02:00
|
|
|
row.parentNode.removeChild(row);
|
|
|
|
break;
|
|
|
|
}
|
2010-01-21 21:44:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2008-08-03 01:16:50 +02:00
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-01-21 21:44:17 +01:00
|
|
|
// Delete task from tasks list
|
|
|
|
var row = $(calendar + basename);
|
|
|
|
if (row) {
|
|
|
|
row.parentNode.removeChild(row);
|
|
|
|
}
|
2008-08-03 01:16:50 +02:00
|
|
|
}
|
|
|
|
|
2010-01-21 21:44:17 +01:00
|
|
|
function _deleteCalendarEventCache(calendar, cname, occurenceTime) {
|
|
|
|
var ownerIsOrganizer = false;
|
2010-05-05 17:20:41 +02:00
|
|
|
if (calendarEvents[calendar]) {
|
|
|
|
var occurences = calendarEvents[calendar][cname];
|
|
|
|
if (occurences)
|
2010-05-18 20:35:47 +02:00
|
|
|
ownerIsOrganizer = occurences[0][19];
|
2010-05-05 17:20:41 +02:00
|
|
|
}
|
|
|
|
|
2010-01-21 21:44:17 +01:00
|
|
|
for (var otherCalendar in calendarEvents) {
|
2010-05-05 17:20:41 +02:00
|
|
|
if (calendarEvents[otherCalendar]) {
|
|
|
|
var occurences = calendarEvents[otherCalendar][cname];
|
|
|
|
if (occurences) {
|
|
|
|
var newOccurences = [];
|
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
|
|
|
var occurence = occurences[i];
|
|
|
|
if (calendar == otherCalendar || ownerIsOrganizer) {
|
|
|
|
// This is the specified event or the same event in another
|
|
|
|
// calendar. In this case, remove it only if the delete
|
|
|
|
// operation is triggered from the organizer's calendar.
|
|
|
|
if (occurenceTime == null) {
|
|
|
|
delete calendarEvents[otherCalendar][cname];
|
|
|
|
}
|
2010-05-18 20:35:47 +02:00
|
|
|
else if (occurenceTime != occurence[15]) {
|
|
|
|
// || occurenceTime == occurence[15]) {
|
2010-05-05 17:20:41 +02:00
|
|
|
newOccurences.push(occurence);
|
|
|
|
}
|
2010-01-21 21:44:17 +01:00
|
|
|
}
|
|
|
|
}
|
2010-05-05 17:20:41 +02:00
|
|
|
if (occurenceTime)
|
|
|
|
calendarEvents[otherCalendar][cname] = newOccurences;
|
2010-01-21 21:44:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the Ajax callback function for _batchDeleteEvents.
|
|
|
|
*/
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteEventCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var isTask = false;
|
|
|
|
var calendar = http.callbackData.calendar;
|
|
|
|
var events = http.callbackData.events;
|
|
|
|
for (var i = 0; i < events.length; i++) {
|
|
|
|
var cname = events[i];
|
|
|
|
_deleteCalendarEventBlocks(calendar, cname);
|
2010-01-21 21:44:17 +01:00
|
|
|
_deleteEventFromTables(calendar, cname);
|
|
|
|
_deleteCalendarEventCache(calendar, cname);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (eventsToDelete.length)
|
|
|
|
_batchDeleteEvents();
|
2010-01-21 21:44:17 +01:00
|
|
|
else
|
2009-07-19 18:41:42 +02:00
|
|
|
document.deleteEventAjaxRequest = null;
|
|
|
|
}
|
|
|
|
else if (parseInt(http.status) == 403)
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("You don't have the required privileges to perform the operation."));
|
2009-07-19 18:41:42 +02:00
|
|
|
else
|
|
|
|
log ("deleteEventCallback Ajax error (" + http.status + ")");
|
|
|
|
}
|
2006-08-14 22:32:30 +02:00
|
|
|
}
|
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function getEventById(cname, owner) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var event = null;
|
|
|
|
|
|
|
|
if (calendarEvents) {
|
|
|
|
if (!owner)
|
|
|
|
owner = UserLogin;
|
|
|
|
var userEvents = calendarEvents[owner];
|
|
|
|
if (userEvents)
|
|
|
|
event = userEvents[cname];
|
|
|
|
}
|
2008-07-29 18:35:49 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return event;
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
function _editRecurrenceDialog(eventCell, method, params) {
|
|
|
|
var targetname = "SOGo_edit_" + eventCell.cname + eventCell.recurrenceTime;
|
|
|
|
var urlstr = (ApplicationBaseURL + eventCell.calendar + "/" + eventCell.cname
|
|
|
|
+ "/occurence" + eventCell.recurrenceTime + "/" + method);
|
|
|
|
if (params && params.length) {
|
|
|
|
urlstr += "?" + params;
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
var win = window.open(urlstr, "_blank",
|
|
|
|
"width=490,height=70,resizable=0");
|
|
|
|
if (win)
|
|
|
|
win.focus();
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
function onViewEvent(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (event.detail == 2) return;
|
|
|
|
var url = ApplicationBaseURL + this.calendar + "/" + this.cname;
|
|
|
|
|
|
|
|
if (typeof this.recurrenceTime != "undefined")
|
|
|
|
url += "/occurence" + this.recurrenceTime;
|
|
|
|
url += "/view";
|
|
|
|
if (document.viewEventAjaxRequest) {
|
|
|
|
document.viewEventAjaxRequest.aborted = true;
|
|
|
|
document.viewEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.viewEventAjaxRequest = triggerAjaxRequest(url, onViewEventCallback, this);
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onViewEventCallback(http) {
|
2010-01-06 23:16:24 +01:00
|
|
|
if (http.readyState == 4 && http.status == 200) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
// $H(data).keys().each(function(key) {
|
|
|
|
// log (key + " = " + data[key]);
|
|
|
|
// });
|
|
|
|
var cell = http.callbackData;
|
|
|
|
var cellPosition = cell.cumulativeOffset();
|
2010-02-11 03:36:43 +01:00
|
|
|
var cellDimensions = cell.getDimensions();
|
2009-07-19 18:41:42 +02:00
|
|
|
var div = $("eventDialog");
|
|
|
|
var divDimensions = div.getDimensions();
|
|
|
|
var view;
|
|
|
|
var left = cellPosition[0];
|
|
|
|
var top = cellPosition[1];
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (currentView != "monthview") {
|
|
|
|
view = $("daysView");
|
|
|
|
var viewPosition = view.cumulativeOffset();
|
2010-02-12 18:55:28 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (parseInt(data["isAllDay"]) == 0) {
|
|
|
|
top -= view.scrollTop;
|
|
|
|
if (viewPosition[1] > top + 2) {
|
|
|
|
view.stopObserving("scroll", onBodyClickHandler);
|
|
|
|
view.scrollTop = cell.offsetTop;
|
|
|
|
top = viewPosition[1];
|
|
|
|
Event.observe.delay(0.1, view, "scroll", onBodyClickHandler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
view = $("calendarView");
|
|
|
|
top -= cell.up("DIV.day").scrollTop;
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (left > parseInt(window.width()*0.75)) {
|
|
|
|
left = left - divDimensions["width"] + 10;
|
|
|
|
div.removeClassName("left");
|
|
|
|
div.addClassName("right");
|
|
|
|
}
|
|
|
|
else {
|
2010-07-05 17:58:18 +02:00
|
|
|
//log (" left = " + left + " + " + cellDimensions.width + " - " + parseInt(cellDimensions["width"]/3));
|
2009-07-19 18:41:42 +02:00
|
|
|
left = left + cellDimensions["width"] - parseInt(cellDimensions["width"]/3);
|
|
|
|
div.removeClassName("right");
|
|
|
|
div.addClassName("left");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Put the event's data in the DIV
|
2009-07-22 00:53:15 +02:00
|
|
|
div.down("h1").update(data["summary"].replace(/\r?\n/g, "<BR/>"));
|
2010-01-06 23:16:24 +01:00
|
|
|
|
|
|
|
var paras = div.getElementsByTagName("p");
|
2010-02-12 18:55:28 +01:00
|
|
|
var para = $(paras[0]);
|
2010-01-06 23:16:24 +01:00
|
|
|
if (data["calendar"].length) {
|
2010-02-12 18:55:28 +01:00
|
|
|
// Remove owner email from calendar's name
|
|
|
|
para.down("SPAN", 1).update(data["calendar"].replace(/ \<.*\>/, ""));
|
|
|
|
para.show();
|
2010-01-06 23:16:24 +01:00
|
|
|
} else
|
2010-02-12 18:55:28 +01:00
|
|
|
para.hide();
|
2010-01-06 23:16:24 +01:00
|
|
|
|
2010-02-12 18:55:28 +01:00
|
|
|
para = $(paras[1]);
|
2009-07-19 18:41:42 +02:00
|
|
|
if (parseInt(data["isAllDay"]) == 0) {
|
2010-02-12 18:55:28 +01:00
|
|
|
para.down("SPAN", 1).update(data["startTime"]);
|
|
|
|
para.show();
|
2009-07-19 18:41:42 +02:00
|
|
|
} else
|
2010-02-12 18:55:28 +01:00
|
|
|
para.hide();
|
2010-01-06 23:16:24 +01:00
|
|
|
|
2010-02-12 18:55:28 +01:00
|
|
|
para = $(paras[2]);
|
2009-07-19 18:41:42 +02:00
|
|
|
if (data["location"].length) {
|
2010-02-12 18:55:28 +01:00
|
|
|
para.down("SPAN", 1).update(data["location"]);
|
|
|
|
para.show();
|
2009-07-19 18:41:42 +02:00
|
|
|
} else
|
2010-02-12 18:55:28 +01:00
|
|
|
para.hide();
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-02-12 18:55:28 +01:00
|
|
|
para = $(paras[3]);
|
2009-07-19 18:41:42 +02:00
|
|
|
if (data["description"].length) {
|
2010-02-12 18:55:28 +01:00
|
|
|
para.update(data["description"].replace(/\r?\n/g, "<BR/>"));
|
|
|
|
para.show();
|
2009-07-19 18:41:42 +02:00
|
|
|
} else
|
2010-02-12 18:55:28 +01:00
|
|
|
para.hide();
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-01-06 23:16:24 +01:00
|
|
|
div.setStyle({ left: left + "px", top: top + "px" });
|
2009-07-19 18:41:42 +02:00
|
|
|
div.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2010-02-11 03:36:43 +01:00
|
|
|
log("onViewEventCallback ajax error (" + http.status + "): " + http.url);
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function editDoubleClickedEvent(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (this.isException && this.recurrenceTime)
|
|
|
|
_editEventId(this.cname, this.calendar, "occurence" + this.recurrenceTime);
|
|
|
|
else if (this.recurrenceTime)
|
|
|
|
_editRecurrenceDialog(this, "confirmEditing");
|
|
|
|
else
|
|
|
|
_editEventId(this.cname, this.calendar);
|
2007-06-11 23:23:48 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
Event.stop(event);
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
function performEventEdition(folder, event, recurrence) {
|
2009-07-19 18:41:42 +02:00
|
|
|
_editEventId(event, folder, recurrence);
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function performEventDeletion(folder, event, recurrence) {
|
2010-02-11 03:36:43 +01:00
|
|
|
if (calendarEvents) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (recurrence) {
|
|
|
|
// Only one recurrence
|
|
|
|
var occurenceTime = recurrence.substring(9);
|
|
|
|
var nodes = _eventBlocksMatching(folder, event, occurenceTime);
|
|
|
|
var urlstr = ApplicationBaseURL + folder + "/" + event + "/" + recurrence + "/delete";
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (nodes)
|
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
performDeleteEventCallback,
|
|
|
|
{ nodes: nodes,
|
|
|
|
occurence: occurenceTime });
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// All recurrences
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
eventsToDelete.push([event]);
|
|
|
|
calendarsOfEventsToDelete.push(folder);
|
|
|
|
_batchDeleteEvents();
|
|
|
|
}
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function performDeleteEventCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var occurenceTime = http.callbackData.occurence;
|
|
|
|
var nodes = http.callbackData.nodes;
|
|
|
|
var cname = nodes[0].cname;
|
|
|
|
var calendar = nodes[0].calendar;
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-01-21 21:44:17 +01:00
|
|
|
_deleteCalendarEventBlocks(calendar, cname, occurenceTime);
|
|
|
|
_deleteEventFromTables(calendar, cname, occurenceTime);
|
|
|
|
_deleteCalendarEventCache(calendar, cname, occurenceTime);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
/* in dateselector */
|
2007-03-19 15:31:49 +01:00
|
|
|
function onDaySelect(node) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var day = node.getAttribute('day');
|
|
|
|
var needRefresh = (listFilter == 'view_selectedday'
|
|
|
|
&& day != currentDay);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var td = $(node).getParentWithTagName("td");
|
|
|
|
var table = $(td).getParentWithTagName("table");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// log ("table.selected: " + table.selected);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (document.selectedDate)
|
|
|
|
document.selectedDate.deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
td.selectElement();
|
|
|
|
document.selectedDate = td;
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
changeCalendarDisplay( { "day": day } );
|
|
|
|
currentDay = day;
|
2010-02-13 00:24:24 +01:00
|
|
|
selectedDayDate = day;
|
2009-07-19 18:41:42 +02:00
|
|
|
if (needRefresh)
|
|
|
|
refreshEvents();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-07-05 21:19:17 +02:00
|
|
|
function onDateSelectorGotoMonth(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var day = this.getAttribute("date");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay(day, true);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
Event.stop(event);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onCalendarGotoDay(node) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var day = node.getAttribute("date");
|
2010-02-15 16:26:08 +01:00
|
|
|
var needRefresh = (listFilter == 'view_selectedday' && day != currentDay);
|
2008-02-08 22:46:05 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
changeCalendarDisplay( { "day": day } );
|
|
|
|
if (needRefresh)
|
|
|
|
refreshEvents();
|
2008-02-08 22:46:05 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function gotoToday() {
|
2010-02-15 16:26:08 +01:00
|
|
|
var todayDate = new Date();
|
|
|
|
selectedDayDate = todayDate.getDayString();
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay('');
|
|
|
|
changeCalendarDisplay();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function setDateSelectorContent(content) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var div = $("dateSelectorView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2010-01-25 18:08:17 +01:00
|
|
|
div.update(content);
|
2009-07-19 18:41:42 +02:00
|
|
|
if (currentDay.length > 0)
|
|
|
|
restoreCurrentDaySelection(div);
|
2007-07-05 21:19:17 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
initDateSelectorEvents();
|
2006-09-07 17:50:03 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function dateSelectorCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.dateSelectorAjaxRequest = null;
|
|
|
|
var content = http.responseText;
|
|
|
|
setDateSelectorContent(content);
|
|
|
|
cachedDateSelectors[http.callbackData] = content;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("dateSelectorCallback Ajax error");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function eventsListCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
var div = $("eventsListView");
|
|
|
|
document.eventsListAjaxRequest = null;
|
|
|
|
var table = $("eventsList");
|
|
|
|
lastClickedRow = -1; // from generic.js
|
|
|
|
|
2009-10-30 20:47:44 +01:00
|
|
|
var rows = table.select("TBODY TR");
|
|
|
|
rows.each(function(e) {
|
|
|
|
e.remove();
|
|
|
|
});
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
2010-05-21 15:59:35 +02:00
|
|
|
var row = createElement("tr");
|
2009-07-19 18:41:42 +02:00
|
|
|
table.tBodies[0].appendChild(row);
|
|
|
|
row.addClassName("eventRow");
|
2010-05-18 20:35:47 +02:00
|
|
|
var rTime = data[i][15];
|
2009-07-19 18:41:42 +02:00
|
|
|
var id = escape(data[i][1] + "-" + data[i][0]);
|
|
|
|
if (rTime)
|
|
|
|
id += "-" + escape(rTime);
|
|
|
|
row.setAttribute("id", id);
|
|
|
|
row.cname = escape(data[i][0]);
|
|
|
|
row.calendar = escape(data[i][1]);
|
|
|
|
if (rTime)
|
|
|
|
row.recurrenceTime = escape(rTime);
|
2010-05-18 20:35:47 +02:00
|
|
|
row.isException = data[i][16];
|
|
|
|
row.editable = data[i][17];
|
|
|
|
row.erasable = data[i][18];
|
2009-07-19 18:41:42 +02:00
|
|
|
var startDate = new Date();
|
|
|
|
startDate.setTime(data[i][4] * 1000);
|
|
|
|
row.day = startDate.getDayString();
|
2009-10-16 21:38:23 +02:00
|
|
|
if (!data[i][7])
|
|
|
|
row.hour = startDate.getHourString(); // event is not all day
|
2009-07-19 18:41:42 +02:00
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
row.observe("selectstart", listRowMouseDownHandler);
|
2009-10-14 22:29:46 +02:00
|
|
|
if (data[i][2] != null)
|
|
|
|
// Status is defined -- event is readable
|
|
|
|
row.observe("dblclick", editDoubleClickedEvent);
|
2009-07-19 18:41:42 +02:00
|
|
|
row.attachMenu("eventsListMenu");
|
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
var td = createElement("td");
|
2009-07-19 18:41:42 +02:00
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
2009-10-14 21:44:46 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][3])); // title
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
td = createElement("td");
|
2009-07-19 18:41:42 +02:00
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
2010-05-21 15:59:35 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][20])); // start date
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
td = createElement("td");
|
2009-07-19 18:41:42 +02:00
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
2010-05-21 15:59:35 +02:00
|
|
|
td.appendChild(document.createTextNode(data[i][21])); // end date
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
td = createElement("td");
|
2009-07-19 18:41:42 +02:00
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
2009-10-14 21:44:46 +02:00
|
|
|
if (data[i][6])
|
|
|
|
td.appendChild(document.createTextNode(data[i][6])); // location
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sorting["attribute"] && sorting["attribute"].length > 0) {
|
|
|
|
var sortHeader = $(sorting["attribute"] + "Header");
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (sortHeader) {
|
|
|
|
var sortImages = $(table.tHead).select(".sortImage");
|
|
|
|
$(sortImages).each(function(item) {
|
|
|
|
item.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
var sortImage = createElement("img", "messageSortImage", "sortImage");
|
|
|
|
sortHeader.insertBefore(sortImage, sortHeader.firstChild);
|
|
|
|
if (sorting["ascending"])
|
2009-11-04 23:13:20 +01:00
|
|
|
sortImage.src = ResourcesURL + "/arrow-down.png";
|
2009-07-19 18:41:42 +02:00
|
|
|
else
|
2009-11-04 23:13:20 +01:00
|
|
|
sortImage.src = ResourcesURL + "/arrow-up.png";
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("eventsListCallback Ajax error");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function tasksListCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var div = $("tasksListView");
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.tasksListAjaxRequest = null;
|
|
|
|
var list = $("tasksList");
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
2010-05-05 17:20:41 +02:00
|
|
|
|
|
|
|
list.previousScroll = list.scrollTop;
|
|
|
|
while (list.childNodes.length)
|
|
|
|
list.removeChild(list.childNodes[0]);
|
2009-07-19 18:41:42 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
2010-05-21 15:59:35 +02:00
|
|
|
var listItem = createElement("li");
|
2009-07-19 18:41:42 +02:00
|
|
|
list.appendChild(listItem);
|
|
|
|
listItem.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
listItem.observe("click", onRowClick);
|
|
|
|
listItem.observe("dblclick", editDoubleClickedEvent);
|
|
|
|
|
|
|
|
var calendar = escape(data[i][1]);
|
|
|
|
var cname = escape(data[i][0]);
|
|
|
|
listItem.setAttribute("id", calendar + "-" + cname);
|
|
|
|
//listItem.addClassName(data[i][5]); // Classification
|
2010-01-26 00:03:46 +01:00
|
|
|
listItem.addClassName(data[i][9]); // status (duelater, completed, etc)
|
2009-07-19 18:41:42 +02:00
|
|
|
listItem.calendar = calendar;
|
|
|
|
listItem.addClassName("calendarFolder" + calendar);
|
|
|
|
listItem.cname = cname;
|
2010-01-26 00:03:46 +01:00
|
|
|
listItem.erasable = data[i][7];
|
2010-05-21 15:59:35 +02:00
|
|
|
var input = createElement("input");
|
2009-07-19 18:41:42 +02:00
|
|
|
input.setAttribute("type", "checkbox");
|
2010-01-26 00:03:46 +01:00
|
|
|
if (parseInt(data[i][6]) == 0) // editable?
|
|
|
|
input.setAttribute("disabled", true);
|
2010-01-25 21:45:45 +01:00
|
|
|
if (parseInt(data[i][8]) == 1) {
|
|
|
|
listItem.addClassName("important");
|
2009-07-31 21:48:25 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
listItem.appendChild(input);
|
|
|
|
input.observe("click", updateTaskStatus, true);
|
|
|
|
input.setAttribute("value", "1");
|
|
|
|
if (data[i][2] == 1)
|
|
|
|
input.setAttribute("checked", "checked");
|
|
|
|
$(input).addClassName("checkBox");
|
|
|
|
|
2009-07-31 21:48:25 +02:00
|
|
|
var t = new Element ("span");
|
2010-01-26 00:03:46 +01:00
|
|
|
t.update(data[i][3]);
|
2009-07-31 21:48:25 +02:00
|
|
|
listItem.appendChild (t);
|
2009-08-25 19:34:37 +02:00
|
|
|
|
2010-01-26 00:03:46 +01:00
|
|
|
listItem.attachMenu("tasksListMenu");
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
list.scrollTop = list.previousScroll;
|
|
|
|
|
|
|
|
if (http.callbackData) {
|
|
|
|
var selectedNodesId = http.callbackData;
|
|
|
|
for (var i = 0; i < selectedNodesId.length; i++) {
|
|
|
|
// log(selectedNodesId[i] + " (" + i + ") is selected");
|
2009-07-22 21:06:14 +02:00
|
|
|
var node = $(selectedNodesId[i]);
|
|
|
|
if (node) {
|
|
|
|
node.selectElement();
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("tasksListCallback: no data");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("tasksListCallback Ajax error");
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
/* in dateselector */
|
2007-03-19 15:31:49 +01:00
|
|
|
function restoreCurrentDaySelection(div) {
|
2010-01-25 18:08:17 +01:00
|
|
|
var elements = $(div).select("TD.activeDay SPAN");
|
|
|
|
if (elements.size()) {
|
|
|
|
var day = elements[0].readAttribute('day');
|
|
|
|
if (day.substr(0, 6) == currentDay.substr(0, 6)) {
|
|
|
|
for (var i = 0; i < elements.length; i++) {
|
|
|
|
day = elements[i].readAttribute('day');
|
|
|
|
if (day && day == currentDay) {
|
|
|
|
var td = $(elements[i]).getParentWithTagName("td");
|
|
|
|
if (document.selectedDate)
|
|
|
|
document.selectedDate.deselect();
|
|
|
|
$(td).selectElement();
|
|
|
|
document.selectedDate = td;
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2009-07-15 20:26:08 +02:00
|
|
|
function loadPreviousView(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var previousArrow = $$("A.leftNavigationArrow").first();
|
|
|
|
onCalendarGotoDay(previousArrow);
|
2009-07-15 20:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadNextView(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var nextArrow = $$("A.rightNavigationArrow").first();
|
|
|
|
onCalendarGotoDay(nextArrow);
|
2009-07-15 20:26:08 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeDateSelectorDisplay(day, keepCurrentDay) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var url = ApplicationBaseURL + "dateselector";
|
|
|
|
if (day) {
|
|
|
|
if (day.length < 8)
|
|
|
|
day += "01";
|
|
|
|
url += "?day=" + day;
|
2006-09-07 17:50:03 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-04-26 18:01:01 +02:00
|
|
|
if (!keepCurrentDay)
|
|
|
|
currentDay = day;
|
|
|
|
|
|
|
|
var month = day.substr(0, 6);
|
|
|
|
if (cachedDateSelectors[month]) {
|
|
|
|
// log ("restoring cached selector for month: " + month);
|
|
|
|
setDateSelectorContent(cachedDateSelectors[month]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// log ("loading selector for month: " + month);
|
|
|
|
if (document.dateSelectorAjaxRequest) {
|
|
|
|
document.dateSelectorAjaxRequest.aborted = true;
|
|
|
|
document.dateSelectorAjaxRequest.abort();
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2010-04-26 18:01:01 +02:00
|
|
|
document.dateSelectorAjaxRequest
|
|
|
|
= triggerAjaxRequest(url,
|
|
|
|
dateSelectorCallback,
|
|
|
|
month);
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-11-07 18:37:58 +01:00
|
|
|
function changeCalendarDisplay(data, newView) {
|
2009-07-19 18:41:42 +02:00
|
|
|
newView = ((newView) ? newView : currentView);
|
|
|
|
var url = ApplicationBaseURL + newView;
|
|
|
|
var day = null;
|
|
|
|
var scrollEvent = null;
|
2008-08-19 00:45:59 +02:00
|
|
|
if (data) {
|
2009-07-19 18:41:42 +02:00
|
|
|
day = data['day'];
|
|
|
|
scrollEvent = data['scrollEvent'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!day)
|
|
|
|
day = currentDay;
|
|
|
|
|
|
|
|
if (day) {
|
|
|
|
if (data) {
|
2010-02-13 00:24:24 +01:00
|
|
|
var dayDiv = $("day"+day);
|
|
|
|
if (dayDiv) {
|
2009-07-19 18:41:42 +02:00
|
|
|
// Don't reload the view if the event is present in current view
|
|
|
|
|
|
|
|
// Deselect day in date selector
|
|
|
|
if (document.selectedDate)
|
|
|
|
document.selectedDate.deselect();
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// Select day in date selector
|
2009-07-28 22:09:24 +02:00
|
|
|
var selectedLink = $$('table#dateSelectorTable span[day='+day+']');
|
2009-07-19 18:41:42 +02:00
|
|
|
if (selectedLink.length > 0) {
|
2009-07-28 22:09:24 +02:00
|
|
|
selectedCell = selectedLink[0].getParentWithTagName("td");
|
2009-10-16 21:38:23 +02:00
|
|
|
$(selectedCell).selectElement();
|
2009-07-19 18:41:42 +02:00
|
|
|
document.selectedDate = selectedCell;
|
2010-02-13 00:24:24 +01:00
|
|
|
} else
|
|
|
|
document.selectedDate = null;
|
2010-01-25 18:08:17 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// Scroll to event
|
2009-10-16 21:38:23 +02:00
|
|
|
if (scrollEvent) {
|
|
|
|
preventAutoScroll = false;
|
2009-08-27 18:51:30 +02:00
|
|
|
scrollDayView(scrollEvent);
|
2009-10-16 21:38:23 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
setSelectedDayDate(day);
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (day.length == 6) {
|
|
|
|
day += "01";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
url += "?day=" + day;
|
2007-11-16 20:38:49 +01:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
selectedCalendarCell = null;
|
2007-11-19 18:09:14 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (document.dayDisplayAjaxRequest) {
|
|
|
|
document.dayDisplayAjaxRequest.aborted = true;
|
|
|
|
document.dayDisplayAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dayDisplayAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, calendarDisplayCallback,
|
|
|
|
{ "view": newView,
|
|
|
|
"day": day,
|
|
|
|
"scrollEvent": scrollEvent });
|
2006-08-24 20:48:33 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-08-24 20:48:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function _ensureView(view) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (currentView != view)
|
|
|
|
changeCalendarDisplay(null, view);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onDayOverview() {
|
2009-07-19 18:41:42 +02:00
|
|
|
return _ensureView("dayview");
|
2006-08-24 20:48:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMulticolumnDayOverview() {
|
2009-07-19 18:41:42 +02:00
|
|
|
return _ensureView("multicolumndayview");
|
2007-02-13 23:01:02 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onWeekOverview() {
|
2009-07-19 18:41:42 +02:00
|
|
|
return _ensureView("weekview");
|
2006-08-24 20:48:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMonthOverview() {
|
2009-07-19 18:41:42 +02:00
|
|
|
return _ensureView("monthview");
|
2006-08-24 20:48:33 +02:00
|
|
|
}
|
|
|
|
|
2009-07-15 22:36:06 +02:00
|
|
|
function onCalendarReload() {
|
2010-01-22 21:42:37 +01:00
|
|
|
refreshEvents();
|
2009-12-23 23:09:18 +01:00
|
|
|
refreshTasks();
|
2010-01-22 21:42:37 +01:00
|
|
|
reloadWebCalendars();
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2009-07-15 22:36:06 +02:00
|
|
|
}
|
|
|
|
|
2010-01-22 21:42:37 +01:00
|
|
|
function reloadWebCalendars() {
|
2009-09-10 19:26:57 +02:00
|
|
|
var url = ApplicationBaseURL + "reloadWebCalendars";
|
|
|
|
if (document.reloadWebCalAjaxRequest) {
|
|
|
|
document.reloadWebCalAjaxRequest.aborted = true;
|
|
|
|
document.reloadWebCalAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.reloadWebCalAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, reloadWebCalendarsCallback);
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-09-10 19:26:57 +02:00
|
|
|
function reloadWebCalendarsCallback (http) {
|
|
|
|
changeCalendarDisplay(null, currentView);
|
|
|
|
}
|
|
|
|
|
2007-11-07 18:37:58 +01:00
|
|
|
function scrollDayView(scrollEvent) {
|
2009-08-18 20:23:13 +02:00
|
|
|
if (!preventAutoScroll) {
|
|
|
|
if (scrollEvent) {
|
|
|
|
var contentView;
|
|
|
|
var eventRow = $(scrollEvent);
|
|
|
|
var eventBlocks = selectCalendarEvent(eventRow.calendar, eventRow.cname, eventRow.recurrenceTime);
|
|
|
|
var firstEvent = eventBlocks.first();
|
|
|
|
|
|
|
|
if (currentView == "monthview")
|
|
|
|
contentView = firstEvent.up("DIV.day");
|
|
|
|
else
|
|
|
|
contentView = $("daysView");
|
|
|
|
|
2009-10-16 21:38:23 +02:00
|
|
|
// Don't scroll to an all-day event
|
|
|
|
if (typeof eventRow.hour != "undefined") {
|
|
|
|
var top = firstEvent.cumulativeOffset()[1] - contentView.scrollTop;
|
|
|
|
// Don't scroll if the event is visible to the user
|
|
|
|
if (top < contentView.cumulativeOffset()[1])
|
|
|
|
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
|
|
|
|
else if (top > contentView.cumulativeOffset()[1] + contentView.getHeight() - firstEvent.getHeight())
|
|
|
|
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
|
|
|
|
}
|
2009-08-18 20:23:13 +02:00
|
|
|
}
|
|
|
|
else if (currentView != "monthview") {
|
|
|
|
var contentView = $("daysView");
|
|
|
|
var hours = (contentView.childNodesWithTag("div")[0]).childNodesWithTag("div");
|
|
|
|
contentView.scrollTop = hours[dayStartHour].offsetTop;
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2006-10-04 00:59:07 +02:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:53:59 +01:00
|
|
|
function onClickableCellsDblClick(event) {
|
2010-03-31 17:27:59 +02:00
|
|
|
var target = getTarget(event);
|
2010-04-02 19:33:29 +02:00
|
|
|
// Hack to ignore double-click in the scrollbar
|
|
|
|
if (target.hasClassName("dayHeader") || (this.scrollHeight - this.clientHeight <= 1)) {
|
2010-03-31 17:27:59 +02:00
|
|
|
newEventFromWidget(this, 'event');
|
|
|
|
Event.stop(event);
|
|
|
|
}
|
2006-11-15 01:53:59 +01:00
|
|
|
}
|
|
|
|
|
2007-11-16 20:38:49 +01:00
|
|
|
function refreshCalendarEvents(scrollEvent) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var todayDate = new Date();
|
|
|
|
var sd;
|
|
|
|
var ed;
|
2009-08-27 18:51:30 +02:00
|
|
|
|
|
|
|
if (!currentDay)
|
|
|
|
currentDay = todayDate.getDayString();
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (currentView == "dayview") {
|
2009-08-27 18:51:30 +02:00
|
|
|
sd = currentDay;
|
2009-07-19 18:41:42 +02:00
|
|
|
ed = sd;
|
|
|
|
}
|
|
|
|
else if (currentView == "weekview") {
|
|
|
|
var startDate;
|
2009-08-27 18:51:30 +02:00
|
|
|
startDate = currentDay.asDate();
|
2009-07-19 18:41:42 +02:00
|
|
|
startDate = startDate.beginOfWeek();
|
|
|
|
sd = startDate.getDayString();
|
|
|
|
var endDate = new Date();
|
|
|
|
endDate.setTime(startDate.getTime());
|
|
|
|
endDate.addDays(6);
|
|
|
|
ed = endDate.getDayString();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var monthDate;
|
2009-08-27 18:51:30 +02:00
|
|
|
monthDate = currentDay.asDate();
|
2009-07-19 18:41:42 +02:00
|
|
|
monthDate.setDate(1);
|
|
|
|
sd = monthDate.beginOfWeek().getDayString();
|
|
|
|
|
|
|
|
var lastMonthDate = new Date();
|
|
|
|
lastMonthDate.setTime(monthDate.getTime());
|
|
|
|
lastMonthDate.setMonth(monthDate.getMonth() + 1);
|
|
|
|
lastMonthDate.addDays(-1);
|
|
|
|
ed = lastMonthDate.endOfWeek().getDayString();
|
|
|
|
}
|
|
|
|
if (document.refreshCalendarEventsAjaxRequest) {
|
|
|
|
document.refreshCalendarEventsAjaxRequest.aborted = true;
|
|
|
|
document.refreshCalendarEventsAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var url = (ApplicationBaseURL + "eventsblocks?sd=" + sd + "&ed=" + ed
|
|
|
|
+ "&view=" + currentView);
|
|
|
|
document.refreshCalendarEventsAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, refreshCalendarEventsCallback,
|
|
|
|
{"startDate": sd, "endDate": ed,
|
|
|
|
"scrollEvent": scrollEvent});
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _parseEvents(list) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var newCalendarEvents = {};
|
|
|
|
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var event = list[i];
|
|
|
|
var cname = event[0];
|
|
|
|
var calendar = event[1];
|
2010-02-11 03:36:43 +01:00
|
|
|
// log("parsed cname: " + cname + "; calendar: " + calendar);
|
2009-07-19 18:41:42 +02:00
|
|
|
var calendarDict = newCalendarEvents[calendar];
|
|
|
|
if (!calendarDict) {
|
|
|
|
calendarDict = {};
|
|
|
|
newCalendarEvents[calendar] = calendarDict;
|
|
|
|
}
|
|
|
|
var occurences = calendarDict[cname];
|
|
|
|
if (!occurences) {
|
|
|
|
occurences = [];
|
|
|
|
calendarDict[cname] = occurences;
|
|
|
|
}
|
|
|
|
event.blocks = [];
|
|
|
|
occurences.push(event);
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return newCalendarEvents;
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
function _setupEventsDragAndDrop(events) {
|
|
|
|
/* We setup the drag controllers for all the events.
|
|
|
|
Since the same events may be listed more than once per calendar
|
|
|
|
(repeating events), we must keep account of those that have already
|
|
|
|
been setup. */
|
|
|
|
var setupFlags = {};
|
|
|
|
|
|
|
|
for (var i = 0; i < events.length; i++) {
|
2010-03-15 13:51:57 +01:00
|
|
|
var cname = events[i][0];
|
|
|
|
var calendar = events[i][1];
|
|
|
|
var setupId = calendar + "_" + cname;
|
|
|
|
if (!setupFlags[setupId]) {
|
|
|
|
var occurrences = calendarEvents[calendar][cname];
|
|
|
|
for (var j = 0; j < occurrences.length; j++) {
|
|
|
|
var blocks = occurrences[j].blocks;
|
|
|
|
var dragController = new SOGoEventDragController();
|
|
|
|
dragController.updateDropCallback = updateEventFromDragging;
|
|
|
|
dragController.attachToEventCells(blocks);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
2010-03-15 13:51:57 +01:00
|
|
|
setupFlags[setupId] = true;
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-11 23:23:48 +02:00
|
|
|
function refreshCalendarEventsCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var eventsBlocks = http.responseText.evalJSON(true);
|
|
|
|
calendarEvents = _parseEvents(eventsBlocks[0]);
|
|
|
|
if (currentView == "monthview")
|
|
|
|
_drawMonthCalendarEvents(eventsBlocks[2], eventsBlocks[0]);
|
|
|
|
else {
|
|
|
|
_drawCalendarAllDayEvents(eventsBlocks[1], eventsBlocks[0]);
|
|
|
|
_drawCalendarEvents(eventsBlocks[2], eventsBlocks[0]);
|
|
|
|
}
|
2010-02-11 20:48:09 +01:00
|
|
|
_setupEventsDragAndDrop(eventsBlocks[0]);
|
2010-05-16 19:27:25 +02:00
|
|
|
resetCategoriesStyles();
|
2009-07-19 18:41:42 +02:00
|
|
|
onWindowResize(null);
|
|
|
|
}
|
2009-10-26 15:49:25 +01:00
|
|
|
if (http.callbackData["scrollEvent"])
|
2009-10-16 21:38:23 +02:00
|
|
|
preventAutoScroll = false;
|
2009-10-26 15:49:25 +01:00
|
|
|
scrollDayView(http.callbackData["scrollEvent"]);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log("AJAX error when refreshing calendar events");
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2010-05-16 19:27:25 +02:00
|
|
|
function resetCategoriesStyles() {
|
|
|
|
if (categoriesStyleSheet == null) {
|
|
|
|
categoriesStyleSheet = document.createElement("style");
|
|
|
|
categoriesStyleSheet.type = "text/css";
|
|
|
|
document.getElementsByTagName("head")[0].appendChild(categoriesStyleSheet);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (Prototype.Browser.IE)
|
|
|
|
while (categoriesStyleSheet.styleSheet.rules.length)
|
|
|
|
categoriesStyleSheet.styleSheet.removeRule();
|
|
|
|
else
|
|
|
|
while (categoriesStyleSheet.firstChild)
|
|
|
|
categoriesStyleSheet.removeChild(categoriesStyleSheet.firstChild);
|
|
|
|
}
|
|
|
|
|
2010-05-21 23:22:25 +02:00
|
|
|
if (UserDefaults['SOGoCalendarCategoriesColors']) {
|
|
|
|
// Update stylesheet with new categories colors
|
|
|
|
var selectors = [];
|
|
|
|
var rules = [];
|
|
|
|
categoriesStyles.keys().each(function(category) {
|
2010-05-16 19:27:25 +02:00
|
|
|
var color = UserDefaults['SOGoCalendarCategoriesColors'][category];
|
|
|
|
if (color) {
|
|
|
|
rules[rules.length] = '{ border-right: 8px solid ' + color + '; }';
|
|
|
|
selectors[selectors.length] = 'DIV.' + categoriesStyles.get(category);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-05-21 23:22:25 +02:00
|
|
|
if (selectors.length > 0) {
|
|
|
|
if (categoriesStyleSheet.styleSheet && categoriesStyleSheet.styleSheet.addRule) {
|
|
|
|
// IE
|
|
|
|
for (var i = 0; i < selectors.length; i++)
|
|
|
|
categoriesStyleSheet.styleSheet.addRule(selectors[i],
|
|
|
|
rules[i]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Mozilla + Safari
|
|
|
|
for (var i = 0; i < selectors.length; i++)
|
|
|
|
categoriesStyleSheet.appendChild(document.createTextNode(selectors[i] +
|
|
|
|
' ' + rules[i]));
|
|
|
|
}
|
2010-05-16 19:27:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
function newBaseEventDIV(eventRep, event, eventText) {
|
2009-07-19 18:41:42 +02:00
|
|
|
// log ("0 cname = " + event[0]);
|
|
|
|
// log ("1 calendar = " + event[1]);
|
|
|
|
// log ("2 status = " + event[2]);
|
|
|
|
// log ("3 title = " + event[3]);
|
|
|
|
// log ("4 start = " + event[4]);
|
|
|
|
// log ("5 end = " + event[5]);
|
|
|
|
// log ("6 location = " + event[6]);
|
|
|
|
// log ("7 isallday = " + event[7]);
|
2010-08-27 22:16:35 +02:00
|
|
|
// log ("8 classification = " + event[8]); // 0 = public, 1 = private, 2 = confidential
|
2010-05-18 20:35:47 +02:00
|
|
|
// log ("9 category = " + event[9]);
|
|
|
|
// log ("10 participants emails = " + event[10]);
|
|
|
|
// log ("11 participants states = " + event[11]);
|
|
|
|
// log ("12 owner = " + event[12]);
|
|
|
|
// log ("13 iscycle = " + event[13]);
|
|
|
|
// log ("14 nextalarm = " + event[14]);
|
|
|
|
// log ("15 recurrenceid = " + event[15]);
|
|
|
|
// log ("16 isexception = " + event[16]);
|
|
|
|
// log ("17 editable = " + event[17]);
|
|
|
|
// log ("18 erasable = " + event[18]);
|
|
|
|
// log ("19 ownerisorganizer = " + event[19]);
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
var eventCell = createElement("div");
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.cname = event[0];
|
|
|
|
eventCell.calendar = event[1];
|
2010-08-27 22:16:35 +02:00
|
|
|
// if (event[8] == 1)
|
|
|
|
// eventCell.addClassName("private");
|
|
|
|
// else if (event[8] == 2)
|
|
|
|
// eventCell.addClassName("confidential");
|
2009-07-19 18:41:42 +02:00
|
|
|
if (eventRep.recurrenceTime)
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.recurrenceTime = eventRep.recurrenceTime;
|
2010-08-26 16:14:10 +02:00
|
|
|
//eventCell.owner = event[12];
|
2010-05-18 20:35:47 +02:00
|
|
|
eventCell.isException = event[16];
|
|
|
|
eventCell.editable = event[17];
|
|
|
|
eventCell.erasable = event[18];
|
|
|
|
eventCell.ownerIsOrganizer = event[19];
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.addClassName("event");
|
2010-08-27 22:16:35 +02:00
|
|
|
// if (event[14] > 0)
|
|
|
|
// eventCell.addClassName("alarm");
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
var innerDiv = createElement("div");
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.appendChild(innerDiv);
|
2009-07-19 18:41:42 +02:00
|
|
|
innerDiv.addClassName("eventInside");
|
|
|
|
innerDiv.addClassName("calendarFolder" + event[1]);
|
|
|
|
if (eventRep.userState >= 0 && userStates[eventRep.userState])
|
|
|
|
innerDiv.addClassName(userStates[eventRep.userState]);
|
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
var gradientDiv = createElement("div");
|
2009-07-19 18:41:42 +02:00
|
|
|
innerDiv.appendChild(gradientDiv);
|
|
|
|
gradientDiv.addClassName("gradient");
|
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
var gradientImg = createElement("img");
|
2009-07-19 18:41:42 +02:00
|
|
|
gradientDiv.appendChild(gradientImg);
|
|
|
|
gradientImg.src = ResourcesURL + "/event-gradient.png";
|
|
|
|
|
2010-05-21 15:59:35 +02:00
|
|
|
var textDiv = createElement("div");
|
2009-07-19 18:41:42 +02:00
|
|
|
innerDiv.appendChild(textDiv);
|
|
|
|
textDiv.addClassName("text");
|
2010-08-27 22:16:35 +02:00
|
|
|
var iconSpan = createElement("span");
|
|
|
|
textDiv.appendChild(iconSpan);
|
|
|
|
textDiv.appendChild(document.createTextNode(eventText.replace(/(\\r)?\\n/g, "<BR/>")));
|
|
|
|
|
|
|
|
// Add alarm and classification icons
|
|
|
|
if (event[8] == 1)
|
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/private.png"}, null, iconSpan);
|
|
|
|
else if (event[8] == 2)
|
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/confidential.png"}, null, iconSpan);
|
|
|
|
if (event[14] > 0)
|
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/alarm.png"}, null, iconSpan);
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-05-16 19:27:25 +02:00
|
|
|
if (event[9] != null) {
|
|
|
|
var categoryStyle = categoriesStyles.get(event[9]);
|
|
|
|
if (!categoryStyle) {
|
|
|
|
categoryStyle = 'category_' + categoriesStyles.keys().length;
|
|
|
|
categoriesStyles.set([event[9]], categoryStyle);
|
|
|
|
}
|
|
|
|
innerDiv.addClassName(categoryStyle);
|
|
|
|
}
|
2010-05-16 21:24:07 +02:00
|
|
|
eventCell.observe("contextmenu", onMenuCurrentView);
|
|
|
|
|
2009-07-27 21:30:05 +02:00
|
|
|
if (event[2] == null) {
|
2010-03-31 22:21:49 +02:00
|
|
|
// Status field is not defined -- user can't read event
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.observe("selectstart", listRowMouseDownHandler);
|
|
|
|
eventCell.observe("click", onCalendarSelectEvent);
|
|
|
|
eventCell.observe("dblclick", Event.stop);
|
2009-07-27 21:30:05 +02:00
|
|
|
}
|
|
|
|
else {
|
2009-07-19 18:41:42 +02:00
|
|
|
// Status field is defined -- user can read event
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
eventCell.observe("click", onCalendarSelectEvent);
|
|
|
|
eventCell.observe("dblclick", editDoubleClickedEvent);
|
|
|
|
eventCell.observe("click", onViewEvent);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
event.blocks.push(eventCell);
|
|
|
|
|
|
|
|
return eventCell;
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
2008-07-17 23:12:43 +02:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _drawCalendarAllDayEvents(events, eventsData) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var daysView = $("calendarHeader");
|
|
|
|
var subdivs = daysView.childNodesWithTag("div");
|
|
|
|
var days = subdivs[1].childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
var parentDiv = days[i];
|
|
|
|
for (var j = 0; j < events[i].length; j++) {
|
|
|
|
var eventRep = events[i][j];
|
|
|
|
var nbr = eventRep.nbr;
|
2010-02-11 03:36:43 +01:00
|
|
|
var eventCell = newAllDayEventDIV(eventRep, eventsData[nbr]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function newAllDayEventDIV(eventRep, event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
// cname, calendar, starts, lasts,
|
|
|
|
// startHour, endHour, title) {
|
2010-02-11 03:36:43 +01:00
|
|
|
var eventCell = newBaseEventDIV(eventRep, event, event[3]);
|
2008-07-17 23:12:43 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
return eventCell;
|
2008-07-17 23:12:43 +02:00
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _drawCalendarEvents(events, eventsData) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var daysView = $("daysView");
|
|
|
|
var subdivs = daysView.childNodesWithTag("div");
|
2010-02-12 18:23:47 +01:00
|
|
|
for (var i = 0; i < subdivs.length; i++) {
|
|
|
|
var subdiv = subdivs[i];
|
|
|
|
if (subdiv.hasClassName("days")) {
|
|
|
|
var days = subdiv.childNodesWithTag("div");
|
|
|
|
for (var j = 0; j < days.length; j++) {
|
|
|
|
var parentDiv = days[j].childNodesWithTag("div")[0];
|
|
|
|
for (var k = 0; k < events[j].length; k++) {
|
|
|
|
var eventRep = events[j][k];
|
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
var eventCell = newEventDIV(eventRep, eventsData[nbr]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function newEventDIV(eventRep, event) {
|
2010-02-11 03:36:43 +01:00
|
|
|
var eventCell = newBaseEventDIV(eventRep, event, event[3]);
|
2008-07-16 04:12:18 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var pc = 100 / eventRep.siblings;
|
2010-02-12 18:23:47 +01:00
|
|
|
var left = Math.floor(eventRep.position * pc);
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.style.left = left + "%";
|
2010-02-12 18:23:47 +01:00
|
|
|
var right = Math.floor(100 - (eventRep.position + 1) * pc);
|
|
|
|
eventCell.style.right = right + "%";
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.addClassName("starts" + eventRep.start);
|
|
|
|
eventCell.addClassName("lasts" + eventRep.length);
|
2008-03-27 22:05:47 +01:00
|
|
|
|
2010-05-21 01:31:09 +02:00
|
|
|
if (event[6]) {
|
|
|
|
var inside = eventCell.childNodesWithTag("div")[0];
|
|
|
|
var textDiv = inside.childNodesWithTag("div")[1];
|
|
|
|
textDiv.appendChild(createElement("br"));
|
|
|
|
var span = createElement("span", null, "location");
|
2010-06-02 21:11:15 +02:00
|
|
|
var text = _("Location:") + " " + event[6];
|
2010-05-21 01:31:09 +02:00
|
|
|
span.appendChild(document.createTextNode(text));
|
|
|
|
textDiv.appendChild(span);
|
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
return eventCell;
|
2007-11-16 20:38:49 +01:00
|
|
|
}
|
2007-11-07 18:37:58 +01:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _drawMonthCalendarEvents(events, eventsData) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var daysView = $("monthDaysView");
|
|
|
|
var days = daysView.childNodesWithTag("div");
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
var parentDiv = days[i];
|
|
|
|
for (var j = 0; j < events[i].length; j++) {
|
|
|
|
var eventRep = events[i][j];
|
|
|
|
var nbr = eventRep.nbr;
|
2010-02-11 03:36:43 +01:00
|
|
|
var eventCell = newMonthEventDIV(eventRep, eventsData[nbr]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function newMonthEventDIV(eventRep, event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var eventText;
|
|
|
|
if (event[7]) // all-day event
|
|
|
|
eventText = event[3];
|
|
|
|
else
|
|
|
|
eventText = eventRep.starthour + " - " + event[3];
|
2008-01-24 22:36:51 +01:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
var eventCell = newBaseEventDIV(eventRep, event,
|
|
|
|
eventText);
|
|
|
|
|
|
|
|
return eventCell;
|
|
|
|
}
|
2008-07-16 04:12:18 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
function attachDragControllers(contentView) {
|
2010-02-13 17:57:39 +01:00
|
|
|
var dayNodes = contentView.select("DIV.days DIV.day");
|
2010-02-11 20:48:09 +01:00
|
|
|
for (var j = 0; j < dayNodes.length; j++) {
|
|
|
|
var dayNode = dayNodes[j];
|
|
|
|
if (dayNode.hasClassName("day")) {
|
|
|
|
var dragController = new SOGoEventDragController();
|
|
|
|
dragController.createDropCallback = newEventFromDragging;
|
|
|
|
dragController.attachToDayNode(dayNode);
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
2010-02-12 18:23:47 +01:00
|
|
|
/* On IE, the scroll bar is part of the last element. For other browsers, we
|
|
|
|
execute this method so that the "right" style attribute of the
|
|
|
|
"calendarHeader" element can be computed. This is execute only once. */
|
|
|
|
function adjustCalendarHeaderDIV() {
|
|
|
|
var dv = $("daysView");
|
|
|
|
if (dv) {
|
|
|
|
var ch = $("calendarHeader");
|
|
|
|
var delta = ch.clientWidth - dv.clientWidth - 1;
|
|
|
|
var styleElement = document.createElement("style");
|
|
|
|
styleElement.type = "text/css";
|
2010-02-13 17:57:39 +01:00
|
|
|
var selectors = ["DIV#calendarHeader DIV.dayLabels",
|
|
|
|
"DIV#calendarHeader DIV.days"];
|
|
|
|
var rule = ("{ right: " + delta + "px; }");
|
|
|
|
if (styleElement.styleSheet && styleElement.styleSheet.addRule) {
|
2010-05-16 19:27:25 +02:00
|
|
|
// IE
|
2010-02-13 17:57:39 +01:00
|
|
|
styleElement.styleSheet.addRule(selectors[0], rule);
|
|
|
|
styleElement.styleSheet.addRule(selectors[1], rule);
|
|
|
|
} else {
|
2010-05-16 19:27:25 +02:00
|
|
|
// Mozilla + Firefox
|
2010-02-13 17:57:39 +01:00
|
|
|
var styleText = selectors.join(",") + " " + rule;
|
|
|
|
styleElement.appendChild(document.createTextNode(styleText));
|
|
|
|
}
|
2010-02-12 18:23:47 +01:00
|
|
|
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
|
|
|
calendarHeaderAdjusted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function calendarDisplayCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var div = $("calendarView");
|
2009-08-18 20:23:13 +02:00
|
|
|
var daysView = $("daysView");
|
|
|
|
var position = -1;
|
|
|
|
|
2009-08-27 18:51:30 +02:00
|
|
|
// Check the previous view to restore the scrolling position
|
2009-08-18 20:23:13 +02:00
|
|
|
if (daysView)
|
|
|
|
position = daysView.scrollTop;
|
2009-08-27 18:51:30 +02:00
|
|
|
preventAutoScroll = (position != -1);
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.dayDisplayAjaxRequest = null;
|
|
|
|
div.update(http.responseText);
|
|
|
|
|
2009-08-18 20:23:13 +02:00
|
|
|
// DOM has changed
|
2009-08-20 19:27:08 +02:00
|
|
|
daysView = $("daysView");
|
2010-02-12 18:23:47 +01:00
|
|
|
if (daysView) {
|
|
|
|
if (preventAutoScroll)
|
|
|
|
daysView.scrollTop = position;
|
|
|
|
if (!calendarHeaderAdjusted)
|
|
|
|
adjustCalendarHeaderDIV();
|
|
|
|
}
|
2009-08-18 20:23:13 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.callbackData["view"])
|
|
|
|
currentView = http.callbackData["view"];
|
|
|
|
if (http.callbackData["day"])
|
|
|
|
currentDay = http.callbackData["day"];
|
|
|
|
|
|
|
|
// Initialize contextual menu
|
2010-08-26 16:14:10 +02:00
|
|
|
var menu = new Array(onMenuNewEventClick,
|
2009-07-19 18:41:42 +02:00
|
|
|
onMenuNewTaskClick,
|
|
|
|
"-",
|
|
|
|
loadPreviousView,
|
2009-12-22 23:45:37 +01:00
|
|
|
loadNextView,
|
|
|
|
"-",
|
2010-08-26 16:14:10 +02:00
|
|
|
deleteEvent,
|
|
|
|
copyEventToPersonalCalendar);
|
|
|
|
var observer;
|
|
|
|
if (currentView == 'dayview') {
|
2009-07-19 18:41:42 +02:00
|
|
|
observer = $("daysView");
|
|
|
|
}
|
|
|
|
else if (currentView == 'weekview') {
|
|
|
|
observer = $("daysView");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
observer = $("monthDaysView");
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var contentView;
|
|
|
|
if (currentView == "monthview")
|
|
|
|
contentView = $("calendarContent");
|
|
|
|
else {
|
|
|
|
contentView = $("daysView");
|
|
|
|
contentView.observe("scroll", onBodyClickHandler);
|
2010-02-11 20:48:09 +01:00
|
|
|
attachDragControllers($("calendarHeader"));
|
2010-03-31 22:21:49 +02:00
|
|
|
|
|
|
|
// Create a clone of the contextual menu for the all-day
|
|
|
|
// events area
|
|
|
|
var allDayViewMenu = Element.clone($("currentViewMenu"), true);
|
|
|
|
allDayViewMenu.id = "allDayViewMenu";
|
|
|
|
var newEventMenuItem = allDayViewMenu.select("LI").first();
|
|
|
|
newEventMenuItem.writeAttribute("hour", "allday");
|
|
|
|
$("currentViewMenu").parentNode.appendChild(allDayViewMenu);
|
|
|
|
initMenu($("allDayViewMenu"), menu);
|
|
|
|
var allDayArea = $$("DIV#calendarHeader DIV.days").first();
|
|
|
|
allDayArea.observe("contextmenu", onMenuAllDayView);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2010-02-11 20:48:09 +01:00
|
|
|
attachDragControllers(contentView);
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2010-03-31 22:21:49 +02:00
|
|
|
// Attach contextual menu
|
2010-08-26 16:14:10 +02:00
|
|
|
var currentViewMenu = $("currentViewMenu");
|
|
|
|
initMenu(currentViewMenu, menu);
|
2010-03-31 22:21:49 +02:00
|
|
|
observer.observe("contextmenu", onMenuCurrentView);
|
2010-08-26 16:14:10 +02:00
|
|
|
currentViewMenu.prepareVisibility = onMenuCurrentViewPrepareVisibility;
|
2010-03-31 22:21:49 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
restoreSelectedDay();
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
refreshCalendarEvents(http.callbackData.scrollEvent);
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var days = contentView.select("DIV.day");
|
|
|
|
|
|
|
|
if (currentView == "monthview")
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
days[i].observe("click", onCalendarSelectDay);
|
|
|
|
days[i].observe("dblclick", onClickableCellsDblClick);
|
|
|
|
days[i].observe("selectstart", listRowMouseDownHandler);
|
|
|
|
//days[i].down(".dayHeader").observe("selectstart", listRowMouseDownHandler);
|
|
|
|
if (currentView == "monthview")
|
|
|
|
days[i].observe("scroll", onBodyClickHandler);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var calendarHeader = $("calendarHeader");
|
|
|
|
var headerDaysLabels = calendarHeader.select("DIV.dayLabels DIV.day");
|
|
|
|
var headerDays = calendarHeader.select("DIV.days DIV.day");
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
headerDays[i].hour = "allday";
|
|
|
|
headerDaysLabels[i].observe("mousedown", listRowMouseDownHandler);
|
|
|
|
headerDays[i].observe("click", onCalendarSelectDay);
|
|
|
|
headerDays[i].observe("dblclick", onClickableCellsDblClick);
|
|
|
|
days[i].observe("click", onCalendarSelectDay);
|
|
|
|
|
|
|
|
var clickableCells = days[i].select("DIV.clickableHourCell");
|
|
|
|
for (var j = 0; j < clickableCells.length; j++)
|
2010-02-11 03:36:43 +01:00
|
|
|
clickableCells[j].observe("dblclick", onClickableCellsDblClick);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("calendarDisplayCallback Ajax error ("
|
|
|
|
+ http.readyState + "/" + http.status + ")");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function assignCalendar(name) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (typeof(skycalendar) != "undefined") {
|
|
|
|
var node = $(name);
|
2009-07-23 22:11:06 +02:00
|
|
|
if (node) {
|
|
|
|
node.calendar = new skycalendar(node);
|
|
|
|
node.calendar.setCalendarPage(ResourcesURL + "/skycalendar.html");
|
|
|
|
var dateFormat = node.getAttribute("dateFormat");
|
|
|
|
if (dateFormat)
|
2009-07-19 18:41:42 +02:00
|
|
|
node.calendar.setDateFormat(dateFormat);
|
2009-07-23 22:11:06 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2006-08-31 01:13:18 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function popupCalendar(node) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var nodeId = $(node).readAttribute("inputId");
|
|
|
|
var input = $(nodeId);
|
|
|
|
input.calendar.popup();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function onEventsSelectionChange() {
|
2009-07-19 18:41:42 +02:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
|
|
|
$("tasksList").addClassName("_unfocused");
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
deselectAll(true);
|
2009-07-19 18:41:42 +02:00
|
|
|
var rows = $(this.tBodies[0]).getSelectedNodes();
|
|
|
|
if (rows.length == 1) {
|
|
|
|
var row = rows[0];
|
|
|
|
changeCalendarDisplay( { "day": row.day,
|
|
|
|
"scrollEvent": row.getAttribute("id") } );
|
2010-08-26 16:14:10 +02:00
|
|
|
changeDateSelectorDisplay(row.day, true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Select visible events cells
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
var row = rows[i];
|
|
|
|
selectCalendarEvent(row.calendar, row.cname, row.recurrenceTime);
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onTasksSelectionChange() {
|
2009-07-19 18:41:42 +02:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
|
|
|
$("eventsList").addClassName("_unfocused");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function _loadEventHref(href) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (document.eventsListAjaxRequest) {
|
|
|
|
document.eventsListAjaxRequest.aborted = true;
|
|
|
|
document.eventsListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var url = ApplicationBaseURL + href;
|
|
|
|
document.eventsListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, eventsListCallback, href);
|
2007-06-08 01:23:07 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function _loadTasksHref(href) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (document.tasksListAjaxRequest) {
|
|
|
|
document.tasksListAjaxRequest.aborted = true;
|
|
|
|
document.tasksListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
url = ApplicationBaseURL + href;
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var tasksList = $("tasksList");
|
|
|
|
var selectedIds;
|
|
|
|
if (tasksList)
|
|
|
|
selectedIds = tasksList.getSelectedNodesId();
|
|
|
|
else
|
|
|
|
selectedIds = null;
|
|
|
|
document.tasksListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, tasksListCallback, selectedIds);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return true;
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onHeaderClick(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var headerId = this.getAttribute("id");
|
|
|
|
var newSortAttribute;
|
|
|
|
if (headerId == "titleHeader")
|
|
|
|
newSortAttribute = "title";
|
|
|
|
else if (headerId == "startHeader")
|
|
|
|
newSortAttribute = "start";
|
|
|
|
else if (headerId == "endHeader")
|
|
|
|
newSortAttribute = "end";
|
|
|
|
else if (headerId == "locationHeader")
|
|
|
|
newSortAttribute = "location";
|
|
|
|
else
|
|
|
|
newSortAttribute = "start";
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (sorting["attribute"] == newSortAttribute)
|
|
|
|
sorting["ascending"] = !sorting["ascending"];
|
|
|
|
else {
|
|
|
|
sorting["attribute"] = newSortAttribute;
|
|
|
|
sorting["ascending"] = true;
|
|
|
|
}
|
|
|
|
refreshEvents();
|
2006-11-09 23:55:04 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
Event.stop(event);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-11-21 18:23:51 +01:00
|
|
|
function refreshCurrentFolder() {
|
2009-07-19 18:41:42 +02:00
|
|
|
refreshEvents();
|
2007-11-21 18:23:51 +01:00
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
/* refreshes the "unifinder" list */
|
2007-06-08 01:23:07 +02:00
|
|
|
function refreshEvents() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var titleSearch;
|
|
|
|
var value = search["value"];
|
|
|
|
if (value && value.length)
|
|
|
|
titleSearch = "&search=" + escape(value.utf8encode());
|
|
|
|
else
|
|
|
|
titleSearch = "";
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
refreshAlarms();
|
2009-04-22 23:02:11 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return _loadEventHref("eventslist?asc=" + sorting["ascending"]
|
|
|
|
+ "&sort=" + sorting["attribute"]
|
|
|
|
+ "&day=" + currentDay
|
|
|
|
+ titleSearch
|
|
|
|
+ "&filterpopup=" + listFilter);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-08-17 22:07:54 +02:00
|
|
|
function refreshTasks(setUserDefault) {
|
|
|
|
var url = "taskslist?show-completed=" + showCompletedTasks;
|
2009-11-29 05:19:32 +01:00
|
|
|
/* TODO: the logic behind this should be reimplemented properly:
|
|
|
|
the "taskslist" method should save the status when the 'show-completed'
|
|
|
|
is set to true and revert to the current status when that parameter is
|
|
|
|
NOT passed via the url. */
|
2009-08-17 22:07:54 +02:00
|
|
|
if (setUserDefault == 1)
|
|
|
|
url += "&setud=1";
|
2009-07-19 18:41:42 +02:00
|
|
|
refreshAlarms();
|
2009-08-17 22:07:54 +02:00
|
|
|
return _loadTasksHref(url);
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function refreshEventsAndDisplay() {
|
2009-07-19 18:41:42 +02:00
|
|
|
refreshEvents();
|
|
|
|
changeCalendarDisplay();
|
2006-10-18 23:53:47 +02:00
|
|
|
}
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
function onListFilterChange() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var node = $("filterpopup");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
listFilter = node.value;
|
2010-10-08 18:08:10 +02:00
|
|
|
// log ("listFilter = " + listFilter);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return refreshEvents();
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function selectMonthInMenu(menu, month) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var entries = $(menu).select("LI");
|
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
|
|
|
var entryMonth = entry.getAttribute("month");
|
|
|
|
if (entryMonth == month)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
|
|
|
}
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
|
2008-12-11 18:25:19 +01:00
|
|
|
function selectYearInMenu(menu, year) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var entries = $(menu).select("LI");
|
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
|
|
|
var entryYear = entry.innerHTML.strip();
|
|
|
|
if (entryYear == year)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
|
|
|
}
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
|
2007-07-05 21:13:59 +02:00
|
|
|
function popupMonthMenu(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (event.button == 0) {
|
|
|
|
var id = this.getAttribute("id");
|
|
|
|
if (id == "monthLabel")
|
|
|
|
menuId = "monthListMenu";
|
|
|
|
else
|
|
|
|
menuId = "yearListMenu";
|
|
|
|
|
|
|
|
var popup = $(menuId);
|
|
|
|
if (id == "monthLabel")
|
|
|
|
selectMonthInMenu(popup, this.getAttribute("month"));
|
|
|
|
else
|
|
|
|
selectYearInMenu(popup, this.innerHTML);
|
|
|
|
|
|
|
|
popupToolbarMenu(this, menuId);
|
|
|
|
Event.stop(event);
|
|
|
|
}
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMonthMenuItemClick(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var month = '' + this.getAttribute("month");
|
|
|
|
var year = '' + $("yearLabel").innerHTML.strip();
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay(year + month + "01", true);
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onYearMenuItemClick(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var month = '' + $("monthLabel").getAttribute("month");;
|
|
|
|
var year = '' + this.innerHTML.strip();
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay(year + month + "01", true);
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
2006-08-31 01:13:18 +02:00
|
|
|
|
2008-07-29 18:35:49 +02:00
|
|
|
function _eventBlocksMatching(calendar, cname, recurrenceTime) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var blocks = null;
|
|
|
|
var events = calendarEvents[calendar];
|
|
|
|
if (events) {
|
|
|
|
var occurences = events[cname];
|
|
|
|
if (occurences) {
|
|
|
|
if (recurrenceTime) {
|
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
|
|
|
var occurence = occurences[i];
|
2010-05-18 20:35:47 +02:00
|
|
|
if (occurence[15] == recurrenceTime)
|
2009-07-19 18:41:42 +02:00
|
|
|
blocks = occurence.blocks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
blocks = [];
|
|
|
|
for (var i = 0; i < occurences.length; i++) {
|
|
|
|
var occurence = occurences[i];
|
|
|
|
blocks = blocks.concat(occurence.blocks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return blocks;
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function selectCalendarEvent(calendar, cname, recurrenceTime) {
|
2009-07-19 18:41:42 +02:00
|
|
|
// Select event in calendar view
|
|
|
|
var selection = _eventBlocksMatching(calendar, cname, recurrenceTime);
|
|
|
|
if (selection) {
|
|
|
|
for (var i = 0; i < selection.length; i++)
|
|
|
|
selection[i].selectElement();
|
2010-08-26 16:14:10 +02:00
|
|
|
if (selectedCalendarCell) {
|
2010-07-30 22:10:00 +02:00
|
|
|
selectedCalendarCell = selectedCalendarCell.concat(selection);
|
2010-08-26 16:14:10 +02:00
|
|
|
}
|
2010-07-30 22:10:00 +02:00
|
|
|
else
|
|
|
|
selectedCalendarCell = selection;
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return selection;
|
2007-11-19 18:09:14 +01:00
|
|
|
}
|
|
|
|
|
2010-07-30 22:10:00 +02:00
|
|
|
function onSelectAll(event) {
|
|
|
|
if (listOfSelection)
|
|
|
|
listOfSelection.selectAll();
|
|
|
|
else {
|
|
|
|
// Select events cells
|
|
|
|
var selectedBlocks = [];
|
|
|
|
for (var c in calendarEvents) {
|
|
|
|
var events = calendarEvents[c];
|
|
|
|
for (var e in events) {
|
|
|
|
var occurrences = events[e];
|
|
|
|
for (var i = 0; i < occurrences.length; i++)
|
|
|
|
selectedBlocks = selectedBlocks.concat(occurrences[i].blocks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var i = 0; i < selectedBlocks.length; i++)
|
|
|
|
selectedBlocks[i].selectElement();
|
|
|
|
|
|
|
|
selectedCalendarCell = selectedBlocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
function deselectAll(cellsOnly) {
|
|
|
|
if (!cellsOnly && listOfSelection) {
|
|
|
|
listOfSelection.deselectAll();
|
|
|
|
}
|
|
|
|
if (selectedCalendarCell) {
|
|
|
|
for (var i = 0; i < selectedCalendarCell.length; i++)
|
|
|
|
selectedCalendarCell[i].deselect();
|
|
|
|
selectedCalendarCell = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-08 18:08:10 +02:00
|
|
|
function onCalendarSelectEvent(event, willShowContextualMenu) {
|
2010-07-30 22:10:00 +02:00
|
|
|
var alreadySelected = false;
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-07-30 22:10:00 +02:00
|
|
|
// Look for event in events list
|
|
|
|
// TODO: event will likely not be found if an Ajax query is refreshing
|
|
|
|
// the events list.
|
2009-07-19 18:41:42 +02:00
|
|
|
var rowID = this.calendar + "-" + this.cname;
|
|
|
|
if (this.recurrenceTime)
|
|
|
|
rowID += "-" + this.recurrenceTime;
|
|
|
|
var row = $(rowID);
|
2010-07-30 22:10:00 +02:00
|
|
|
|
|
|
|
// Check if event is already selected
|
|
|
|
if (selectedCalendarCell)
|
|
|
|
for (var i = 0; i < selectedCalendarCell.length; i++)
|
|
|
|
if (selectedCalendarCell[i] == this) {
|
|
|
|
alreadySelected = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1)) {
|
|
|
|
// If meta or ctrl key is pressed, inverse the selection
|
|
|
|
if (alreadySelected) {
|
|
|
|
this.deselect();
|
|
|
|
selectedCalendarCell.splice(i, 1);
|
|
|
|
if (row)
|
|
|
|
row.deselect();
|
2010-10-08 18:08:10 +02:00
|
|
|
|
2010-07-30 22:10:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2010-10-08 18:08:10 +02:00
|
|
|
else if (!(alreadySelected && willShowContextualMenu)
|
|
|
|
&& event.shiftKey == 0) {
|
|
|
|
// Unselect entries in events list and calendar view, unless :
|
|
|
|
// - Shift key is pressed;
|
|
|
|
// - Or right button is clicked and event is already selected.
|
|
|
|
listOfSelection = null;
|
2010-08-26 16:14:10 +02:00
|
|
|
deselectAll();
|
|
|
|
this.selectElement();
|
|
|
|
if (alreadySelected)
|
|
|
|
selectedCalendarCell = [this];
|
2010-07-30 22:10:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!alreadySelected) {
|
|
|
|
// Select event in calendar view
|
|
|
|
selectCalendarEvent(this.calendar, this.cname, this.recurrenceTime);
|
|
|
|
}
|
|
|
|
// Select event in events list
|
2009-07-19 18:41:42 +02:00
|
|
|
if (row) {
|
|
|
|
var div = row.parentNode.parentNode.parentNode;
|
|
|
|
div.scrollTop = row.offsetTop - (div.offsetHeight / 2);
|
|
|
|
row.selectElement();
|
|
|
|
}
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onCalendarSelectDay(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var day = this.getAttribute("day");
|
2010-10-08 18:08:10 +02:00
|
|
|
var needRefresh = (listFilter == 'view_selectedday' && day != currentDay);
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
setSelectedDayDate(day);
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
|
2010-10-08 18:08:10 +02:00
|
|
|
if (needRefresh)
|
|
|
|
refreshEvents();
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
var target = Event.findElement(event);
|
|
|
|
var div = target.up('div');
|
|
|
|
if (div && !div.hasClassName('event') && !div.hasClassName('eventInside') && !div.hasClassName('text') && !div.hasClassName('gradient')) {
|
|
|
|
// Target is not an event -- unselect all events.
|
|
|
|
listOfSelection = $("eventsList");
|
|
|
|
deselectAll();
|
|
|
|
listOfSelection = null;
|
|
|
|
preventDefault(event);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (listOfSelection) {
|
|
|
|
listOfSelection.addClassName("_unfocused");
|
|
|
|
listOfSelection = null;
|
|
|
|
}
|
|
|
|
|
2009-08-20 20:35:55 +02:00
|
|
|
changeCalendarDisplay( { "day": currentDay } );
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
function setSelectedDayDate(dayDate) {
|
|
|
|
if (selectedDayDate != dayDate) {
|
|
|
|
var day = $("day" + selectedDayDate);
|
|
|
|
if (day)
|
|
|
|
day.removeClassName("selectedDay");
|
|
|
|
var allDay = $("allDay" + selectedDayDate);
|
|
|
|
if (allDay)
|
|
|
|
allDay.removeClassName("selectedDay");
|
2009-07-19 18:41:42 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
selectedDayDate = dayDate;
|
|
|
|
|
|
|
|
day = $("day" + selectedDayDate);
|
|
|
|
day.addClassName("selectedDay");
|
|
|
|
selectedDayNumber = day.readAttribute("day-number");
|
|
|
|
allDay = $("allDay" + selectedDayDate);
|
|
|
|
if (allDay)
|
|
|
|
allDay.addClassName("selectedDay");
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
2006-10-31 23:59:57 +01:00
|
|
|
}
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
/* after loading a new view, to reselect the currently selected day */
|
|
|
|
function restoreSelectedDay() {
|
|
|
|
var day = null;
|
|
|
|
if (selectedDayDate.length > 0)
|
|
|
|
day = $("day" + selectedDayDate);
|
|
|
|
if (!day) {
|
|
|
|
if (selectedDayNumber > -1)
|
|
|
|
selectedDayDate = findDateFromDayNumber(selectedDayNumber);
|
2009-07-19 18:41:42 +02:00
|
|
|
else
|
2010-02-13 00:24:24 +01:00
|
|
|
selectedDayDate = currentDay;
|
|
|
|
if (selectedDayDate.length > 0)
|
|
|
|
day = $("day" + selectedDayDate);
|
|
|
|
}
|
|
|
|
if (day) {
|
|
|
|
selectedDayDate = null;
|
|
|
|
setSelectedDayDate(day.id.substr(3));
|
2008-01-24 22:36:51 +01:00
|
|
|
}
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
function findDateFromDayNumber(dayNumber) {
|
|
|
|
var view;
|
|
|
|
if (currentView == "monthview")
|
|
|
|
view = $("monthDaysView");
|
|
|
|
else
|
|
|
|
view = $("daysView");
|
|
|
|
var days = view.select(".day");
|
|
|
|
return days[dayNumber].readAttribute("day");
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function onShowCompletedTasks(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
showCompletedTasks = (this.checked ? 1 : 0);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2009-08-17 22:07:54 +02:00
|
|
|
return refreshTasks(1);
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2007-06-06 23:09:39 +02:00
|
|
|
function updateTaskStatus(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var newStatus = (this.checked ? 1 : 0);
|
|
|
|
|
|
|
|
if (isSafari() && !isSafari3()) {
|
|
|
|
newStatus = (newStatus ? 0 : 1);
|
|
|
|
}
|
2009-08-25 19:34:37 +02:00
|
|
|
_updateTaskCompletion (this.parentNode, newStatus);
|
2009-07-19 18:41:42 +02:00
|
|
|
return false;
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function updateCalendarStatus(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var list = [];
|
|
|
|
var newStatus = (this.checked ? 1 : 0);
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (isSafari() && !isSafari3()) {
|
|
|
|
newStatus = (newStatus ? 0 : 1);
|
|
|
|
this.checked = newStatus;
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var nodes = $("calendarList").childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var input = $(nodes[i]).childNodesWithTag("input")[0];
|
|
|
|
if (input.checked) {
|
|
|
|
var folderId = nodes[i].getAttribute("id");
|
|
|
|
var elems = folderId.split(":");
|
|
|
|
if (elems.length > 1)
|
|
|
|
list.push(elems[0]);
|
|
|
|
else
|
|
|
|
list.push(UserLogin);
|
|
|
|
}
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// if (!list.length) {
|
|
|
|
// list.push(UserLogin);
|
|
|
|
// nodes[0].childNodesWithTag("input")[0].checked = true;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
|
|
|
|
// + list.join(",") + "/Calendar/");
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
var folderID = this.parentNode.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID);
|
|
|
|
if (newStatus)
|
|
|
|
urlstr += "/activateFolder";
|
|
|
|
else
|
|
|
|
urlstr += "/deactivateFolder";
|
|
|
|
//log("updateCalendarStatus: ajax request = " + urlstr + ", folderID = " + folderID);
|
|
|
|
triggerAjaxRequest(urlstr, calendarStatusCallback, folderID);
|
2007-10-02 17:29:16 +02:00
|
|
|
}
|
|
|
|
else {
|
2009-07-19 18:41:42 +02:00
|
|
|
updateCalendarsList();
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
2007-10-02 17:29:16 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
|
|
|
|
return false;
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
function calendarStatusCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var folder = $(http.callbackData);
|
|
|
|
var input = folder.childNodesWithTag("input")[0];
|
|
|
|
input.checked = (!input.checked);
|
|
|
|
}
|
|
|
|
}
|
2008-01-24 22:36:51 +01:00
|
|
|
else
|
2009-07-19 18:41:42 +02:00
|
|
|
log("calendarStatusCallback Ajax error");
|
|
|
|
}
|
|
|
|
|
|
|
|
function calendarEntryCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
var denied = !isHttpStatus204(http.status);
|
|
|
|
var entry = $(http.callbackData);
|
|
|
|
if (denied)
|
|
|
|
entry.addClassName("denied");
|
|
|
|
else
|
|
|
|
entry.removeClassName("denied");
|
|
|
|
}
|
2006-12-20 17:45:52 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function updateCalendarsList(method) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var list = $("calendarList").childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var folderID = list[i].getAttribute("id");
|
|
|
|
var url = URLForFolderID(folderID) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folderID);
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
//function validateBrowseURL(input) {
|
|
|
|
// var button = $("browseURLBtn");
|
|
|
|
//
|
|
|
|
// if (input.value.length) {
|
|
|
|
// if (!button.enabled)
|
|
|
|
// enableAnchor(button);
|
|
|
|
// } else if (!button.disabled)
|
|
|
|
// disableAnchor(button);
|
|
|
|
//}
|
|
|
|
|
|
|
|
//function browseURL(anchor, event) {
|
|
|
|
// if (event.button == 0) {
|
|
|
|
// var input = $("url");
|
|
|
|
// var url = input.value;
|
|
|
|
// if (url.length)
|
|
|
|
// window.open(url, '_blank');
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return false;
|
|
|
|
//}
|
2006-11-09 23:55:04 +01:00
|
|
|
|
2007-11-19 23:19:17 +01:00
|
|
|
function onCalendarsMenuPrepareVisibility() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var folders = $("calendarList");
|
2010-02-11 03:36:43 +01:00
|
|
|
var selected = folders.getSelectedNodes();
|
2009-07-19 18:41:42 +02:00
|
|
|
if (selected.length > 0) {
|
|
|
|
var folderOwner = selected[0].getAttribute("owner");
|
2010-06-08 15:38:32 +02:00
|
|
|
|
|
|
|
var lis = $(this).down("ul").childElements();
|
|
|
|
|
|
|
|
/* distance: sharing = length - 1, export = length - 7 */
|
|
|
|
var endDists = [ 1, 7 ];
|
|
|
|
for (var i = 0; i < endDists.length; i++) {
|
|
|
|
var dist = lis.length - endDists[i];
|
|
|
|
var option = $(lis[dist]);
|
|
|
|
if (folderOwner == UserLogin || IsSuperUser)
|
|
|
|
option.removeClassName("disabled");
|
|
|
|
else
|
|
|
|
option.addClassName("disabled");
|
|
|
|
}
|
|
|
|
|
2010-03-31 00:01:15 +02:00
|
|
|
var deleteCalendarOption = $("deleteCalendarMenuItem");
|
|
|
|
// Swith between Delete and Unsubscribe
|
|
|
|
if (folderOwner == UserLogin)
|
2010-06-02 21:11:15 +02:00
|
|
|
deleteCalendarOption.update(_("Delete Calendar"));
|
2010-03-31 00:01:15 +02:00
|
|
|
else
|
2010-06-02 21:11:15 +02:00
|
|
|
deleteCalendarOption.update(_("Unsubscribe Calendar"));
|
2010-03-31 00:01:15 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2007-11-19 23:19:17 +01:00
|
|
|
}
|
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
function onMenuCurrentViewPrepareVisibility() {
|
|
|
|
var options = $(this).down("ul");
|
|
|
|
var deleteOption = options.down("li", 6);
|
|
|
|
var copyOption = options.down("li", 7);
|
|
|
|
if (!selectedCalendarCell) {
|
|
|
|
deleteOption.addClassName("disabled");
|
|
|
|
copyOption.addClassName("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
deleteOption.removeClassName("disabled");
|
|
|
|
var calendarEntry = $("/" + selectedCalendarCell[0].calendar);
|
|
|
|
if (calendarEntry.getAttribute("owner") == UserLogin)
|
|
|
|
copyOption.addClassName("disabled");
|
|
|
|
else
|
|
|
|
copyOption.removeClassName("disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var menus = {};
|
2007-05-28 21:19:17 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var dateMenu = [];
|
|
|
|
for (var i = 0; i < 12; i++)
|
|
|
|
dateMenu.push(onMonthMenuItemClick);
|
|
|
|
menus["monthListMenu"] = dateMenu;
|
2007-05-22 16:38:54 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
dateMenu = [];
|
|
|
|
for (var i = 0; i < 11; i++)
|
|
|
|
dateMenu.push(onYearMenuItemClick);
|
|
|
|
menus["yearListMenu"] = dateMenu;
|
2007-05-22 16:38:54 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
menus["eventsListMenu"] = new Array(onMenuNewEventClick, "-",
|
|
|
|
onMenuNewTaskClick,
|
|
|
|
editEvent, deleteEvent, "-",
|
|
|
|
onSelectAll, "-",
|
|
|
|
null, null);
|
|
|
|
menus["calendarsMenu"] = new Array(onCalendarModify,
|
|
|
|
"-",
|
|
|
|
onCalendarNew, onCalendarRemove,
|
2009-09-02 21:14:15 +02:00
|
|
|
"-", onCalendarExport, onCalendarImport,
|
|
|
|
null, "-", null, "-", onMenuSharing);
|
2009-07-19 18:41:42 +02:00
|
|
|
menus["searchMenu"] = new Array(setSearchCriteria);
|
2007-05-22 16:38:54 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
menus["tasksListMenu"] = new Array (editEvent, newTask, "-",
|
2009-08-25 19:34:37 +02:00
|
|
|
marksTasksAsCompleted, deleteEvent);
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var calendarsMenu = $("calendarsMenu");
|
|
|
|
if (calendarsMenu)
|
|
|
|
calendarsMenu.prepareVisibility = onCalendarsMenuPrepareVisibility;
|
2007-11-19 23:19:17 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return menus;
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2009-08-25 19:34:37 +02:00
|
|
|
function newTask () {
|
2010-02-11 03:36:43 +01:00
|
|
|
return newEventFromWidget(this, 'task');
|
2009-08-25 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function marksTasksAsCompleted () {
|
|
|
|
var selectedTasks = $$("UL#tasksList LI._selected");
|
|
|
|
|
|
|
|
for (var i = 0; i < selectedTasks.length; i++) {
|
|
|
|
var task = selectedTasks[i];
|
|
|
|
_updateTaskCompletion (task, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _updateTaskCompletion (task, value) {
|
|
|
|
url = (ApplicationBaseURL + task.calendar
|
|
|
|
+ "/" + task.cname + "/changeStatus?status=" + value);
|
|
|
|
|
|
|
|
triggerAjaxRequest(url, refreshTasks, null);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-05-19 03:12:23 +02:00
|
|
|
function onMenuSharing(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if ($(this).hasClassName("disabled"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
var folders = $("calendarList");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
|
|
|
/* FIXME: activation of the context menu should preferably select the entry
|
|
|
|
above which the event has occured */
|
|
|
|
if (selected) {
|
|
|
|
var folderID = selected.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/acls";
|
|
|
|
|
|
|
|
openAclWindow(urlstr);
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2009-07-28 22:09:24 +02:00
|
|
|
function onMenuCurrentView(event) {
|
2010-02-16 14:32:02 +01:00
|
|
|
$("eventDialog").hide();
|
2010-08-26 16:14:10 +02:00
|
|
|
if (this.hasClassName('event')) {
|
|
|
|
var onClick = onCalendarSelectEvent.bind(this);
|
2010-10-08 18:08:10 +02:00
|
|
|
onClick(event, true);
|
2010-08-26 16:14:10 +02:00
|
|
|
}
|
2009-07-28 22:09:24 +02:00
|
|
|
popupMenu(event, 'currentViewMenu', this);
|
|
|
|
}
|
|
|
|
|
2010-03-31 22:21:49 +02:00
|
|
|
function onMenuAllDayView(event) {
|
|
|
|
$("eventDialog").hide();
|
|
|
|
popupMenu(event, 'allDayViewMenu', this);
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureDragHandles() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.leftBlock = $("leftPanel");
|
|
|
|
handle.rightBlock = $("rightPanel");
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.upperBlock = $("eventsListView");
|
|
|
|
handle.lowerBlock = $("calendarView");
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function initCalendarSelector() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var selector = $("calendarSelector");
|
2009-07-28 22:09:24 +02:00
|
|
|
updateCalendarStatus(); // triggers the initial events refresh
|
2009-07-19 18:41:42 +02:00
|
|
|
selector.changeNotification = updateCalendarsList;
|
|
|
|
|
|
|
|
var list = $("calendarList");
|
|
|
|
list.multiselect = true;
|
|
|
|
var items = list.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
var input = items[i].childNodesWithTag("input")[0];
|
|
|
|
$(input).observe("click", updateCalendarStatus);
|
|
|
|
items[i].observe("mousedown", listRowMouseDownHandler);
|
|
|
|
items[i].observe("selectstart", listRowMouseDownHandler);
|
|
|
|
items[i].observe("click", onRowClick);
|
|
|
|
items[i].observe("dblclick", onCalendarModify);
|
|
|
|
}
|
|
|
|
|
|
|
|
var links = $("calendarSelectorButtons").childNodesWithTag("a");
|
|
|
|
$(links[0]).observe("click", onCalendarNew);
|
2009-09-10 19:26:57 +02:00
|
|
|
$(links[1]).observe("click", onCalendarWebAdd);
|
|
|
|
$(links[2]).observe("click", onCalendarAdd);
|
|
|
|
$(links[3]).observe("click", onCalendarRemove);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2008-04-15 21:48:48 +02:00
|
|
|
function onCalendarModify(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var folders = $("calendarList");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
|
|
|
var calendarID = selected.getAttribute("id");
|
2010-07-05 17:58:18 +02:00
|
|
|
var owner = selected.getAttribute("owner");
|
2009-07-19 18:41:42 +02:00
|
|
|
var url = ApplicationBaseURL + calendarID + "/properties";
|
|
|
|
var windowID = sanitizeWindowName(calendarID + " properties");
|
2009-09-23 20:45:16 +02:00
|
|
|
var width = 310;
|
2010-07-05 17:58:18 +02:00
|
|
|
var height = 294;
|
2010-01-15 00:19:19 +01:00
|
|
|
var isWebCalendar = false;
|
2010-02-11 03:36:43 +01:00
|
|
|
if (UserSettings['Calendar']
|
2009-09-23 20:45:16 +02:00
|
|
|
&& UserSettings['Calendar']['WebCalendars']) {
|
|
|
|
var webCalendars = UserSettings['Calendar']['WebCalendars'];
|
2010-07-05 17:58:18 +02:00
|
|
|
var realID = owner + ":Calendar/" + calendarID.substr (1, calendarID.length - 1);
|
2010-01-19 13:28:10 +01:00
|
|
|
if (webCalendars[realID]) {
|
2010-01-15 00:19:19 +01:00
|
|
|
isWebCalendar = true;
|
2010-01-19 13:28:10 +01:00
|
|
|
}
|
2009-09-23 20:45:16 +02:00
|
|
|
}
|
2010-07-05 17:58:18 +02:00
|
|
|
if (Prototype.Browser.IE) height += 10;
|
|
|
|
|
2010-05-06 21:30:14 +02:00
|
|
|
if (owner == UserLogin) {
|
2010-06-08 15:44:02 +02:00
|
|
|
height += 20;
|
2010-05-06 21:30:14 +02:00
|
|
|
}
|
2010-06-05 06:46:12 +02:00
|
|
|
if (isWebCalendar) {
|
2010-07-05 17:58:18 +02:00
|
|
|
height += 26;
|
2010-06-05 06:46:12 +02:00
|
|
|
}
|
|
|
|
else if (calendarID == "/personal") {
|
2010-04-19 23:30:25 +02:00
|
|
|
height -= 26;
|
2010-06-05 06:46:12 +02:00
|
|
|
}
|
2009-09-23 20:45:16 +02:00
|
|
|
|
|
|
|
var properties = window.open(url, windowID,
|
|
|
|
"width="+width+",height="+height+",resizable=0");
|
2009-07-19 18:41:42 +02:00
|
|
|
properties.focus();
|
2007-09-15 04:31:34 +02:00
|
|
|
}
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
function updateCalendarProperties(calendarID, calendarName, calendarColor) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var idParts = calendarID.split(":");
|
|
|
|
var folderName = idParts[1].split("/")[1];
|
|
|
|
var nodeID;
|
|
|
|
|
|
|
|
if (idParts[0] != UserLogin)
|
|
|
|
nodeID = "/" + idParts[0].asCSSIdentifier() + "_" + folderName;
|
2010-03-10 22:53:26 +01:00
|
|
|
else
|
2009-07-19 18:41:42 +02:00
|
|
|
nodeID = "/" + folderName;
|
2008-08-28 16:48:45 +02:00
|
|
|
// log("nodeID: " + nodeID);
|
2010-03-10 22:53:26 +01:00
|
|
|
var calendarNode = $(nodeID);
|
|
|
|
var childNodes = calendarNode.childNodes;
|
|
|
|
childNodes[childNodes.length-1].nodeValue = calendarName;
|
2008-04-22 01:03:48 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
appendStyleElement(nodeID, calendarColor);
|
2007-09-15 04:31:34 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function onCalendarNew(event) {
|
2010-08-19 16:19:24 +02:00
|
|
|
showPromptDialog(_("New Calendar..."), _("Name of the Calendar"), onCalendarNewConfirm);
|
2009-07-19 18:41:42 +02:00
|
|
|
preventDefault(event);
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
|
2010-08-19 16:19:24 +02:00
|
|
|
function onCalendarNewConfirm() {
|
|
|
|
createFolder(this.value, appendCalendar);
|
|
|
|
disposeDialog();
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
function onCalendarAdd(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
openUserFolderSelector(onFolderSubscribeCB, "calendar");
|
|
|
|
preventDefault(event);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
2009-09-10 19:26:57 +02:00
|
|
|
|
|
|
|
function onCalendarWebAdd(event) {
|
2010-08-19 16:19:24 +02:00
|
|
|
showPromptDialog(_("Subscribe to a web calendar..."), _("URL of the Calendar"), onCalendarWebAddConfirm);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarWebAddConfirm() {
|
|
|
|
var calendarUrl = this.value;
|
2009-09-10 19:26:57 +02:00
|
|
|
if (calendarUrl) {
|
|
|
|
if (document.addWebCalendarRequest) {
|
|
|
|
document.addWebCalendarRequest.aborted = true;
|
|
|
|
document.addWebCalendarRequest.abort ();
|
|
|
|
}
|
|
|
|
var url = ApplicationBaseURL + "/addWebCalendar?url=" + escape (calendarUrl);
|
2010-02-11 03:36:43 +01:00
|
|
|
document.addWebCalendarRequest =
|
2009-09-10 19:26:57 +02:00
|
|
|
triggerAjaxRequest (url, addWebCalendarCallback);
|
|
|
|
}
|
2010-08-19 16:19:24 +02:00
|
|
|
disposeDialog();
|
2009-09-10 19:26:57 +02:00
|
|
|
}
|
|
|
|
function addWebCalendarCallback (http) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
2009-09-28 03:05:10 +02:00
|
|
|
if (data.imported >= 0) {
|
2009-09-10 19:49:07 +02:00
|
|
|
appendCalendar(data.displayname, "/" + data.name);
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
else {
|
2010-08-19 16:19:24 +02:00
|
|
|
showAlertDialog (_("An error occured while importing calendar."));
|
2009-09-10 19:49:07 +02:00
|
|
|
}
|
2009-09-10 19:26:57 +02:00
|
|
|
}
|
|
|
|
|
2009-09-02 15:24:02 +02:00
|
|
|
function onCalendarExport(event) {
|
|
|
|
var node = $("calendarList").getSelectedNodes().first();
|
|
|
|
var folderId = node.getAttribute("id");
|
2010-06-08 15:38:32 +02:00
|
|
|
var url = URLForFolderID(folderId) + ".ics/export";
|
|
|
|
window.location.href = url;
|
2009-09-02 15:24:02 +02:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
|
2009-09-02 21:14:15 +02:00
|
|
|
function onCalendarImport(event) {
|
2010-04-12 19:51:59 +02:00
|
|
|
var list = $("calendarList");
|
|
|
|
var node = list.getSelectedNodes().first();
|
2009-09-02 21:14:15 +02:00
|
|
|
var folderId = node.getAttribute("id");
|
|
|
|
|
|
|
|
var url = ApplicationBaseURL + folderId + "/import";
|
|
|
|
$("uploadForm").action = url;
|
|
|
|
$("calendarFile").value = "";
|
|
|
|
|
|
|
|
var cellPosition = node.cumulativeOffset();
|
|
|
|
var cellDimensions = node.getDimensions();
|
|
|
|
var left = cellDimensions['width'] - 20;
|
|
|
|
var top = cellPosition[1];
|
2010-04-12 19:51:59 +02:00
|
|
|
top -= list.scrollTop;
|
2009-09-02 21:14:15 +02:00
|
|
|
|
|
|
|
var div = $("uploadDialog");
|
2009-09-03 19:53:38 +02:00
|
|
|
var res = $("uploadResults");
|
2009-11-04 23:13:20 +01:00
|
|
|
res.setStyle({ top: top + "px", left: left + "px" });
|
|
|
|
div.setStyle({ top: top + "px", left: left + "px" });
|
|
|
|
div.show();
|
2009-09-02 21:14:15 +02:00
|
|
|
}
|
2009-11-04 23:13:20 +01:00
|
|
|
function hideCalendarImport(event) {
|
|
|
|
$("uploadDialog").hide();
|
2009-09-02 21:14:15 +02:00
|
|
|
}
|
2009-11-04 23:13:20 +01:00
|
|
|
function hideImportResults(event) {
|
|
|
|
$("uploadResults").hide();
|
2009-09-03 19:53:38 +02:00
|
|
|
}
|
2009-11-04 23:13:20 +01:00
|
|
|
function validateUploadForm() {
|
2009-09-02 21:14:15 +02:00
|
|
|
rc = false;
|
|
|
|
if ($("calendarFile").value.length)
|
|
|
|
rc = true;
|
|
|
|
return rc;
|
|
|
|
}
|
2009-10-28 18:48:22 +01:00
|
|
|
function uploadCompleted(response) {
|
|
|
|
data = response.evalJSON(true);
|
2009-09-03 19:53:38 +02:00
|
|
|
|
|
|
|
var div = $("uploadResults");
|
2009-09-28 17:06:54 +02:00
|
|
|
if (data.imported < 0)
|
2010-06-02 21:11:15 +02:00
|
|
|
$("uploadResultsContent").update(_("An error occured while importing calendar."));
|
2009-10-28 18:48:22 +01:00
|
|
|
else if (data.imported == 0)
|
2010-06-02 21:11:15 +02:00
|
|
|
$("uploadResultsContent").update(_("No event was imported."));
|
2009-09-03 20:37:08 +02:00
|
|
|
else {
|
2010-06-02 21:11:15 +02:00
|
|
|
$("uploadResultsContent").update(_("A total of %{0} events were imported in the calendar.").formatted(data.imported));
|
2009-10-28 18:48:22 +01:00
|
|
|
refreshEventsAndDisplay();
|
2009-09-03 20:37:08 +02:00
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
hideCalendarImport();
|
|
|
|
$("uploadResults").show();
|
2009-09-03 19:53:38 +02:00
|
|
|
}
|
2009-09-02 21:14:15 +02:00
|
|
|
|
2008-04-15 21:48:48 +02:00
|
|
|
function setEventsOnCalendar(checkBox, li) {
|
2009-07-19 18:41:42 +02:00
|
|
|
li.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
li.observe("selectstart", listRowMouseDownHandler);
|
|
|
|
li.observe("click", onRowClick);
|
|
|
|
li.observe("dblclick", onCalendarModify);
|
|
|
|
checkBox.observe("click", updateCalendarStatus);
|
2008-04-15 21:48:48 +02:00
|
|
|
}
|
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
function appendCalendar(folderName, folderPath) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var owner;
|
|
|
|
|
|
|
|
if (folderPath) {
|
|
|
|
owner = getSubscribedFolderOwner(folderPath);
|
|
|
|
folderPath = accessToSubscribedFolder(folderPath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
folderPath = "/" + folderName;
|
|
|
|
|
|
|
|
if (!owner)
|
|
|
|
owner = UserLogin;
|
|
|
|
|
|
|
|
//log ("append name: " + folderName + "; path: " + folderPath + "; owner: " + owner);
|
|
|
|
|
|
|
|
if ($(folderPath))
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("You have already subscribed to that folder!"));
|
2009-07-19 18:41:42 +02:00
|
|
|
else {
|
|
|
|
var calendarList = $("calendarList");
|
|
|
|
var items = calendarList.select("li");
|
|
|
|
var li = document.createElement("li");
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// Add the calendar to the proper place
|
|
|
|
var i = getListIndexForFolder(items, owner, folderName);
|
|
|
|
if (i != items.length) // User is subscribed to other calendars of the same owner
|
|
|
|
calendarList.insertBefore(li, items[i]);
|
2010-02-11 03:36:43 +01:00
|
|
|
else
|
2009-07-19 18:41:42 +02:00
|
|
|
calendarList.appendChild(li);
|
|
|
|
$(li).writeAttribute("id", folderPath);
|
|
|
|
$(li).writeAttribute("owner", owner);
|
|
|
|
|
|
|
|
var checkBox = createElement("input", null, "checkBox", { checked: 1 },
|
|
|
|
{ type: "checkbox" }, li);
|
|
|
|
|
|
|
|
li.appendChild(document.createTextNode(" "));
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var colorBox = document.createElement("div");
|
|
|
|
li.appendChild(colorBox);
|
|
|
|
li.appendChild(document.createTextNode(folderName
|
|
|
|
.replace("<", "<", "g")
|
|
|
|
.replace(">", ">", "g")));
|
|
|
|
colorBox.appendChild(document.createTextNode("OO"));
|
|
|
|
|
|
|
|
$(colorBox).addClassName("colorBox");
|
|
|
|
$(colorBox).addClassName('calendarFolder' + folderPath.substr(1));
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// Check the checkbox (required for IE)
|
|
|
|
li.getElementsByTagName("input")[0].checked = true;
|
2009-06-02 21:45:07 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// Register events (doesn't work with Safari)
|
|
|
|
setEventsOnCalendar($(checkBox), $(li));
|
2007-10-02 17:29:16 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var url = URLForFolderID(folderPath) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folderPath);
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// Update CSS for events color
|
|
|
|
appendStyleElement(folderPath, "#AAAAAA");
|
|
|
|
}
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function appendStyleElement(folderPath, color) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (document.styleSheets) {
|
|
|
|
var fgColor = getContrastingTextColor(color);
|
|
|
|
var styleElement = document.createElement("style");
|
|
|
|
styleElement.type = "text/css";
|
|
|
|
var selectors = [
|
|
|
|
'DIV.calendarFolder' + folderPath.substr(1),
|
|
|
|
'LI.calendarFolder' + folderPath.substr(1),
|
|
|
|
'UL#calendarList DIV.calendarFolder' + folderPath.substr(1)
|
|
|
|
];
|
|
|
|
var rules = [
|
|
|
|
' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }',
|
|
|
|
' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }',
|
|
|
|
' { color: ' + color + ' !important; }'
|
|
|
|
];
|
|
|
|
for (var i = 0; i < rules.length; i++)
|
|
|
|
if (styleElement.styleSheet && styleElement.styleSheet.addRule)
|
|
|
|
styleElement.styleSheet.addRule(selectors[i], rules[i]); // IE
|
|
|
|
else
|
|
|
|
styleElement.appendChild(document.createTextNode(selectors[i] + rules[i])); // Mozilla + Safari
|
|
|
|
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderSubscribeCB(folderData) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var folder = $(folderData["folder"]);
|
|
|
|
if (!folder) {
|
|
|
|
appendCalendar(folderData["folderName"], folderData["folder"]);
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
2009-11-29 05:19:32 +01:00
|
|
|
changeCalendarDisplay();
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderUnsubscribeCB(folderId) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var node = $(folderId);
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
if (removeFolderRequestCount == 0) {
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarRemove(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (removeFolderRequestCount == 0) {
|
|
|
|
var nodes = $("calendarList").getSelectedNodes();
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
nodes[i].deselect();
|
|
|
|
var owner = nodes[i].getAttribute("owner");
|
|
|
|
var folderId = nodes[i].getAttribute("id");
|
|
|
|
if (owner == UserLogin) {
|
|
|
|
if (folderId == "/personal") {
|
|
|
|
var label = labels["You cannot remove nor unsubscribe from your"
|
|
|
|
+ " personal calendar."];
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(label);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
var folderIdElements = folderId.split(":");
|
|
|
|
deletePersonalCalendar(folderIdElements[0]);
|
|
|
|
}
|
|
|
|
}
|
2009-09-04 21:08:21 +02:00
|
|
|
else {
|
|
|
|
var folderUrl = ApplicationBaseURL + folderId;
|
|
|
|
unsubscribeFromFolder(folderUrl, owner,
|
2009-07-19 18:41:42 +02:00
|
|
|
onFolderUnsubscribeCB, folderId);
|
2009-09-04 21:08:21 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
preventDefault(event);
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-10-24 17:52:08 +02:00
|
|
|
function deletePersonalCalendar(folderElement) {
|
2010-08-19 23:26:31 +02:00
|
|
|
showConfirmDialog(_("Confirmation"),
|
|
|
|
_("Are you sure you want to delete the calendar \"%{0}\"?").formatted($(folderElement).lastChild.nodeValue.strip()),
|
|
|
|
deletePersonalCalendarConfirm.bind(folderElement));
|
|
|
|
}
|
|
|
|
|
|
|
|
function deletePersonalCalendarConfirm() {
|
|
|
|
var folderId = this.substr(1);
|
|
|
|
removeFolderRequestCount++;
|
|
|
|
var url = ApplicationBaseURL + "/" + folderId + "/delete";
|
|
|
|
triggerAjaxRequest(url, deletePersonalCalendarCallback, folderId);
|
|
|
|
disposeDialog();
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function deletePersonalCalendarCallback(http) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var ul = $("calendarList");
|
|
|
|
var children = ul.childNodesWithTag("li");
|
|
|
|
var i = 0;
|
|
|
|
var done = false;
|
|
|
|
while (!done && i < children.length) {
|
|
|
|
var currentFolderId = children[i].getAttribute("id").substr(1);
|
|
|
|
if (currentFolderId == http.callbackData) {
|
|
|
|
ul.removeChild(children[i]);
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
removeFolderRequestCount--;
|
|
|
|
if (removeFolderRequestCount == 0) {
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax problem 5: " + http.status);
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function configureLists() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var list = $("tasksList");
|
|
|
|
list.multiselect = true;
|
|
|
|
list.observe("mousedown", onTasksSelectionChange);
|
|
|
|
list.observe("selectstart", listRowMouseDownHandler);
|
2007-06-08 01:23:07 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var input = $("showHideCompletedTasks");
|
|
|
|
input.observe("click", onShowCompletedTasks);
|
2009-08-17 22:07:54 +02:00
|
|
|
if (showCompletedTasks)
|
|
|
|
input.checked = true;
|
2007-06-08 01:23:07 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
list = $("eventsList");
|
|
|
|
list.multiselect = true;
|
|
|
|
configureSortableTableHeaders(list);
|
|
|
|
TableKit.Resizable.init(list, {'trueResize' : true, 'keepWidth' : true});
|
|
|
|
list.observe("mousedown", onEventsSelectionChange);
|
2007-06-08 01:23:07 +02:00
|
|
|
}
|
|
|
|
|
2007-07-05 21:13:59 +02:00
|
|
|
function initDateSelectorEvents() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var arrow = $("rightArrow");
|
|
|
|
arrow.observe("click", onDateSelectorGotoMonth);
|
|
|
|
arrow = $("leftArrow");
|
|
|
|
arrow.observe("click", onDateSelectorGotoMonth);
|
2008-07-16 04:12:18 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var menuButton = $("monthLabel");
|
|
|
|
menuButton.observe("click", popupMonthMenu);
|
|
|
|
menuButton = $("yearLabel");
|
|
|
|
menuButton.observe("click", popupMonthMenu);
|
2007-07-05 21:13:59 +02:00
|
|
|
}
|
|
|
|
|
2008-08-19 00:45:59 +02:00
|
|
|
function onBodyClickHandler(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
$("eventDialog").hide();
|
2008-08-19 00:45:59 +02:00
|
|
|
}
|
|
|
|
|
2008-09-18 20:03:59 +02:00
|
|
|
function onWindowResize(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle)
|
|
|
|
handle.adjust();
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle)
|
|
|
|
handle.adjust();
|
|
|
|
|
2009-07-29 19:54:48 +02:00
|
|
|
if (!$(document.body).hasClassName("popup"))
|
|
|
|
drawNowLine ();
|
2009-07-23 15:57:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function drawNowLine () {
|
|
|
|
var d = new Date();
|
|
|
|
var hours = d.getHours();
|
|
|
|
var minutes = d.getMinutes();
|
2009-07-29 16:47:14 +02:00
|
|
|
|
|
|
|
if (currentView == "dayview") {
|
2009-07-29 15:43:47 +02:00
|
|
|
var today = new Date ();
|
|
|
|
var m = parseInt(today.getMonth ()) + 1;
|
|
|
|
var d = today.getDate ();
|
|
|
|
if (m < 10)
|
|
|
|
m = "0" + m;
|
|
|
|
if (d < 10)
|
|
|
|
d = "0" + d;
|
|
|
|
var day = today.getFullYear () + "" + m + "" + d;
|
2010-02-11 03:36:43 +01:00
|
|
|
var targets = $$("DIV#daysView DIV.days DIV.day[day=" + day
|
2009-07-29 15:43:47 +02:00
|
|
|
+ "] DIV.events DIV.clickableHourCell");
|
|
|
|
}
|
2009-07-29 16:47:14 +02:00
|
|
|
else if (currentView == "weekview")
|
2009-07-23 15:57:35 +02:00
|
|
|
var targets = $$("DIV#daysView DIV.days DIV.dayOfToday DIV.events DIV.clickableHourCell");
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-29 15:43:47 +02:00
|
|
|
if (targets) {
|
|
|
|
var target = targets[hours];
|
2009-07-23 15:57:35 +02:00
|
|
|
|
2009-07-29 15:43:47 +02:00
|
|
|
if (target) {
|
|
|
|
var div = $("nowLineDisplay");
|
|
|
|
if (!div)
|
|
|
|
div = new Element ("div", {'id': 'nowLineDisplay'});
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-29 15:43:47 +02:00
|
|
|
div.style.top = parseInt (((minutes * target.offsetHeight) / 60) - 1) + "px";
|
|
|
|
target.appendChild (div);
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2009-07-29 15:43:47 +02:00
|
|
|
setTimeout ("drawNowLine ();", 60000); // 1 min.
|
|
|
|
}
|
2009-07-23 15:57:35 +02:00
|
|
|
}
|
2008-09-18 20:03:59 +02:00
|
|
|
}
|
|
|
|
|
2010-04-14 21:07:59 +02:00
|
|
|
function onDocumentKeydown(event) {
|
|
|
|
var target = Event.element(event);
|
|
|
|
if (target.tagName != "INPUT") {
|
2010-10-08 22:57:24 +02:00
|
|
|
var keyCode = event.keyCode;
|
|
|
|
if (!keyCode) {
|
|
|
|
keyCode = event.charCode;
|
|
|
|
if (keyCode == "a".charCodeAt(0))
|
|
|
|
keyCode = "A".charCodeAt(0);
|
|
|
|
else if (keyCode == "c".charCodeAt(0))
|
|
|
|
keyCode = "C".charCodeAt(0);
|
|
|
|
else if (keyCode == "v".charCodeAt(0))
|
|
|
|
keyCode = "V".charCodeAt(0);
|
|
|
|
}
|
|
|
|
if (keyCode == Event.KEY_DELETE
|
|
|
|
|| (keyCode == Event.KEY_BACKSPACE && isMac())) {
|
2010-04-16 00:19:28 +02:00
|
|
|
$("eventDialog").hide();
|
2010-04-14 21:07:59 +02:00
|
|
|
deleteEvent();
|
2010-04-16 00:19:28 +02:00
|
|
|
event.stop();
|
2010-04-14 21:07:59 +02:00
|
|
|
}
|
2010-08-26 19:21:41 +02:00
|
|
|
else if (((isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1))
|
2010-10-08 22:57:24 +02:00
|
|
|
&& keyCode == "A".charCodeAt(0)) { // Ctrl-A
|
2010-07-30 22:10:00 +02:00
|
|
|
onSelectAll(event);
|
|
|
|
Event.stop(event);
|
|
|
|
}
|
2010-08-26 16:14:10 +02:00
|
|
|
else if (((isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1))
|
2010-10-08 22:57:24 +02:00
|
|
|
&& keyCode == "C".charCodeAt(0)) { // Ctrl-C
|
2010-08-26 16:14:10 +02:00
|
|
|
copyEventToClipboard();
|
|
|
|
}
|
|
|
|
else if (((isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1))
|
2010-10-08 22:57:24 +02:00
|
|
|
&& keyCode == "V".charCodeAt(0)) { // Ctrl-V
|
2010-08-26 16:14:10 +02:00
|
|
|
copyEventFromClipboard();
|
|
|
|
}
|
2010-04-14 21:07:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function initCalendars() {
|
2009-07-19 18:41:42 +02:00
|
|
|
sorting["attribute"] = "start";
|
|
|
|
sorting["ascending"] = true;
|
2009-11-30 19:23:39 +01:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (!$(document.body).hasClassName("popup")) {
|
2009-07-19 18:42:04 +02:00
|
|
|
var node = $("filterpopup");
|
2009-07-19 18:51:50 +02:00
|
|
|
listFilter = node.value;
|
2010-04-12 19:51:59 +02:00
|
|
|
|
|
|
|
var tabsContainer = $("schedulerTabs");
|
|
|
|
var controller = new SOGoTabsController();
|
|
|
|
controller.attachToTabsContainer(tabsContainer);
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
initDateSelectorEvents();
|
|
|
|
initCalendarSelector();
|
|
|
|
configureSearchField();
|
2010-08-11 22:56:14 +02:00
|
|
|
showCompletedTasks = parseInt(UserSettings['ShowCompletedTasks']);
|
2009-07-19 18:41:42 +02:00
|
|
|
configureLists();
|
|
|
|
$("calendarList").attachMenu("calendarsMenu");
|
|
|
|
$(document.body).observe("click", onBodyClickHandler);
|
2009-11-04 23:13:20 +01:00
|
|
|
// Calendar import form
|
|
|
|
$("uploadCancel").observe("click", hideCalendarImport);
|
|
|
|
$("uploadOK").observe("click", hideImportResults);
|
2010-04-14 21:07:59 +02:00
|
|
|
|
2010-07-30 22:10:00 +02:00
|
|
|
Event.observe(document, "keydown", onDocumentKeydown);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onWindowResize.defer();
|
|
|
|
Event.observe(window, "resize", onWindowResize);
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", initCalendars);
|