2016-08-12 20:31:28 +02:00
|
|
|
/* -*- Mode: javascript; indent-tabs-mode: nil; js-indent-level: 4; -*- */
|
|
|
|
|
2014-05-08 23:17:05 +02:00
|
|
|
var eventListFilter = 'view_today';
|
|
|
|
var taskListFilter = '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;
|
|
|
|
|
2015-11-23 19:29:02 +01:00
|
|
|
var componentWindowHeight = 500;
|
|
|
|
var componentWindowWidth = 520;
|
|
|
|
|
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;
|
2014-07-17 15:42:32 +02:00
|
|
|
var recurrenceBool = false;
|
2010-02-12 18:23:47 +01:00
|
|
|
|
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 = [];
|
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
var refreshViewCheckTimer;
|
2014-06-20 19:16:55 +02:00
|
|
|
|
|
|
|
// This should probably go in the generic.js
|
2014-04-14 16:29:23 +02:00
|
|
|
function printView() {
|
2014-07-16 16:30:48 +02:00
|
|
|
var flag = false;
|
|
|
|
var calendarsList = $("calendarList").children;
|
|
|
|
for (var i = 0; i < calendarsList.length; i++) {
|
|
|
|
if (calendarsList[i].down("input").checked) {
|
|
|
|
flag = true;
|
|
|
|
break;
|
|
|
|
}
|
2014-06-25 23:39:48 +02:00
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
if (flag)
|
|
|
|
window.open("printView","","width=660,height=470");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
else
|
|
|
|
showAlertDialog("Please select at least one calendar");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
return false;
|
2014-04-14 16:29:23 +02:00
|
|
|
}
|
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
function newEvent(type, day, hour, duration) {
|
2011-09-23 21:25:56 +02:00
|
|
|
var folder = null;
|
|
|
|
if (UserDefaults['SOGoDefaultCalendar'] == 'personal')
|
|
|
|
folder = $("calendarList").down("li");
|
|
|
|
else if (UserDefaults['SOGoDefaultCalendar'] == 'first') {
|
|
|
|
var list = $("calendarList");
|
|
|
|
var inputs = list.select("input");
|
|
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
|
|
var input = inputs[i];
|
|
|
|
if (input.checked) {
|
|
|
|
folder = input.up();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!folder)
|
|
|
|
folder = list.down("li");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
folder = getSelectedFolder();
|
2009-07-19 18:41:42 +02:00
|
|
|
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("&");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2015-11-23 19:29:02 +01:00
|
|
|
window.open(urlstr, "", "width=" + componentWindowWidth + ",height=" + componentWindowHeight + ",resizable=0");
|
2014-07-30 16:31:25 +02: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");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-05-12 21:25:50 +02:00
|
|
|
newEvent.delay(0.1, 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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-07-09 22:47:13 +02:00
|
|
|
function updateEventFromDragging(controller, eventCells, eventDelta, calendarID) {
|
2014-07-17 15:42:32 +02:00
|
|
|
if (eventDelta.dayNumber || eventDelta.start || eventDelta.duration || calendarID != 0) {
|
2014-07-16 16:30:48 +02:00
|
|
|
if (calendarID != 0)
|
2014-07-17 15:42:32 +02:00
|
|
|
var params = ("destination=" + calendarID[1]
|
2014-07-16 16:30:48 +02:00
|
|
|
+ "&days=" + 0
|
|
|
|
+ "&start=" + eventDelta.start * 15
|
|
|
|
+ "&duration=" + eventDelta.duration * 15);
|
|
|
|
else
|
2014-07-17 15:42:32 +02:00
|
|
|
var params = ("destination=" + 0
|
2014-07-16 16:30:48 +02:00
|
|
|
+ "&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);
|
2014-07-17 15:42:32 +02:00
|
|
|
recurrenceBool = false;
|
|
|
|
if (calendarID == 0) {
|
|
|
|
recurrenceBool = true;
|
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
if (eventCell.recurrenceTime && !eventCell.isException)
|
|
|
|
_editRecurrenceDialog(eventCell, "confirmAdjustment", params);
|
|
|
|
else {
|
|
|
|
var urlstr = (ApplicationBaseURL + "/" + eventCell.calendar + "/" + eventCell.cname);
|
2014-07-17 15:42:32 +02:00
|
|
|
if (eventCell.recurrenceTime && recurrenceBool)
|
2014-07-16 16:30:48 +02:00
|
|
|
urlstr += "/occurence" + eventCell.recurrenceTime;
|
|
|
|
urlstr += ("/adjust?" + params);
|
|
|
|
// log(" urlstr: " + urlstr);
|
|
|
|
triggerAjaxRequest(urlstr, updateEventFromDraggingCallback);
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function performEventAdjustment(folder, event, recurrence, params) {
|
2014-03-04 19:23:55 +01:00
|
|
|
var urlstr = ApplicationBaseURL + "/" + folder + "/" + event;
|
2014-07-17 15:42:32 +02:00
|
|
|
if (recurrence && recurrenceBool)
|
2010-02-11 03:36:43 +01:00
|
|
|
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
|
|
|
}
|
2014-02-03 17:09:03 +01:00
|
|
|
else {
|
|
|
|
var response = http.responseText.evalJSON(true);
|
|
|
|
showAlertDialog(response['message']);
|
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-24 19:35:14 +02:00
|
|
|
function updateTaskFromDraggingCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
refreshTasks();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2014-07-30 16:31:25 +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) {
|
2014-01-28 21:36:48 +01:00
|
|
|
var target = document.menuTarget;
|
2014-05-12 21:25:50 +02:00
|
|
|
if (target) {
|
|
|
|
if (/(minutes\d{2}|dayHeader)/.test(target.className))
|
|
|
|
target = target.parentNode;
|
|
|
|
newEventFromWidget(target, "event");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newEvent('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) {
|
2014-01-28 21:36:48 +01:00
|
|
|
var target = document.menuTarget;
|
2014-05-12 21:25:50 +02:00
|
|
|
if (target) {
|
|
|
|
if (/(minutes\d{2}|dayHeader)/.test(target.className))
|
|
|
|
target = target.parentNode;
|
|
|
|
newEventFromWidget(target, "task");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newEvent('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;
|
2014-03-04 19:23:55 +01:00
|
|
|
var urlstr = ApplicationBaseURL + "/" + calendar + "/" + id;
|
2009-07-19 18:41:42 +02:00
|
|
|
if (recurrence) {
|
|
|
|
urlstr += "/" + recurrence;
|
|
|
|
targetname += recurrence;
|
|
|
|
}
|
|
|
|
urlstr += "/edit";
|
|
|
|
var win = window.open(urlstr, "_blank",
|
2015-11-23 19:29:02 +01:00
|
|
|
"width=" + componentWindowWidth + ",height=" + componentWindowHeight + ",resizable=0");
|
2009-07-19 18:41:42 +02:00
|
|
|
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();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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;
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++)
|
2014-05-12 21:25:50 +02:00
|
|
|
_editEventId.delay(0.1,
|
|
|
|
nodes[i].cname,
|
|
|
|
nodes[i].calendar);
|
2009-07-19 18:41:42 +02:00
|
|
|
} else if (selectedCalendarCell) {
|
|
|
|
if (selectedCalendarCell[0].recurrenceTime && !selectedCalendarCell[0].isException)
|
2014-05-12 21:25:50 +02:00
|
|
|
_editRecurrenceDialog.delay(0.1,
|
|
|
|
selectedCalendarCell[0],
|
|
|
|
"confirmEditing");
|
2009-07-19 18:41:42 +02:00
|
|
|
else
|
2014-05-12 21:25:50 +02:00
|
|
|
_editEventId.delay(0.1,
|
|
|
|
selectedCalendarCell[0].cname,
|
|
|
|
selectedCalendarCell[0].calendar);
|
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."));
|
2007-12-03 15:13:10 +01:00
|
|
|
}
|
2014-07-30 16:31:25 +02: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() {
|
2014-02-04 22:25:52 +01:00
|
|
|
// Delete the events of the next calendar
|
2009-07-19 18:41:42 +02:00
|
|
|
var calendar = calendarsOfEventsToDelete.shift();
|
2014-02-04 22:25:52 +01:00
|
|
|
var events = eventsToDelete.shift();
|
2014-03-04 19:23:55 +01:00
|
|
|
var urlstr = (ApplicationBaseURL + "/" + calendar
|
2014-02-04 22:25:52 +01:00
|
|
|
+ "/batchDelete?ids=" + events.join(','));
|
2009-07-19 18:41:42 +02:00
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
deleteEventCallback,
|
2014-02-04 22:25:52 +01:00
|
|
|
{ calendar: calendar, events: events });
|
2006-10-17 00:35:22 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteEvent() {
|
2014-02-04 22:25:52 +01:00
|
|
|
var label = "";
|
|
|
|
var events = [];
|
2009-07-19 18:41:42 +02:00
|
|
|
if (listOfSelection) {
|
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
|
|
|
if (nodes.length > 0) {
|
2012-09-12 10:41:52 +02:00
|
|
|
if (listOfSelection.parentNode == $("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");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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++) {
|
2010-10-13 17:02:39 +02:00
|
|
|
canDelete = nodes[i].erasable;
|
2010-08-26 16:14:10 +02:00
|
|
|
if (canDelete) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var calendar = nodes[i].calendar;
|
2014-02-04 22:25:52 +01:00
|
|
|
var cname = nodes[i].cname;
|
|
|
|
if (nodes[i].recurrenceTime) {
|
|
|
|
cname += '/occurence' + nodes[i].recurrenceTime;
|
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
if (!sortedNodes[calendar]) {
|
|
|
|
sortedNodes[calendar] = [];
|
|
|
|
calendars.push(calendar);
|
|
|
|
}
|
2014-02-04 22:25:52 +01:00
|
|
|
if (sortedNodes[calendar].indexOf(cname) < 0) {
|
|
|
|
// Build list item element for confirmation dialog
|
|
|
|
var itemElement = new Element('li');
|
|
|
|
var colorBox = new Element('div', {'class': 'colorBox calendarFolder' + nodes[i].calendar});
|
|
|
|
var content = '';
|
2012-09-07 21:46:49 +02:00
|
|
|
if (nodes[i].tagName == 'TR') {
|
|
|
|
var cell = nodes[i].down('td span');
|
2014-02-04 22:25:52 +01:00
|
|
|
content = cell.allTextContent(); // extract the first column only
|
2012-09-07 21:46:49 +02:00
|
|
|
}
|
2014-02-04 22:25:52 +01:00
|
|
|
else {
|
|
|
|
content = nodes[i].allTextContent();
|
|
|
|
}
|
|
|
|
itemElement.appendChild(colorBox);
|
2014-02-07 22:12:14 +01:00
|
|
|
itemElement.appendChild(new Element('span').update(content.escapeHTML()));
|
2014-02-04 22:25:52 +01:00
|
|
|
if (nodes[i].startDate) {
|
|
|
|
var startDate = new Date(nodes[i].startDate*1000);
|
|
|
|
var dateElement = new Element('div', {'class': 'muted'});
|
|
|
|
var date;
|
|
|
|
if (typeof nodes[i].hour == 'undefined')
|
|
|
|
date = startDate.toLocaleDateString(localeCode);
|
|
|
|
else
|
|
|
|
date = startDate.toLocaleString(localeCode);
|
|
|
|
dateElement.update(date);
|
|
|
|
itemElement.appendChild(dateElement);
|
|
|
|
}
|
|
|
|
events.push(itemElement);
|
|
|
|
sortedNodes[calendar].push(cname);
|
2011-04-21 15:33:45 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2014-02-04 22:25:52 +01:00
|
|
|
// Update global arrays
|
2010-08-26 16:14:10 +02:00
|
|
|
for (i = 0; i < calendars.length; i++) {
|
|
|
|
calendarsOfEventsToDelete.push(calendars[i]);
|
|
|
|
eventsToDelete.push(sortedNodes[calendars[i]]);
|
|
|
|
}
|
2014-02-04 22:25:52 +01:00
|
|
|
if (i == 0)
|
2010-08-26 16:14:10 +02:00
|
|
|
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 = [];
|
2014-02-04 22:25:52 +01:00
|
|
|
var cname;
|
2010-07-30 22:10:00 +02:00
|
|
|
for (var i = 0; i < selectedCalendarCell.length; i++) {
|
2010-10-13 17:02:39 +02:00
|
|
|
canDelete = selectedCalendarCell[i].erasable;
|
2010-07-30 22:10:00 +02:00
|
|
|
if (canDelete) {
|
|
|
|
var calendar = selectedCalendarCell[i].calendar;
|
2014-02-04 22:25:52 +01:00
|
|
|
var cname = selectedCalendarCell[i].cname;
|
|
|
|
if (selectedCalendarCell[i].recurrenceTime) {
|
|
|
|
cname += '/occurence' + selectedCalendarCell[i].recurrenceTime;
|
|
|
|
}
|
2010-07-30 22:10:00 +02:00
|
|
|
if (!sortedNodes[calendar]) {
|
|
|
|
sortedNodes[calendar] = [];
|
|
|
|
calendars.push(calendar);
|
|
|
|
}
|
2014-02-04 22:25:52 +01:00
|
|
|
if (sortedNodes[calendar].indexOf(cname) < 0) {
|
|
|
|
// Build list item element for confirmation dialog
|
|
|
|
var itemElement = new Element('li');
|
|
|
|
var colorBox = new Element('div', {'class': 'colorBox calendarFolder' + selectedCalendarCell[i].calendar});
|
|
|
|
var content = '';
|
2011-04-21 15:33:45 +02:00
|
|
|
var event = $(selectedCalendarCell[i]).down("DIV.text");
|
|
|
|
for (var j = 0; j < event.childNodes.length; j++) {
|
|
|
|
var node = event.childNodes[j];
|
|
|
|
if (node.nodeType == Node.TEXT_NODE) {
|
|
|
|
content += node.nodeValue;
|
|
|
|
}
|
|
|
|
}
|
2014-02-04 22:25:52 +01:00
|
|
|
itemElement.appendChild(colorBox);
|
2014-02-07 22:12:14 +01:00
|
|
|
itemElement.appendChild(new Element('span').update(content.escapeHTML()));
|
2014-02-04 22:25:52 +01:00
|
|
|
if (selectedCalendarCell[i].startDate) {
|
|
|
|
var startDate = new Date(selectedCalendarCell[i].startDate*1000);
|
|
|
|
var dateElement = new Element('div', {'class': 'muted'});
|
|
|
|
var date;
|
|
|
|
if (selectedCalendarCell[i].readAttribute('hour') == 'allday')
|
|
|
|
date = startDate.toLocaleDateString(localeCode);
|
|
|
|
else
|
|
|
|
date = startDate.toLocaleString(localeCode);
|
|
|
|
dateElement.update(date);
|
|
|
|
itemElement.appendChild(dateElement);
|
|
|
|
}
|
|
|
|
events.push(itemElement);
|
|
|
|
sortedNodes[calendar].push(cname);
|
2011-04-21 15:33:45 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2014-02-04 22:25:52 +01:00
|
|
|
// Update global arrays
|
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]]);
|
|
|
|
}
|
2014-02-04 22:25:52 +01:00
|
|
|
if (i == 0)
|
2010-08-26 16:14:10 +02:00
|
|
|
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."));
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-02-04 22:25:52 +01:00
|
|
|
if (events.length > 0) {
|
|
|
|
// Show confirmation dialog
|
|
|
|
var p = new Element('p');
|
|
|
|
p.appendChild(document.createTextNode(label));
|
|
|
|
var list = new Element('ul');
|
|
|
|
for (i = 0; i < events.length; i++) {
|
|
|
|
list.appendChild(events[i]);
|
|
|
|
}
|
|
|
|
p.appendChild(list);
|
|
|
|
p.appendChild(document.createTextNode(_("Would you like to continue?")));
|
|
|
|
showConfirmDialog(_("Warning"), p, deleteEventFromListConfirm, deleteEventCancel);
|
|
|
|
}
|
2014-07-30 16:31:25 +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() {
|
2014-07-16 16:30:48 +02:00
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
_batchDeleteEvents();
|
|
|
|
refreshTasks();
|
|
|
|
disposeDialog();
|
2010-08-26 16:14:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteEventFromViewConfirm() {
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
selectedCalendarCell = null;
|
|
|
|
_batchDeleteEvents();
|
|
|
|
disposeDialog();
|
|
|
|
}
|
|
|
|
|
2011-04-21 15:33:45 +02:00
|
|
|
function deleteEventCancel(event) {
|
2010-10-08 18:08:10 +02:00
|
|
|
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();
|
2014-03-04 19:23:55 +01:00
|
|
|
var urlstr = ApplicationBaseURL + "/" + path; log (urlstr);
|
2010-08-26 16:14:10 +02:00
|
|
|
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"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-09 16:17:07 +02:00
|
|
|
function onMenuRawEvent(event) {
|
|
|
|
if (selectedCalendarCell.length != 1) {
|
2014-07-16 16:30:48 +02:00
|
|
|
return;
|
2012-07-09 16:17:07 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-07-09 16:17:07 +02:00
|
|
|
var calendar = selectedCalendarCell[0].calendar;
|
|
|
|
var cname = selectedCalendarCell[0].cname;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = ApplicationBaseURL + "/" + calendar + "/" + cname + "/raw";
|
2014-05-12 21:25:50 +02:00
|
|
|
openGenericWindow.delay(0.1, url);
|
2012-07-09 16:17:07 +02: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");
|
2014-07-30 16:31:25 +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")));
|
2014-07-30 16:31:25 +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
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-24 20:00:49 +02:00
|
|
|
resizeCalendarHeaderDIV();
|
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];
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-01-21 21:44:17 +01:00
|
|
|
// Delete task from tasks list
|
2014-09-12 14:34:15 +02:00
|
|
|
var rows = $$("tr[id^='" + calendar + basename + "']");
|
|
|
|
rows.each(function(row) {
|
2010-01-21 21:44:17 +01:00
|
|
|
row.parentNode.removeChild(row);
|
2014-09-12 14:34:15 +02:00
|
|
|
});
|
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
|
|
|
}
|
2014-07-30 16:31:25 +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 calendar = http.callbackData.calendar;
|
|
|
|
var events = http.callbackData.events;
|
|
|
|
for (var i = 0; i < events.length; i++) {
|
2014-02-04 22:25:52 +01:00
|
|
|
var cname = /(.+)\/occurence([0-9]+)/.exec(events[i]) || [null, events[i]];
|
|
|
|
_deleteCalendarEventBlocks(calendar, cname[1], cname[2]);
|
|
|
|
_deleteEventFromTables(calendar, cname[1], cname[2]);
|
|
|
|
_deleteCalendarEventCache(calendar, cname[1], cname[2]);
|
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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (calendarEvents) {
|
|
|
|
if (!owner)
|
|
|
|
owner = UserLogin;
|
|
|
|
var userEvents = calendarEvents[owner];
|
|
|
|
if (userEvents)
|
|
|
|
event = userEvents[cname];
|
|
|
|
}
|
2014-07-30 16:31:25 +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;
|
2014-03-04 19:23:55 +01:00
|
|
|
var urlstr = (ApplicationBaseURL + "/" + eventCell.calendar + "/" + eventCell.cname
|
2010-02-11 03:36:43 +01:00
|
|
|
+ "/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;
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = ApplicationBaseURL + "/" + this.calendar + "/" + this.cname;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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) {
|
2014-07-30 16:31:25 +02:00
|
|
|
// log (key + " = " + data[key]);
|
|
|
|
// });
|
2009-07-19 18:41:42 +02:00
|
|
|
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;
|
2012-10-08 22:31:17 +02:00
|
|
|
var left;
|
2012-09-24 18:18:18 +02:00
|
|
|
var top = cellPosition[1] - 5;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (currentView != "monthview") {
|
|
|
|
view = $("daysView");
|
|
|
|
var viewPosition = view.cumulativeOffset();
|
2014-07-30 16:31:25 +02: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 {
|
|
|
|
top -= cell.up("DIV.day").scrollTop;
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2013-07-17 20:57:07 +02:00
|
|
|
left = cellPosition[0] + cellDimensions["width"] + 4;
|
2012-10-08 22:31:17 +02:00
|
|
|
if (left + divDimensions["width"] > window.width()) {
|
2013-07-17 20:57:07 +02:00
|
|
|
left = cellPosition[0] - divDimensions["width"];
|
2009-07-19 18:41:42 +02:00
|
|
|
div.removeClassName("left");
|
|
|
|
div.addClassName("right");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
div.removeClassName("right");
|
|
|
|
div.addClassName("left");
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// 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/>"));
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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]);
|
2012-01-30 20:59:05 +01:00
|
|
|
if (parseInt(data["isAllDay"]) == 0) {
|
|
|
|
para.down("SPAN").update(data["startTime"] + " - " + data["endTime"]);
|
2010-02-12 18:55:28 +01:00
|
|
|
para.show();
|
2010-01-06 23:16:24 +01:00
|
|
|
} else
|
2010-02-12 18:55:28 +01:00
|
|
|
para.hide();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-12 18:55:28 +01:00
|
|
|
para = $(paras[1]);
|
2012-01-30 20:59:05 +01:00
|
|
|
if (data["calendar"].length) {
|
2014-02-10 19:49:02 +01:00
|
|
|
para.down("SPAN", 1).update(data["calendar"]);
|
2010-02-12 18:55:28 +01:00
|
|
|
para.show();
|
2009-07-19 18:41:42 +02:00
|
|
|
} else
|
2010-02-12 18:55:28 +01:00
|
|
|
para.hide();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-12 18:55:28 +01:00
|
|
|
para = $(paras[2]);
|
2012-01-30 20:59:05 +01:00
|
|
|
if (data["location"].length) {
|
2014-02-10 19:49:02 +01:00
|
|
|
para.down("SPAN", 1).update(data["location"]);
|
2010-02-12 18:55:28 +01:00
|
|
|
para.show();
|
2009-07-19 18:41:42 +02:00
|
|
|
} else
|
2010-02-12 18:55:28 +01:00
|
|
|
para.hide();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
para = $(paras[3]);
|
2013-06-19 16:23:47 +02:00
|
|
|
if (data["created_by"].length) {
|
2014-07-16 16:30:48 +02:00
|
|
|
para.down("SPAN", 1).update(data["created_by"]);
|
2013-06-19 16:23:47 +02:00
|
|
|
para.show();
|
|
|
|
} else
|
|
|
|
para.hide();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2013-06-19 16:23:47 +02:00
|
|
|
para = $(paras[4]);
|
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();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2015-11-06 15:40:36 +01:00
|
|
|
var windowHeight = window.height();
|
|
|
|
var bottomOffset = windowHeight - div.getDimensions().height - top;
|
|
|
|
if (bottomOffset < 0)
|
|
|
|
top += bottomOffset;
|
|
|
|
|
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();
|
2014-02-11 03:49:49 +01:00
|
|
|
configureLinks(div);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
2014-07-30 16:31:25 +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);
|
2014-09-12 14:34:15 +02:00
|
|
|
//var nodes = _eventBlocksMatching(folder, event, occurenceTime);
|
2014-03-04 19:23:55 +01:00
|
|
|
var urlstr = ApplicationBaseURL + "/" + folder + "/" + event + "/" + recurrence + "/delete";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-09-12 14:34:15 +02:00
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
performDeleteEventCallback,
|
|
|
|
{ calendar: folder,
|
|
|
|
cname: event,
|
|
|
|
occurence: occurenceTime });
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
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)) {
|
2014-09-17 15:45:44 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var occurenceTime = http.callbackData.occurence;
|
2014-09-12 14:34:15 +02:00
|
|
|
var cname = http.callbackData.cname;
|
|
|
|
var calendar = http.callbackData.calendar;
|
2014-09-17 15:45:44 +02: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');
|
2014-05-08 23:17:05 +02:00
|
|
|
var needRefresh = (eventListFilter == 'view_selectedday'
|
2009-07-19 18:41:42 +02:00
|
|
|
&& day != currentDay);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var td = $(node).getParentWithTagName("td");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
// var table = $(td).getParentWithTagName("table");
|
2009-07-19 18:41:42 +02:00
|
|
|
// log ("table.selected: " + table.selected);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (document.selectedDate)
|
|
|
|
document.selectedDate.deselect();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
td.selectElement();
|
|
|
|
document.selectedDate = td;
|
2014-07-30 16:31:25 +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();
|
2014-07-30 16:31:25 +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");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay(day, true);
|
2014-07-30 16:31:25 +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");
|
2014-05-08 23:17:05 +02:00
|
|
|
var needRefresh = (eventListFilter == 'view_selectedday' && day != currentDay);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
changeCalendarDisplay( { "day": day } );
|
|
|
|
if (needRefresh)
|
|
|
|
refreshEvents();
|
2014-07-30 16:31:25 +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 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();
|
2014-07-30 16:31:25 +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");
|
2014-07-30 16:31:25 +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);
|
2014-07-30 16:31:25 +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
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-10-30 20:47:44 +01:00
|
|
|
var rows = table.select("TBODY TR");
|
|
|
|
rows.each(function(e) {
|
2014-07-30 16:31:25 +02:00
|
|
|
e.remove();
|
|
|
|
});
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
2015-06-23 15:23:29 +02:00
|
|
|
|
|
|
|
// [0] Event ID
|
|
|
|
// [1] Calendar ID
|
|
|
|
// [2] Calendar name
|
|
|
|
// [3] Status
|
|
|
|
// [4] Title
|
|
|
|
// [5] Start date
|
|
|
|
// [6] End date
|
|
|
|
// [7] Location
|
|
|
|
// [8] Is all day?
|
|
|
|
// [9] Classification (0 = public, 1, = private, 2 = confidential)
|
|
|
|
// [10] Category
|
|
|
|
// [11] Participants email addresses
|
|
|
|
// [12] Participants states
|
|
|
|
// [13] Owner
|
|
|
|
// [14] Is cyclic?
|
|
|
|
// [15] Next alarm
|
|
|
|
// [16] recurrence-id
|
|
|
|
// [17] isException
|
|
|
|
// [18] Editable?
|
|
|
|
// [19] Erasable?
|
|
|
|
// [20] Owner is organizer?
|
|
|
|
// [21] Description
|
|
|
|
// [22] Formatted start date
|
|
|
|
// [23] Formatted end date
|
|
|
|
|
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 row = createElement("tr");
|
2009-07-19 18:41:42 +02:00
|
|
|
table.tBodies[0].appendChild(row);
|
|
|
|
row.addClassName("eventRow");
|
2012-09-07 21:46:49 +02:00
|
|
|
var calendar = escape(data[i][1]);
|
2010-10-13 17:02:39 +02:00
|
|
|
var rTime = data[i][16];
|
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]);
|
2012-09-07 21:46:49 +02:00
|
|
|
row.calendar = calendar;
|
2009-07-19 18:41:42 +02:00
|
|
|
if (rTime)
|
|
|
|
row.recurrenceTime = escape(rTime);
|
2010-10-13 17:02:39 +02:00
|
|
|
row.isException = data[i][17];
|
2011-09-23 21:25:56 +02:00
|
|
|
row.editable = data[i][18] || IsSuperUser;
|
2010-10-13 17:02:39 +02:00
|
|
|
row.erasable = data[i][19] || IsSuperUser;
|
2014-02-04 22:25:52 +01:00
|
|
|
row.startDate = data[i][5];
|
|
|
|
var startDate = new Date(data[i][5]*1000);
|
2009-07-19 18:41:42 +02:00
|
|
|
row.day = startDate.getDayString();
|
2010-10-13 17:02:39 +02:00
|
|
|
if (!data[i][8])
|
2009-10-16 21:38:23 +02:00
|
|
|
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);
|
2010-10-13 17:02:39 +02:00
|
|
|
if (data[i][3] != null)
|
2009-10-14 22:29:46 +02:00
|
|
|
// Status is defined -- event is readable
|
|
|
|
row.observe("dblclick", editDoubleClickedEvent);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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);
|
2012-09-07 21:46:49 +02:00
|
|
|
var colorDiv = createElement("div", false, "colorBox calendarFolder" + calendar);
|
|
|
|
td.appendChild(colorDiv);
|
2013-11-13 20:46:08 +01:00
|
|
|
colorDiv.update(' ');
|
2012-09-07 21:46:49 +02:00
|
|
|
var span = createElement("span");
|
|
|
|
td.appendChild(span);
|
|
|
|
span.update(data[i][4]); // title
|
2014-07-30 16:31:25 +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);
|
2015-06-23 15:23:29 +02:00
|
|
|
td.update(data[i][22]); // start date
|
2014-07-30 16:31:25 +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);
|
2015-06-23 15:23:29 +02:00
|
|
|
td.update(data[i][23]); // end date
|
2014-07-30 16:31:25 +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-10-13 17:02:39 +02:00
|
|
|
if (data[i][7])
|
2014-02-07 21:53:39 +01:00
|
|
|
td.update(data[i][7]); // location
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-05-08 23:17:05 +02:00
|
|
|
td = createElement("td");
|
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
|
|
|
if (data[i][10])
|
2014-07-16 16:30:48 +02:00
|
|
|
td.update(data[i][10]); // category
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-10-13 17:02:39 +02:00
|
|
|
td = createElement("td");
|
|
|
|
row.appendChild(td);
|
|
|
|
td.observe("mousedown", listRowMouseDownHandler, true);
|
2014-02-07 21:53:39 +01:00
|
|
|
td.update(data[i][2]); // calendar
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-09-28 21:42:49 +02:00
|
|
|
if (sorting["event-header"] && sorting["event-header"].length > 0) {
|
|
|
|
var sortHeader = $(sorting["event-header"]);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (sortHeader) {
|
|
|
|
var sortImages = $(table.tHead).select(".sortImage");
|
|
|
|
$(sortImages).each(function(item) {
|
2014-07-30 16:31:25 +02:00
|
|
|
item.remove();
|
|
|
|
});
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var sortImage = createElement("img", "messageSortImage", "sortImage");
|
|
|
|
sortHeader.insertBefore(sortImage, sortHeader.firstChild);
|
2012-09-28 21:42:49 +02:00
|
|
|
if (sorting["event-ascending"])
|
2009-11-04 23:13:20 +01:00
|
|
|
sortImage.src = ResourcesURL + "/arrow-up.png";
|
2012-09-28 21:42:49 +02:00
|
|
|
else
|
|
|
|
sortImage.src = ResourcesURL + "/arrow-down.png";
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-24 19:35:14 +02:00
|
|
|
configureEventsDraggables();
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("eventsListCallback Ajax error");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2014-06-27 23:00:32 +02:00
|
|
|
function activeTasksCallback(http) {
|
2014-07-08 23:19:55 +02:00
|
|
|
if (http.readyState == 4 && http.status == 200) {
|
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
document.activeTasksAjaxRequest = null;
|
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
var list = $("calendarList");
|
|
|
|
var items = list.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
var id = items[i].getAttribute("id").substr(1);
|
|
|
|
var number = parseInt(data[id]);
|
|
|
|
var input = items[i].childNodesWithTag("input")[0];
|
|
|
|
var activeTasks = items[i].childNodesWithTag("span")[1];
|
|
|
|
if (typeof activeTasks == "undefined") {
|
|
|
|
if (number > 0) {
|
|
|
|
activeTasks = createElement("span", null, "badge");
|
|
|
|
items[i].appendChild(activeTasks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (number == 0) {
|
|
|
|
items[i].removeChild(activeTasks);
|
|
|
|
}
|
|
|
|
if (number > 0) {
|
|
|
|
activeTasks.innerHTML = number;
|
|
|
|
}
|
|
|
|
}
|
2014-06-27 23:00:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-28 21:42:49 +02:00
|
|
|
|
2014-06-27 23:00:32 +02:00
|
|
|
function tasksListCallback(http) {
|
2014-07-16 16:30:48 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
var div = $("tasksListView");
|
|
|
|
document.tasksListAjaxRequest = null;
|
|
|
|
var table = $("tasksList");
|
|
|
|
lastClickedRow = -1; // from generic.js
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var rows = table.select("TBODY TR");
|
|
|
|
rows.each(function(e) {
|
2014-07-30 16:31:25 +02:00
|
|
|
e.remove();
|
|
|
|
});
|
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
if (http.responseText.length > 0) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
// [0] Task ID
|
|
|
|
// [1] Calendar ID
|
|
|
|
// [2] Calendar name
|
|
|
|
// [3] Status (0, 1 = completed, 2)
|
|
|
|
// [4] Title
|
|
|
|
// [5] Due date (int)
|
|
|
|
// [6] Classification (0 = public, 1, = private, 2 = confidential)
|
|
|
|
// [7] Location
|
|
|
|
// [8] Category
|
|
|
|
// [9] Editable?
|
|
|
|
// [10] Erasable?
|
|
|
|
// [11] Priority (0, 1 = important, 9 = low)
|
2014-08-26 19:36:42 +02:00
|
|
|
// [12] Owner
|
2014-09-12 14:34:15 +02:00
|
|
|
// [13] recurrence-id
|
|
|
|
// [14] isException
|
2015-06-24 13:48:01 +02:00
|
|
|
// [15] Description
|
|
|
|
// [16] Status CSS class (duelater, completed, etc)
|
|
|
|
// [17] Due date (formatted)
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
var row = createElement("tr");
|
|
|
|
table.tBodies[0].appendChild(row);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
row.on("dblclick", editDoubleClickedEvent);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var calendar = escape(data[i][1]);
|
|
|
|
var cname = escape(data[i][0]);
|
2014-09-17 15:45:44 +02:00
|
|
|
|
2014-09-12 14:34:15 +02:00
|
|
|
var rTime = data[i][13];
|
|
|
|
var id = escape(data[i][1] + "-" + data[i][0]);
|
|
|
|
if (rTime)
|
|
|
|
id += "-" + escape(rTime);
|
|
|
|
row.setAttribute("id", id);
|
|
|
|
if (rTime)
|
|
|
|
row.recurrenceTime = escape(rTime);
|
|
|
|
row.isException = data[i][14];
|
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
//listItem.addClassName(data[i][5]); // Classification
|
2015-06-24 13:48:01 +02:00
|
|
|
row.addClassName(data[i][16]); // status
|
2014-07-24 19:35:14 +02:00
|
|
|
row.addClassName("taskRow");
|
2014-07-16 16:30:48 +02:00
|
|
|
row.calendar = calendar;
|
|
|
|
row.cname = cname;
|
|
|
|
row.erasable = data[i][10] || IsSuperUser;
|
|
|
|
if (parseInt(data[i][11]) == 1) {
|
|
|
|
row.addClassName("important");
|
|
|
|
}
|
|
|
|
else if (parseInt(data[i][11]) == 9) {
|
|
|
|
row.addClassName("low");
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var cell = createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
var input = createElement("input");
|
|
|
|
input.setAttribute("type", "checkbox");
|
|
|
|
cell.appendChild(input);
|
|
|
|
input.setAttribute("value", "1");
|
|
|
|
if (parseInt(data[i][9]) == 0) // editable?
|
|
|
|
input.setAttribute("disabled", true);
|
|
|
|
input.addClassName("checkBox");
|
|
|
|
if (parseInt(data[i][3]) == 1) // completed?
|
|
|
|
input.setAttribute("checked", "checked");
|
|
|
|
input.observe("click", updateTaskStatus, true);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
cell = createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
if (data[i][11] != null) {
|
|
|
|
cell.update(_("prio_" + data[i][11])); // Priority
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cell.update(""); // Priority
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
cell = createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
var colorDiv = createElement("div", false, "colorBox calendarFolder" + calendar);
|
|
|
|
cell.appendChild(colorDiv);
|
|
|
|
colorDiv.update(' ');
|
|
|
|
var t = new Element ("span");
|
|
|
|
cell.appendChild(t);
|
|
|
|
t.update(data[i][4]); // title
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
cell = createElement("td");
|
|
|
|
row.appendChild(cell);
|
2015-06-24 13:48:01 +02:00
|
|
|
if (data[i][17])
|
|
|
|
cell.update(data[i][17]); // end date
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
cell = createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
cell.update(data[i][7]); // location
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
cell = createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
cell.update(data[i][8]); // category
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
cell = createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
cell.update(data[i][2]); // calendar name
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
table.scrollTop = table.previousScroll;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
if (sorting["task-attribute"] && sorting["task-attribute"].length > 0) {
|
|
|
|
var sortHeader = $(sorting["task-header"]);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
if (sortHeader) {
|
|
|
|
var sortImages = $(table.tHead).select(".sortImage");
|
|
|
|
$(sortImages).each(function(item) {
|
2014-07-30 16:31:25 +02:00
|
|
|
item.remove();
|
|
|
|
});
|
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var sortImage = createElement("img", "messageSortImage", "sortImage");
|
|
|
|
sortHeader.insertBefore(sortImage, sortHeader.firstChild);
|
|
|
|
if (sorting["task-ascending"])
|
|
|
|
sortImage.src = ResourcesURL + "/arrow-up.png";
|
|
|
|
else
|
|
|
|
sortImage.src = ResourcesURL + "/arrow-down.png";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (http.callbackData) {
|
|
|
|
var selectedNodesId = http.callbackData;
|
|
|
|
for (var i = 0; i < selectedNodesId.length; i++) {
|
2014-07-30 16:31:25 +02:00
|
|
|
// log(selectedNodesId[i] + " (" + i + ") is selected");
|
2014-07-16 16:30:48 +02:00
|
|
|
var node = $(selectedNodesId[i]);
|
|
|
|
if (node) {
|
|
|
|
node.selectElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("tasksListCallback: no data");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-24 19:35:14 +02:00
|
|
|
|
2014-06-27 23:00:32 +02:00
|
|
|
}
|
2014-07-24 19:35:14 +02:00
|
|
|
configureTasksDraggables();
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
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) {
|
2014-01-28 21:36:48 +01:00
|
|
|
onCalendarGotoDay($("leftNavigationArrow"));
|
2009-07-15 20:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadNextView(event) {
|
2014-01-28 21:36:48 +01:00
|
|
|
onCalendarGotoDay($("rightNavigationArrow"));
|
2009-07-15 20:26:08 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeDateSelectorDisplay(day, keepCurrentDay) {
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = ApplicationBaseURL + "/dateselector";
|
2009-07-19 18:41:42 +02:00
|
|
|
if (day) {
|
|
|
|
if (day.length < 8)
|
|
|
|
day += "01";
|
|
|
|
url += "?day=" + day;
|
2006-09-07 17:50:03 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-04-26 18:01:01 +02:00
|
|
|
if (!keepCurrentDay)
|
|
|
|
currentDay = day;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-04-26 18:01:01 +02:00
|
|
|
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
|
2014-07-30 16:31:25 +02:00
|
|
|
= 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);
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = ApplicationBaseURL + "/" + newView;
|
2009-07-19 18:41:42 +02:00
|
|
|
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'];
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (!day)
|
|
|
|
day = currentDay;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// Deselect day in date selector
|
|
|
|
if (document.selectedDate)
|
|
|
|
document.selectedDate.deselect();
|
2014-07-30 16:31:25 +02: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;
|
2014-07-30 16:31:25 +02: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
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
setSelectedDayDate(day);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
selectedCalendarCell = null;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (document.dayDisplayAjaxRequest) {
|
|
|
|
document.dayDisplayAjaxRequest.aborted = true;
|
|
|
|
document.dayDisplayAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dayDisplayAjaxRequest
|
2014-07-30 16:31:25 +02:00
|
|
|
= triggerAjaxRequest(url, calendarDisplayCallback,
|
|
|
|
{ "view": newView,
|
|
|
|
"day": day,
|
|
|
|
"scrollEvent": scrollEvent });
|
|
|
|
|
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);
|
2014-07-30 16:31:25 +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
|
|
|
}
|
|
|
|
|
2012-04-18 22:03:07 +02:00
|
|
|
function refreshEventsAndTasks() {
|
2010-01-22 21:42:37 +01:00
|
|
|
refreshEvents();
|
2009-12-23 23:09:18 +01:00
|
|
|
refreshTasks();
|
2012-04-18 22:03:07 +02:00
|
|
|
}
|
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
function initRefreshViewCheckTimer() {
|
|
|
|
var refreshViewCheck = UserDefaults["SOGoRefreshViewCheck"];
|
|
|
|
if (refreshViewCheck && refreshViewCheck != "manually") {
|
|
|
|
var interval;
|
|
|
|
if (refreshViewCheck == "once_per_hour")
|
|
|
|
interval = 3600;
|
|
|
|
else if (refreshViewCheck == "every_minute")
|
|
|
|
interval = 60;
|
|
|
|
else {
|
|
|
|
interval = parseInt(refreshViewCheck.substr(6)) * 60;
|
|
|
|
}
|
|
|
|
refreshViewCheckTimer = window.setInterval(onRefreshViewCheckCallback,
|
|
|
|
interval * 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRefreshViewCheckCallback(event) {
|
|
|
|
onCalendarReload();
|
|
|
|
}
|
|
|
|
|
2012-04-18 22:03:07 +02:00
|
|
|
function onCalendarReload() {
|
|
|
|
if (!reloadWebCalendars()) {
|
|
|
|
refreshEventsAndTasks();
|
2012-04-20 18:11:21 +02:00
|
|
|
changeCalendarDisplay();
|
2012-04-18 22:03:07 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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() {
|
2012-04-18 22:03:07 +02:00
|
|
|
var remaining = [];
|
|
|
|
var refreshOperations = { "remaining": remaining };
|
|
|
|
if (UserSettings['Calendar']
|
|
|
|
&& UserSettings['Calendar']['WebCalendars']) {
|
|
|
|
var webCalendars = UserSettings['Calendar']['WebCalendars'];
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-18 22:03:07 +02:00
|
|
|
var folders = $("calendarList");
|
|
|
|
var calendarNodes = folders.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < calendarNodes.length; i++) {
|
|
|
|
var current = calendarNodes[i];
|
|
|
|
var calendarID = current.getAttribute("id");
|
|
|
|
var owner = current.getAttribute("owner");
|
|
|
|
var realID = owner + ":Calendar/" + calendarID.substr(1);
|
|
|
|
if (webCalendars[realID]) { /* is web calendar ? */
|
|
|
|
remaining.push(realID);
|
|
|
|
reloadWebCalendar(realID, refreshOperations);
|
|
|
|
}
|
|
|
|
}
|
2009-09-10 19:26:57 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-18 22:03:07 +02:00
|
|
|
return (remaining.length > 0);
|
2009-09-10 19:26:57 +02:00
|
|
|
}
|
2010-02-11 03:36:43 +01:00
|
|
|
|
2012-04-18 22:03:07 +02:00
|
|
|
var calendarReloadErrors = { "invalid-calendar-content":
|
2014-07-30 16:31:25 +02:00
|
|
|
_("the returned content was not valid calendar"
|
|
|
|
+ " data"),
|
|
|
|
"http-error": _("an unknown http error occurred"
|
|
|
|
+ " during the load operation"),
|
|
|
|
"bad-url": _("the url in use is invalid or the"
|
|
|
|
+ " host is currently unreachable"),
|
|
|
|
"invalid-url": _("the url being used is invalid"
|
|
|
|
+ " or not handled") };
|
2012-04-18 22:03:07 +02:00
|
|
|
|
|
|
|
function reloadWebCalendar(folderID, refreshOperations) {
|
|
|
|
var url = URLForFolderID(folderID) + "/reload";
|
|
|
|
var cbData = { "folderID": folderID };
|
|
|
|
if (refreshOperations) {
|
|
|
|
cbData["refreshOperations"] = refreshOperations;
|
|
|
|
}
|
|
|
|
triggerAjaxRequest(url, reloadWebCalendarCallback, cbData);
|
|
|
|
}
|
|
|
|
|
|
|
|
function reloadWebCalendarCallback(http) {
|
|
|
|
var cbData = http.callbackData;
|
|
|
|
if (http.status == 200) {
|
|
|
|
var result = http.responseText.evalJSON(true);
|
|
|
|
var requireAuth = false;
|
|
|
|
var success = false;
|
|
|
|
if (result.status) {
|
|
|
|
if (result.status == 401) {
|
|
|
|
requireAuth = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (result.status == 200) {
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var errorMessage = _("An error occurred while importing calendar.");
|
|
|
|
if (result["error"]) {
|
|
|
|
var message = calendarReloadErrors[result["error"]];
|
|
|
|
errorMessage = (_("An error occurred while loading remote"
|
|
|
|
+ " calendar: %{0}.").formatted(message));
|
|
|
|
}
|
|
|
|
showAlertDialog (errorMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var errorMessage = _("An error occurred while importing calendar.");
|
|
|
|
if (result["error"]) {
|
|
|
|
var message = calendarReloadErrors[result["error"]];
|
|
|
|
errorMessage = (_("An error occurred while loading remote"
|
|
|
|
+ " calendar: %{0}.").formatted(message));
|
|
|
|
}
|
|
|
|
showAlertDialog (errorMessage);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-18 22:03:07 +02:00
|
|
|
if (requireAuth) {
|
|
|
|
reauthenticateWebCalendar(cbData["folderID"], cbData);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var refreshOperations = cbData["refreshOperations"];
|
|
|
|
if (refreshOperations) {
|
|
|
|
var remaining = refreshOperations["remaining"];
|
|
|
|
var calIdx = remaining.indexOf(cbData["folderID"]);
|
|
|
|
remaining.splice(calIdx, 1);
|
|
|
|
if (remaining.length == 0) {
|
|
|
|
refreshEventsAndTasks();
|
2012-04-20 18:11:21 +02:00
|
|
|
changeCalendarDisplay();
|
2012-04-18 22:03:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (success) {
|
|
|
|
refreshEventsAndTasks();
|
2012-04-20 18:11:21 +02:00
|
|
|
changeCalendarDisplay();
|
2012-04-18 22:03:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
showAlertDialog(_("An error occurred while importing calendar."));
|
|
|
|
var refreshOperations = cbData["refreshOperations"];
|
|
|
|
if (refreshOperations) {
|
|
|
|
var remaining = refreshOperations["remaining"];
|
|
|
|
var calIdx = remaining.indexOf(cbData["folderID"]);
|
|
|
|
remaining.splice(calIdx, 1);
|
|
|
|
if (remaining.length > 0) {
|
|
|
|
var newFolderID = remaining[0];
|
|
|
|
reloadWebCalendar(newFolderID, refreshOperations);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function reauthenticateWebCalendar(folderID, refreshCBData) {
|
|
|
|
var remoteURL = null;
|
|
|
|
if (UserSettings['Calendar'] && UserSettings['Calendar']['WebCalendars']) {
|
|
|
|
var webCalendars = UserSettings['Calendar']['WebCalendars'];
|
|
|
|
remoteURL = webCalendars[folderID];
|
|
|
|
}
|
|
|
|
var parts = remoteURL.split("/");
|
|
|
|
var hostname = parts[2];
|
|
|
|
function authenticate(username, password) {
|
|
|
|
disposeDialog();
|
|
|
|
var url = URLForFolderID(folderID) + "/set-credentials";
|
|
|
|
var parameters = ("username=" + encodeURIComponent(username)
|
|
|
|
+ "&password=" + encodeURIComponent(password));
|
|
|
|
triggerAjaxRequest(url, authenticateWebCalendarCallback, refreshCBData, parameters,
|
|
|
|
{ "Content-type": "application/x-www-form-urlencoded" });
|
|
|
|
}
|
2013-02-05 22:13:18 +01:00
|
|
|
showAuthenticationDialog(_("Please identify yourself to %{0}")
|
2012-04-18 22:03:07 +02:00
|
|
|
.formatted(hostname),
|
|
|
|
authenticate);
|
|
|
|
}
|
|
|
|
|
|
|
|
function authenticateWebCalendarCallback(http) {
|
|
|
|
var cbData = http.callbackData;
|
|
|
|
var folderID = cbData["folderID"];
|
|
|
|
var refreshOperations = cbData["refreshOperations"];
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
reloadWebCalendar(folderID, refreshOperations);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (refreshOperations) {
|
|
|
|
var remaining = refreshOperations["remaining"];
|
|
|
|
var calIdx = remaining.indexOf(folderID);
|
|
|
|
remaining.splice(calIdx, 1);
|
|
|
|
if (remaining.length > 0) {
|
|
|
|
var newFolderID = remaining[0];
|
|
|
|
reloadWebCalendar(newFolderID, refreshOperations);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-10 19:26:57 +02:00
|
|
|
}
|
|
|
|
|
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);
|
2011-04-21 15:33:45 +02:00
|
|
|
if (eventRow) {
|
|
|
|
var eventBlocks = selectCalendarEvent(eventRow.calendar, eventRow.cname, eventRow.recurrenceTime);
|
|
|
|
if (eventBlocks) {
|
|
|
|
var firstEvent = eventBlocks.first();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2011-04-21 15:33:45 +02:00
|
|
|
if (currentView == "monthview")
|
|
|
|
contentView = firstEvent.up("DIV.day");
|
|
|
|
else
|
|
|
|
contentView = $("daysView");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2011-04-21 15:33:45 +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];
|
|
|
|
}
|
2010-10-13 17:02:39 +02:00
|
|
|
}
|
2009-10-16 21:38:23 +02:00
|
|
|
}
|
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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-08-27 18:51:30 +02:00
|
|
|
if (!currentDay)
|
|
|
|
currentDay = todayDate.getDayString();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
if (currentView == "dayview" || currentView == "multicolumndayview") {
|
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();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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();
|
|
|
|
}
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = (ApplicationBaseURL + "/eventsblocks?sd=" + sd + "&ed=" + ed
|
2009-07-19 18:41:42 +02:00
|
|
|
+ "&view=" + currentView);
|
|
|
|
document.refreshCalendarEventsAjaxRequest
|
2014-07-30 16:31:25 +02:00
|
|
|
= triggerAjaxRequest(url, refreshCalendarEventsCallback,
|
|
|
|
{"startDate": sd, "endDate": ed,
|
|
|
|
"scrollEvent": scrollEvent});
|
2007-06-11 23:23:48 +02:00
|
|
|
}
|
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
function _parseEvents(list, calendars) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var newCalendarEvents = {};
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
if (currentView == "multicolumndayview") {
|
2014-07-16 16:30:48 +02:00
|
|
|
var list;
|
|
|
|
for (var i = 0; i < calendars.length; i++) {
|
|
|
|
list = calendars[i][0];
|
|
|
|
for (var j = 0; j < list.length; j++) {
|
|
|
|
var event = list[j];
|
|
|
|
var cname = event[0];
|
|
|
|
var calendar = event[1];
|
|
|
|
// log("parsed cname: " + cname + "; calendar: " + calendar);
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-16 16:30:48 +02:00
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var event = list[i];
|
|
|
|
var cname = event[0];
|
|
|
|
var calendar = event[1];
|
|
|
|
// log("parsed cname: " + cname + "; calendar: " + calendar);
|
|
|
|
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);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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.
|
2014-07-30 16:31:25 +02:00
|
|
|
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. */
|
2010-02-11 03:36:43 +01:00
|
|
|
var setupFlags = {};
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
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;
|
2014-07-29 22:05:46 +02:00
|
|
|
if (blocks.length > 0)
|
|
|
|
// Ignore events that have no visible blocks
|
|
|
|
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) {
|
2014-07-30 16:31:25 +02:00
|
|
|
var eventsBlocks = http.responseText.evalJSON(true);
|
|
|
|
|
|
|
|
if (currentView == "multicolumndayview") {
|
|
|
|
calendarEvents = _parseEvents(null, eventsBlocks);
|
|
|
|
_drawCalendarAllDayEvents(null, null, eventsBlocks);
|
2014-06-20 19:16:55 +02:00
|
|
|
_drawCalendarEvents(null, null, eventsBlocks);
|
|
|
|
for (var i = 0 ; i < eventsBlocks.length; i++) {
|
2014-07-30 16:31:25 +02:00
|
|
|
_setupEventsDragAndDrop(eventsBlocks[i][0]);
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
calendarEvents = _parseEvents(eventsBlocks[0], null);
|
2014-06-20 19:16:55 +02:00
|
|
|
allDayEventsList = eventsBlocks[1];
|
|
|
|
eventsList = eventsBlocks[2];
|
|
|
|
if (currentView == "monthview")
|
|
|
|
_drawMonthCalendarEvents(eventsList, eventsBlocks[0], null);
|
|
|
|
else {
|
|
|
|
_drawCalendarAllDayEvents(allDayEventsList, eventsBlocks[0], null);
|
|
|
|
_drawCalendarEvents(eventsList, eventsBlocks[0], null);
|
|
|
|
}
|
|
|
|
_setupEventsDragAndDrop(eventsBlocks[0]);
|
2014-07-30 16:31:25 +02:00
|
|
|
}
|
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);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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) {
|
2014-07-29 22:05:46 +02:00
|
|
|
var color = UserDefaults['SOGoCalendarCategoriesColors'][category];
|
|
|
|
if (color) {
|
|
|
|
rules.push('border-right: 8px solid ' + color);
|
|
|
|
selectors.push('DIV.' + categoriesStyles.get(category));
|
|
|
|
}
|
|
|
|
});
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-05-21 23:22:25 +02:00
|
|
|
if (selectors.length > 0) {
|
|
|
|
if (categoriesStyleSheet.styleSheet && categoriesStyleSheet.styleSheet.addRule) {
|
|
|
|
// IE
|
2014-07-29 22:05:46 +02:00
|
|
|
for (var i = 0; i < selectors.length; i++) {
|
2010-05-21 23:22:25 +02:00
|
|
|
categoriesStyleSheet.styleSheet.addRule(selectors[i],
|
|
|
|
rules[i]);
|
2014-07-29 22:05:46 +02:00
|
|
|
}
|
2010-05-21 23:22:25 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Mozilla + Safari
|
2014-07-29 22:05:46 +02:00
|
|
|
for (var i = 0; i < selectors.length; i++) {
|
2010-05-21 23:22:25 +02:00
|
|
|
categoriesStyleSheet.appendChild(document.createTextNode(selectors[i] +
|
2014-07-29 22:05:46 +02:00
|
|
|
' { ' + rules[i] + '; }'));
|
|
|
|
}
|
2010-05-21 23:22:25 +02:00
|
|
|
}
|
2010-05-16 19:27:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
function newBaseEventDIV(eventRep, event, eventText) {
|
2014-07-30 16:31:25 +02:00
|
|
|
// log ("0 cname = " + event[0]);
|
|
|
|
// log ("1 calendar = " + event[1]);
|
2010-10-13 17:02:39 +02:00
|
|
|
// log ("2 calendar name = " + event[2]);
|
2014-07-30 16:31:25 +02:00
|
|
|
// log ("3 status = " + event[3]);
|
|
|
|
// log ("4 title = " + event[4]);
|
|
|
|
// log ("5 start = " + event[5]);
|
|
|
|
// log ("6 end = " + event[6]);
|
|
|
|
// log ("7 location = " + event[7]);
|
|
|
|
// log ("8 isallday = " + event[8]);
|
|
|
|
// log ("9 classification = " + event[9]); // 0 = public, 1 = private, 2 = confidential
|
|
|
|
// log ("10 category = " + event[10]);
|
|
|
|
// log ("11 participants emails = " + event[11]);
|
|
|
|
// log ("12 participants states = " + event[12]);
|
|
|
|
// log ("13 owner = " + event[13]);
|
|
|
|
// log ("14 iscycle = " + event[14]);
|
|
|
|
// log ("15 nextalarm = " + event[15]);
|
|
|
|
// log ("16 recurrenceid = " + event[16]);
|
|
|
|
// log ("17 isexception = " + event[17]);
|
2010-10-13 17:02:39 +02:00
|
|
|
// log ("18 editable = " + event[18]);
|
|
|
|
// log ("19 erasable = " + event[19]);
|
|
|
|
// log ("20 ownerisorganizer = " + event[20]);
|
2014-07-30 16:31:25 +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];
|
2014-01-28 21:36:48 +01:00
|
|
|
var startDate = new Date(event[5]*1000);
|
|
|
|
if (startDate) {
|
2014-02-04 22:25:52 +01:00
|
|
|
eventCell.startDate = event[5];
|
2014-01-28 21:36:48 +01:00
|
|
|
eventCell.writeAttribute('day', startDate.getDayString());
|
2014-02-04 22:25:52 +01:00
|
|
|
eventCell.writeAttribute('hour', event[8]? 'allday' : startDate.getHourString());
|
2014-01-28 21:36:48 +01:00
|
|
|
}
|
2014-07-16 16:30:48 +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-10-13 17:02:39 +02:00
|
|
|
eventCell.isException = event[17];
|
|
|
|
eventCell.editable = event[18];
|
|
|
|
eventCell.erasable = event[19] || IsSuperUser;
|
|
|
|
eventCell.ownerIsOrganizer = event[20];
|
2010-02-11 03:36:43 +01:00
|
|
|
eventCell.addClassName("event");
|
2014-07-16 16:30:48 +02:00
|
|
|
// if (event[14] > 0)
|
|
|
|
// eventCell.addClassName("alarm");
|
2014-07-30 16:31:25 +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]);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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-10-13 17:02:39 +02:00
|
|
|
var iconSpan = createElement("span", null, "icons");
|
2014-02-05 22:02:38 +01:00
|
|
|
textDiv.update(eventText.replace(/(\\r)?\\n/g, "<BR/>"));
|
2014-03-21 03:14:45 +01:00
|
|
|
textDiv.appendChild(iconSpan);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-08-27 22:16:35 +02:00
|
|
|
// Add alarm and classification icons
|
2010-10-13 17:02:39 +02:00
|
|
|
if (event[9] == 1)
|
2010-08-27 22:16:35 +02:00
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/private.png"}, null, iconSpan);
|
2010-10-13 17:02:39 +02:00
|
|
|
else if (event[9] == 2)
|
2010-08-27 22:16:35 +02:00
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/confidential.png"}, null, iconSpan);
|
2010-10-13 17:02:39 +02:00
|
|
|
if (event[15] > 0)
|
2010-08-27 22:16:35 +02:00
|
|
|
createElement("img", null, null, {src: ResourcesURL + "/alarm.png"}, null, iconSpan);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-10-13 17:02:39 +02:00
|
|
|
if (event[10] != null) {
|
2014-04-10 18:25:42 +02:00
|
|
|
var category = event[10].decodeEntities();
|
|
|
|
var categoryStyle = categoriesStyles.get(category);
|
2010-05-16 19:27:25 +02:00
|
|
|
if (!categoryStyle) {
|
|
|
|
categoryStyle = 'category_' + categoriesStyles.keys().length;
|
2014-04-10 18:25:42 +02:00
|
|
|
categoriesStyles.set([category], categoryStyle);
|
2010-05-16 19:27:25 +02:00
|
|
|
}
|
2016-06-09 22:10:11 +02:00
|
|
|
gradientDiv.addClassName(categoryStyle);
|
2010-05-16 19:27:25 +02:00
|
|
|
}
|
2010-05-16 21:24:07 +02:00
|
|
|
eventCell.observe("contextmenu", onMenuCurrentView);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-10-13 17:02:39 +02:00
|
|
|
if (event[3] == 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
|
|
|
}
|
2016-08-12 20:31:28 +02:00
|
|
|
else if (event[3] == 0) {
|
|
|
|
// Event is cancelled
|
|
|
|
eventCell.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
eventCell.observe("click", onCalendarSelectEvent);
|
|
|
|
eventCell.observe("click", onViewEvent);
|
|
|
|
innerDiv.addClassName('cancelled');
|
|
|
|
}
|
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
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
event.blocks.push(eventCell);
|
2014-07-29 22:05:46 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
return eventCell;
|
2008-07-16 04:12:18 +02:00
|
|
|
}
|
2008-07-17 23:12:43 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
function _drawCalendarAllDayEvents(events, eventsData, columnsData) {
|
2012-04-24 20:00:49 +02:00
|
|
|
var headerView = $("calendarHeader");
|
|
|
|
var subdivs = headerView.childNodesWithTag("div");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
if (currentView == "multicolumndayview"){
|
2014-07-16 16:30:48 +02:00
|
|
|
var days = subdivs[2].childNodesWithTag("div");
|
2014-07-30 16:31:25 +02:00
|
|
|
for (var i = 0; i < days.length; i++) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var parentDiv = days[i];
|
|
|
|
var calendar = columnsData[i];
|
|
|
|
var calendarAllDayEvents = calendar[1][0];
|
|
|
|
var calendarAllDayEventsData = calendar[0];
|
|
|
|
for (var j = 0; j < calendarAllDayEvents.length; j++) {
|
|
|
|
var eventRep = calendarAllDayEvents[j];
|
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
var eventCell = newAllDayEventDIV(eventRep, calendarAllDayEventsData[nbr]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
|
|
|
}
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-16 16:30:48 +02:00
|
|
|
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;
|
|
|
|
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
|
|
|
}
|
2012-04-24 20:00:49 +02:00
|
|
|
resizeCalendarHeaderDIV();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When the list of all day events overflows, we resize it in order to contain
|
2014-07-30 16:31:25 +02:00
|
|
|
at least 6 or 7 items. Afterwards we restore the regular scrollbar
|
|
|
|
mechanism. */
|
2012-04-24 20:00:49 +02:00
|
|
|
function resizeCalendarHeaderDIV() {
|
|
|
|
var headerView = $("calendarHeader");
|
|
|
|
var daysView = $("daysView");
|
|
|
|
if (headerView && daysView) {
|
|
|
|
/* consts */
|
2014-06-20 19:16:55 +02:00
|
|
|
var headerViewBaseHeight = 90;
|
|
|
|
var daysViewBaseTop = 95;
|
2012-04-24 20:00:49 +02:00
|
|
|
/* /consts */
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-24 20:00:49 +02:00
|
|
|
var maxEventPerDay = 0;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-24 20:00:49 +02:00
|
|
|
var subdivs = headerView.childNodesWithTag("div");
|
2014-06-20 19:16:55 +02:00
|
|
|
if (currentView == "multicolumndayview")
|
2014-07-16 16:30:48 +02:00
|
|
|
var days = subdivs[2].childNodesWithTag("div");
|
2014-06-20 19:16:55 +02:00
|
|
|
else
|
2014-07-16 16:30:48 +02:00
|
|
|
var days = subdivs[1].childNodesWithTag("div");
|
2012-04-24 20:00:49 +02:00
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
var parentDiv = days[i];
|
|
|
|
var divs = parentDiv.childNodesWithTag("div");
|
|
|
|
if (divs.length > maxEventPerDay) {
|
|
|
|
maxEventPerDay = divs.length;
|
|
|
|
}
|
|
|
|
}
|
2014-06-20 19:16:55 +02:00
|
|
|
if (maxEventPerDay > 0 && maxEventPerDay <= 4) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var moveDaysView = (maxEventPerDay * 19.5);
|
|
|
|
var expendHeaderHeight = ((maxEventPerDay - 1) * 20);
|
|
|
|
var deltaMax = 60;
|
|
|
|
if (expendHeaderHeight > deltaMax){
|
|
|
|
expendHeaderHeight = deltaMax;
|
|
|
|
moveDaysView = deltaMax;
|
|
|
|
}
|
|
|
|
daysView.style.top = String(daysViewBaseTop + moveDaysView) + "px";
|
|
|
|
headerView.style.height = String(headerViewBaseHeight + expendHeaderHeight) + "px";
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
else if (maxEventPerDay > 4) {
|
2014-07-30 16:31:25 +02:00
|
|
|
var deltaMax = 60;
|
2014-06-20 19:16:55 +02:00
|
|
|
daysView.style.top = String(daysViewBaseTop + deltaMax + 19) + "px";
|
|
|
|
headerView.style.height = String(headerViewBaseHeight + deltaMax) + "px";
|
2012-04-24 20:00:49 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-30 16:31:25 +02:00
|
|
|
var headerDays = document.getElementsByClassName("days")[0];
|
|
|
|
headerDays.observe("mouseenter", function(event){
|
|
|
|
headerDays.style.zIndex = "1";
|
|
|
|
});
|
|
|
|
headerDays.observe("mouseleave", function(event){
|
|
|
|
headerDays.style.zIndex = "0";
|
|
|
|
});
|
2012-04-24 20:00:49 +02:00
|
|
|
daysView.style.top = null;
|
|
|
|
headerView.style.height = null;
|
|
|
|
}
|
|
|
|
}
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function newAllDayEventDIV(eventRep, event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
// cname, calendar, starts, lasts,
|
2014-07-30 16:31:25 +02:00
|
|
|
// startHour, endHour, title) {
|
2010-10-13 17:02:39 +02:00
|
|
|
var eventCell = newBaseEventDIV(eventRep, event, event[4]);
|
2014-07-30 16:31:25 +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
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
function _drawCalendarEvents(events, eventsData, columnsData) {
|
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");
|
2014-06-20 19:16:55 +02:00
|
|
|
if (currentView == "multicolumndayview") {
|
2014-07-16 16:30:48 +02:00
|
|
|
for (var j = 0; j < days.length; j++) {
|
|
|
|
var parentDiv = days[j].childNodesWithTag("div")[0];
|
|
|
|
var calendar = columnsData[j];
|
|
|
|
var calendarEvents = calendar[2][0];
|
|
|
|
var calendarEventsData = calendar[0];
|
|
|
|
for (var k = 0; k < calendarEvents.length; k++) {
|
|
|
|
var eventRep = calendarEvents[k];
|
|
|
|
var nbr = eventRep.nbr;
|
|
|
|
var eventCell = newEventDIV(eventRep, calendarEventsData[nbr]);
|
|
|
|
parentDiv.appendChild(eventCell);
|
|
|
|
}
|
|
|
|
}
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-16 16:30:48 +02:00
|
|
|
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);
|
|
|
|
}
|
2010-02-12 18:23:47 +01:00
|
|
|
}
|
|
|
|
}
|
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) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var eventCell = newBaseEventDIV(eventRep, event, event[4]);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var pc = 100 / eventRep.siblings;
|
|
|
|
var left = eventRep.position * pc;
|
|
|
|
eventCell.style.left = left + "%";
|
|
|
|
var right = 100 - (eventRep.position + 1) * pc;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
eventCell.style.right = right + "%";
|
|
|
|
eventCell.addClassName("starts" + eventRep.start);
|
|
|
|
eventCell.addClassName("lasts" + eventRep.length);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
if (event[7]) {
|
|
|
|
var inside = eventCell.childNodesWithTag("div")[0];
|
|
|
|
var textDiv = inside.childNodesWithTag("div")[1];
|
|
|
|
textDiv.appendChild(createElement("br"));
|
|
|
|
var span = createElement("span", null, "location");
|
2016-01-13 17:29:41 +01:00
|
|
|
var text = _("Location") + " " + event[7];
|
2014-07-16 16:30:48 +02:00
|
|
|
span.update(text);
|
|
|
|
textDiv.appendChild(span);
|
|
|
|
}
|
2014-07-29 22:05:46 +02:00
|
|
|
|
2014-07-16 16:30:48 +02: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) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var eventText;
|
|
|
|
if (event[8]) // all-day event
|
|
|
|
eventText = event[4];
|
|
|
|
else
|
|
|
|
eventText = eventRep.starthour + " - " + event[4];
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var eventCell = newBaseEventDIV(eventRep, event,
|
|
|
|
eventText);
|
2014-07-29 22:05:46 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
return eventCell;
|
2010-02-11 03:36:43 +01:00
|
|
|
}
|
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
|
2014-07-30 16:31:25 +02:00
|
|
|
execute this method so that the "right" style attribute of the
|
|
|
|
"calendarHeader" element can be computed. This is execute only once. */
|
2010-02-12 18:23:47 +01:00
|
|
|
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";
|
2014-06-20 19:16:55 +02:00
|
|
|
var selectors = ["DIV#calendarHeader DIV.calendarLabels",
|
|
|
|
"DIV#calendarHeader DIV.dayLabels",
|
2010-02-13 17:57:39 +01:00
|
|
|
"DIV#calendarHeader DIV.days"];
|
2012-09-25 18:00:47 +02:00
|
|
|
var rule = ("right: " + delta + "px");
|
2010-02-13 17:57:39 +01:00
|
|
|
if (styleElement.styleSheet && styleElement.styleSheet.addRule) {
|
2010-05-16 19:27:25 +02:00
|
|
|
// IE
|
2014-07-29 22:05:46 +02:00
|
|
|
for (var i = 0; i < selectors.length; i++) {
|
|
|
|
styleElement.styleSheet.addRule(selectors[i], rule);
|
|
|
|
}
|
2010-02-13 17:57:39 +01:00
|
|
|
} else {
|
2010-05-16 19:27:25 +02:00
|
|
|
// Mozilla + Firefox
|
2012-09-25 18:00:47 +02:00
|
|
|
var styleText = selectors.join(",") + " { " + rule + "; }";
|
2010-02-13 17:57:39 +01:00
|
|
|
styleElement.appendChild(document.createTextNode(styleText));
|
|
|
|
}
|
2010-02-12 18:23:47 +01:00
|
|
|
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
|
|
|
calendarHeaderAdjusted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
function adjustMultiColumnCalendarHeaderDIV() {
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
var ch = $("calendarHeader");
|
|
|
|
var calendarLabels = ch.getElementsByClassName("calendarLabels")[0];
|
|
|
|
var calendarsToDisplay = calendarLabels.getElementsByClassName("calendarsToDisplay");
|
|
|
|
var dayLabels = ch.getElementsByClassName("dayLabels")[0].getElementsByClassName("dayColumn")[0];
|
|
|
|
var days = ch.getElementsByClassName("days")[0].getElementsByClassName("dayColumn");
|
|
|
|
var daysView = $("daysView").getElementsByClassName("dayColumn");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
var nbCalendars = calendarsToDisplay.length;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
if (nbCalendars > 0) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var width = 100/nbCalendars;
|
|
|
|
var left = 0;
|
|
|
|
var position = "absolute";
|
|
|
|
for(var i=0; i < nbCalendars; i++){
|
|
|
|
calendarsToDisplay[i].setStyle({ width: width + '%', left: left + '%', position: position}).show();
|
|
|
|
days[i].setStyle({ width: width + '%', left: left + '%'}).show();
|
|
|
|
daysView[i].setStyle({ width: width + '%', left: left + '%'}).show();
|
|
|
|
left += width;
|
|
|
|
}
|
|
|
|
dayLabels.setStyle({ width: '100%'}).show();
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-07-16 16:30:48 +02:00
|
|
|
$("calendarHeader").remove();
|
|
|
|
$("daysView").remove();
|
|
|
|
$("calendarContent").style.height = "100%";
|
|
|
|
$("calendarContent").style.background = "#E7E7E7";
|
2014-06-20 19:16:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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)
|
2014-07-16 16:30:48 +02:00
|
|
|
position = daysView.scrollTop;
|
2009-08-27 18:51:30 +02:00
|
|
|
preventAutoScroll = (position != -1);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.dayDisplayAjaxRequest = null;
|
|
|
|
div.update(http.responseText);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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();
|
|
|
|
}
|
2014-07-30 16:31:25 +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"];
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-20 19:16:55 +02:00
|
|
|
if (currentView == "multicolumndayview")
|
2014-07-30 16:31:25 +02:00
|
|
|
adjustMultiColumnCalendarHeaderDIV();
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// 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,
|
2012-07-09 16:17:07 +02:00
|
|
|
copyEventToPersonalCalendar,
|
2012-11-05 19:12:25 +01:00
|
|
|
onMenuRawEvent
|
2014-07-30 16:31:25 +02:00
|
|
|
);
|
2010-08-26 16:14:10 +02:00
|
|
|
var observer;
|
2014-06-20 19:16:55 +02:00
|
|
|
if (currentView == 'dayview' || currentView == 'weekview' || currentView == 'multicolumndayview') {
|
2009-07-19 18:41:42 +02:00
|
|
|
observer = $("daysView");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
observer = $("monthDaysView");
|
|
|
|
}
|
2014-07-30 16:31:25 +02: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"));
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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);
|
2014-07-30 16:31:25 +02: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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
restoreSelectedDay();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
refreshCalendarEvents(http.callbackData.scrollEvent);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var days = contentView.select("DIV.day");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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);
|
|
|
|
}
|
2014-07-09 22:47:13 +02:00
|
|
|
else if (currentView == "multicolumndayview") {
|
2014-07-16 16:30:48 +02:00
|
|
|
var calendarHeader = $("calendarHeader");
|
|
|
|
var headerCalendarsLabels = calendarHeader.select("DIV.calendarLabels DIV.calendarsToDisplay");
|
|
|
|
var headerDays = calendarHeader.select("DIV.days DIV.day");
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
|
|
|
headerDays[i].hour = "allday";
|
|
|
|
headerCalendarsLabels[i].observe("mousedown", listRowMouseDownHandler);
|
|
|
|
headerDays[i].observe("click", onCalendarSelectDay);
|
|
|
|
headerDays[i].observe("dblclick", onClickableCellsDblClick);
|
2014-08-27 22:50:45 +02:00
|
|
|
Event.on(days[i], "mousedown", onCalendarSelectDay);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var clickableCells = days[i].select("DIV.clickableHourCell");
|
|
|
|
for (var j = 0; j < clickableCells.length; j++)
|
|
|
|
clickableCells[j].observe("dblclick", onClickableCellsDblClick);
|
|
|
|
}
|
2014-07-09 22:47:13 +02:00
|
|
|
}
|
2009-07-19 18:41:42 +02:00
|
|
|
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);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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-06-08 01:23:07 +02:00
|
|
|
function onEventsSelectionChange() {
|
2009-07-19 18:41:42 +02:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-10-13 17:02:39 +02:00
|
|
|
var tasksList = $("tasksList");
|
|
|
|
tasksList.addClassName("_unfocused");
|
|
|
|
deselectAll(tasksList);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-09-07 21:46:49 +02:00
|
|
|
var rows = $(this).getSelectedNodes();
|
2009-07-19 18:41:42 +02:00
|
|
|
if (rows.length == 1) {
|
|
|
|
var row = rows[0];
|
|
|
|
changeCalendarDisplay( { "day": row.day,
|
2014-07-30 16:31:25 +02:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
2011-05-31 21:12:46 +02:00
|
|
|
function onTasksSelectionChange(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2011-05-31 21:12:46 +02:00
|
|
|
var target = Event.element(event);
|
|
|
|
if (target.tagName == 'SPAN')
|
|
|
|
target = target.parentNode;
|
|
|
|
// Update selection
|
|
|
|
onRowClick(event, target);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-10-13 17:02:39 +02:00
|
|
|
var eventsList = $("eventsList");
|
|
|
|
eventsList.addClassName("_unfocused");
|
2011-05-31 21:12:46 +02:00
|
|
|
eventsList.deselectAll();
|
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();
|
|
|
|
}
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = ApplicationBaseURL + "/" + href;
|
2009-07-19 18:41:42 +02:00
|
|
|
document.eventsListAjaxRequest
|
2014-07-30 16:31:25 +02:00
|
|
|
= triggerAjaxRequest(url, eventsListCallback, href);
|
|
|
|
|
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) {
|
2014-07-16 16:30:48 +02:00
|
|
|
if (document.tasksListAjaxRequest) {
|
|
|
|
document.tasksListAjaxRequest.aborted = true;
|
|
|
|
document.tasksListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
if (document.activeTasksAjaxRequest) {
|
|
|
|
document.activeTasksAjaxRequest.aborted = true;
|
|
|
|
document.activeTasksAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
url = ApplicationBaseURL + "/" + href;
|
|
|
|
urlActiveTasks = ApplicationBaseURL + "/activeTasks";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var tasksList = $("tasksList");
|
|
|
|
var selectedIds;
|
|
|
|
if (tasksList)
|
|
|
|
selectedIds = tasksList.getSelectedNodesId();
|
|
|
|
else
|
|
|
|
selectedIds = null;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
document.tasksListAjaxRequest = triggerAjaxRequest(url, tasksListCallback, selectedIds);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
document.activeTasksAjaxRequest = triggerAjaxRequest(urlActiveTasks, activeTasksCallback);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +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 newSortAttribute;
|
2012-09-28 21:42:49 +02:00
|
|
|
var headerId;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-09-28 21:42:49 +02:00
|
|
|
headerId = this.getAttribute("id");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-09-28 21:42:49 +02:00
|
|
|
if (headerId.startsWith('event'))
|
2014-07-30 16:31:25 +02:00
|
|
|
{
|
2012-09-28 21:42:49 +02:00
|
|
|
// This is needed to get the dom object and flip the triangle
|
|
|
|
sorting["event-header"] = headerId;
|
|
|
|
// Take away the 'events' and 'Header' and lowercase the result
|
|
|
|
newSortAttribute = headerId.sub("Header", "").sub("event", "").toLowerCase();
|
|
|
|
if (sorting["event-attribute"] == newSortAttribute)
|
|
|
|
sorting["event-ascending"] = !sorting["event-ascending"];
|
|
|
|
else
|
|
|
|
sorting["event-ascending"] = true;
|
|
|
|
sorting["event-attribute"] = newSortAttribute;
|
|
|
|
refreshEvents();
|
2014-07-30 16:31:25 +02:00
|
|
|
}
|
2012-09-28 21:42:49 +02:00
|
|
|
else // Tasks
|
2014-07-30 16:31:25 +02:00
|
|
|
{
|
2012-09-28 21:42:49 +02:00
|
|
|
// This is needed to get the dom object and flip the triangle
|
|
|
|
sorting["task-header"] = headerId;
|
|
|
|
// Take away the 'tasks' and 'Header' and lowercase the result
|
|
|
|
newSortAttribute = headerId.sub("Header", "").sub("task", "").toLowerCase();
|
|
|
|
if (sorting["task-attribute"] == newSortAttribute)
|
|
|
|
sorting["task-ascending"] = !sorting["task-ascending"];
|
|
|
|
else
|
|
|
|
sorting["task-ascending"] = true;
|
|
|
|
sorting["task-attribute"] = newSortAttribute;
|
|
|
|
refreshTasks();
|
2014-07-30 16:31:25 +02:00
|
|
|
}
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
Event.stop(event);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2012-12-05 20:47:28 +01:00
|
|
|
function refreshCurrentFolder(id) {
|
|
|
|
if (id == 'tasks')
|
2014-07-16 16:30:48 +02:00
|
|
|
refreshTasks();
|
2012-12-05 20:47:28 +01:00
|
|
|
else
|
2014-07-16 16:30:48 +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() {
|
2014-05-08 23:17:05 +02:00
|
|
|
var specificSearch;
|
2012-12-05 20:47:28 +01:00
|
|
|
var value = search["events"]["value"];
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (value && value.length)
|
2014-05-08 23:17:05 +02:00
|
|
|
specificSearch = ("&search=" + search["events"]["criteria"]
|
|
|
|
+ "&value=" + escape(value.utf8encode()));
|
2009-07-19 18:41:42 +02:00
|
|
|
else
|
2014-05-08 23:17:05 +02:00
|
|
|
specificSearch = "";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
refreshAlarms();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-09-28 21:42:49 +02:00
|
|
|
return _loadEventHref("eventslist?asc=" + sorting["event-ascending"]
|
|
|
|
+ "&sort=" + sorting["event-attribute"]
|
2009-07-19 18:41:42 +02:00
|
|
|
+ "&day=" + currentDay
|
2014-05-08 23:17:05 +02:00
|
|
|
+ specificSearch
|
|
|
|
+ "&filterpopup=" + eventListFilter);
|
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) {
|
2014-05-08 23:17:05 +02:00
|
|
|
var specificSearch;
|
2012-12-05 20:47:28 +01:00
|
|
|
var value = search["tasks"]["value"];
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-12-05 20:47:28 +01:00
|
|
|
if (value && value.length)
|
2014-05-16 22:28:43 +02:00
|
|
|
specificSearch = ("&search=" + search["tasks"]["criteria"]
|
|
|
|
+ "&value=" + escape(value.utf8encode()));
|
2012-12-05 20:47:28 +01:00
|
|
|
else
|
2014-05-08 23:17:05 +02:00
|
|
|
specificSearch = "";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-08-17 22:07:54 +02:00
|
|
|
if (setUserDefault == 1)
|
2014-05-16 22:28:43 +02:00
|
|
|
specificSearch += "&setud=1";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
refreshAlarms();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-09-28 21:42:49 +02:00
|
|
|
return _loadTasksHref("taskslist?show-completed=" + showCompletedTasks
|
|
|
|
+ "&asc=" + sorting["task-ascending"]
|
2012-12-05 20:47:28 +01:00
|
|
|
+ "&sort=" + sorting["task-attribute"]
|
2014-05-08 23:17:05 +02:00
|
|
|
+ specificSearch
|
|
|
|
+ "&filterpopup=" + taskListFilter);
|
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
|
|
|
}
|
|
|
|
|
2014-05-08 23:17:05 +02:00
|
|
|
function onEventsListFilterChange() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var node = $("filterpopup");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-05-08 23:17:05 +02:00
|
|
|
eventListFilter = node.value;
|
2014-07-30 16:31:25 +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
|
|
|
|
2014-05-08 23:17:05 +02:00
|
|
|
function onTasksListFilterChange() {
|
2014-07-16 16:30:48 +02:00
|
|
|
var node = $("tasksFilterpopup");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
taskListFilter = node.value;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
$("showHideCompletedTasks").disabled = taskListFilter == "view_overdue" ||
|
2014-07-30 16:31:25 +02:00
|
|
|
taskListFilter == "view_incomplete" ||
|
|
|
|
taskListFilter == "view_not_started";
|
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
return refreshTasks();
|
2014-05-08 23:17:05 +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";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var popup = $(menuId);
|
|
|
|
if (id == "monthLabel")
|
|
|
|
selectMonthInMenu(popup, this.getAttribute("month"));
|
|
|
|
else
|
|
|
|
selectYearInMenu(popup, this.innerHTML);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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();
|
2014-07-30 16:31:25 +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();
|
2014-07-30 16:31:25 +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-10-13 17:02:39 +02:00
|
|
|
if (occurence[16] == 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
return blocks;
|
2008-07-29 18:35:49 +02:00
|
|
|
}
|
|
|
|
|
2010-10-13 17:02:39 +02:00
|
|
|
/** Select event in calendar view */
|
2008-07-29 18:35:49 +02:00
|
|
|
function selectCalendarEvent(calendar, cname, recurrenceTime) {
|
2009-07-19 18:41:42 +02:00
|
|
|
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
|
|
|
}
|
2014-07-30 16:31:25 +02: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();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-07-30 22:10:00 +02:00
|
|
|
selectedCalendarCell = selectedBlocks;
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-07-30 22:10:00 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-13 17:02:39 +02:00
|
|
|
function deselectAll(list) {
|
|
|
|
if (list) {
|
|
|
|
list.deselectAll();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("eventsList").deselectAll();
|
|
|
|
$("tasksList").deselectAll();
|
2010-08-26 16:14:10 +02:00
|
|
|
}
|
|
|
|
if (selectedCalendarCell) {
|
|
|
|
for (var i = 0; i < selectedCalendarCell.length; i++)
|
|
|
|
selectedCalendarCell[i].deselect();
|
|
|
|
selectedCalendarCell = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-13 17:02:39 +02:00
|
|
|
/** Click on an event in the calendar view */
|
2010-10-08 18:08:10 +02:00
|
|
|
function onCalendarSelectEvent(event, willShowContextualMenu) {
|
2010-07-30 22:10:00 +02:00
|
|
|
var alreadySelected = false;
|
2014-07-30 16:31:25 +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);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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;
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-07-30 22:10:00 +02:00
|
|
|
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();
|
2014-07-30 16:31:25 +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.
|
2010-08-26 16:14:10 +02:00
|
|
|
deselectAll();
|
2010-10-14 15:20:25 +02:00
|
|
|
listOfSelection = null;
|
2010-08-26 16:14:10 +02:00
|
|
|
this.selectElement();
|
|
|
|
if (alreadySelected)
|
|
|
|
selectedCalendarCell = [this];
|
2010-07-30 22:10:00 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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");
|
2014-05-08 23:17:05 +02:00
|
|
|
var needRefresh = (eventListFilter == 'view_selectedday' && day != currentDay);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
setSelectedDayDate(day);
|
2009-07-19 18:41:42 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-10-08 18:08:10 +02:00
|
|
|
if (needRefresh)
|
|
|
|
refreshEvents();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
var target = Event.findElement(event);
|
|
|
|
var div = target.up('div');
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-09 22:47:13 +02:00
|
|
|
// Select the calendar associated with the day clicked
|
|
|
|
if (currentView == "multicolumndayview") {
|
2014-07-16 16:30:48 +02:00
|
|
|
if (target.getAttribute("calendar"))
|
|
|
|
var calendar = "[id='/" + target.getAttribute("calendar") + "']";
|
|
|
|
else
|
|
|
|
var calendar = "[id='/" + target.up("[calendar]").getAttribute("calendar") + "']";
|
|
|
|
var list = $("calendarList");
|
|
|
|
var selectedCalendar = list.down(calendar);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
onRowClick(event, selectedCalendar);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
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();
|
2014-01-28 21:36:48 +01:00
|
|
|
return true;
|
2010-08-26 16:14:10 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (listOfSelection) {
|
|
|
|
listOfSelection.addClassName("_unfocused");
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
selectedDayDate = dayDate;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-13 00:24:24 +01:00
|
|
|
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;
|
2014-02-22 02:35:54 +01:00
|
|
|
if (selectedDayDate && selectedDayDate.length > 0)
|
2010-02-13 00:24:24 +01:00
|
|
|
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");
|
2014-02-22 02:35:54 +01:00
|
|
|
return (dayNumber < days.size()) ? days[dayNumber].readAttribute("day") : null;
|
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);
|
2014-07-30 16:31:25 +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);
|
2012-09-07 21:46:49 +02:00
|
|
|
_updateTaskCompletion (this.up("tr"), 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);
|
2014-07-30 16:31:25 +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);
|
|
|
|
}
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// if (!list.length) {
|
|
|
|
// list.push(UserLogin);
|
|
|
|
// nodes[0].childNodesWithTag("input")[0].checked = true;
|
|
|
|
// }
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
|
2014-07-30 16:31:25 +02:00
|
|
|
// + list.join(",") + "/Calendar/");
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-24 19:42:16 +02:00
|
|
|
if (event) {
|
|
|
|
event.returnValue = true;
|
|
|
|
}
|
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);
|
|
|
|
}
|
2014-07-11 23:04:06 +02:00
|
|
|
configureDroppables();
|
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");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-06-08 15:38:32 +02:00
|
|
|
var lis = $(this).down("ul").childElements();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-06-08 15:38:32 +02:00
|
|
|
/* 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");
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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"));
|
2014-07-30 16:31:25 +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);
|
2012-07-09 16:17:07 +02:00
|
|
|
var rawOption = options.down("li", 8);
|
2010-08-26 16:14:10 +02:00
|
|
|
if (!selectedCalendarCell) {
|
|
|
|
deleteOption.addClassName("disabled");
|
|
|
|
copyOption.addClassName("disabled");
|
2012-07-09 16:17:07 +02:00
|
|
|
rawOption.addClassName("disabled");
|
2010-08-26 16:14:10 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
deleteOption.removeClassName("disabled");
|
|
|
|
var calendarEntry = $("/" + selectedCalendarCell[0].calendar);
|
|
|
|
if (calendarEntry.getAttribute("owner") == UserLogin)
|
|
|
|
copyOption.addClassName("disabled");
|
|
|
|
else
|
|
|
|
copyOption.removeClassName("disabled");
|
2014-07-16 16:30:48 +02:00
|
|
|
if (selectedCalendarCell.length == 1) {
|
|
|
|
// show raw content is only allowed for single event
|
2012-07-09 16:17:07 +02:00
|
|
|
rawOption.removeClassName("disabled");
|
|
|
|
}
|
2014-07-16 16:30:48 +02:00
|
|
|
else
|
2012-07-09 16:17:07 +02:00
|
|
|
rawOption.addClassName("disabled");
|
2010-08-26 16:14:10 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-08-26 16:14:10 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-09 16:17:07 +02:00
|
|
|
function onTasksListMenuPrepareVisibility() {
|
|
|
|
var options = $(this).down("ul");
|
|
|
|
var rawOption = options.down("li", 6);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-11-05 19:12:25 +01:00
|
|
|
var selectedTasks = $$("#tasksList ._selected");
|
2012-07-09 16:17:07 +02:00
|
|
|
if (selectedTasks.length == 1)
|
|
|
|
rawOption.removeClassName("disabled");
|
|
|
|
else
|
|
|
|
rawOption.addClassName("disabled");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-07-09 16:17:07 +02:00
|
|
|
return true;
|
|
|
|
}
|
2014-07-11 23:04:06 +02:00
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
2009-07-19 18:41:42 +02:00
|
|
|
var menus = {};
|
2014-07-30 16:31:25 +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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
dateMenu = [];
|
|
|
|
for (var i = 0; i < 11; i++)
|
|
|
|
dateMenu.push(onYearMenuItemClick);
|
|
|
|
menus["yearListMenu"] = dateMenu;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-05-12 21:25:50 +02:00
|
|
|
menus["eventsListMenu"] = new Array(onMenuNewEventClick,
|
|
|
|
onMenuNewTaskClick, "-",
|
2009-07-19 18:41:42 +02:00
|
|
|
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);
|
2014-05-16 22:28:43 +02:00
|
|
|
menus["eventSearchMenu"] = new Array(setSearchCriteria, setSearchCriteria, setSearchCriteria);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-02-11 03:36:43 +01:00
|
|
|
menus["tasksListMenu"] = new Array (editEvent, newTask, "-",
|
2012-07-09 16:17:07 +02:00
|
|
|
marksTasksAsCompleted, deleteEvent, "-",
|
2014-07-16 16:30:48 +02:00
|
|
|
onMenuRawTask);
|
2014-05-16 22:28:43 +02:00
|
|
|
menus["taskSearchMenu"] = new Array(setSearchCriteria, setSearchCriteria, setSearchCriteria);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var calendarsMenu = $("calendarsMenu");
|
|
|
|
if (calendarsMenu)
|
|
|
|
calendarsMenu.prepareVisibility = onCalendarsMenuPrepareVisibility;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-07-09 16:17:07 +02:00
|
|
|
var tasksListMenu = $("tasksListMenu");
|
|
|
|
if (tasksListMenu)
|
|
|
|
tasksListMenu.prepareVisibility = onTasksListMenuPrepareVisibility;
|
2014-07-30 16:31:25 +02: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 () {
|
2014-05-12 21:25:50 +02:00
|
|
|
newEventFromWidget.delay(0.1, this, 'task');
|
2009-08-25 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function marksTasksAsCompleted () {
|
2012-09-07 21:46:49 +02:00
|
|
|
var selectedTasks = $$("#tasksList ._selected");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-08-25 19:34:37 +02:00
|
|
|
for (var i = 0; i < selectedTasks.length; i++) {
|
|
|
|
var task = selectedTasks[i];
|
|
|
|
_updateTaskCompletion (task, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _updateTaskCompletion (task, value) {
|
2014-03-04 19:23:55 +01:00
|
|
|
url = (ApplicationBaseURL + "/" + task.calendar
|
2014-09-12 14:34:15 +02:00
|
|
|
+ "/" + task.cname);
|
|
|
|
|
|
|
|
if (task.recurrenceTime)
|
|
|
|
url += ("/occurence" + task.recurrenceTime);
|
|
|
|
|
|
|
|
url += ("/changeStatus?status=" + value);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-08-25 19:34:37 +02:00
|
|
|
triggerAjaxRequest(url, refreshTasks, null);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-08-25 19:34:37 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-09 16:17:07 +02:00
|
|
|
function onMenuRawTask(event) {
|
2012-09-07 21:46:49 +02:00
|
|
|
var selectedTasks = $$("#tasksList ._selected");
|
2012-07-09 16:17:07 +02:00
|
|
|
if (selectedTasks.length != 1) {
|
2014-07-16 16:30:48 +02:00
|
|
|
return;
|
2012-07-09 16:17:07 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = ApplicationBaseURL + "/" + selectedTasks[0].calendar + "/" + selectedTasks[0].cname + "/raw"
|
2014-05-12 21:25:50 +02:00
|
|
|
openGenericWindow.delay(0.1, url);
|
2012-07-09 16:17:07 +02:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:12:23 +02:00
|
|
|
function onMenuSharing(event) {
|
2009-07-19 18:41:42 +02:00
|
|
|
if ($(this).hasClassName("disabled"))
|
|
|
|
return;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var folders = $("calendarList");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
|
|
|
/* FIXME: activation of the context menu should preferably select the entry
|
2014-07-30 16:31:25 +02:00
|
|
|
above which the event has occurred */
|
2009-07-19 18:41:42 +02:00
|
|
|
if (selected) {
|
|
|
|
var folderID = selected.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/acls";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
openAclWindow(urlstr);
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2014-08-27 22:50:45 +02:00
|
|
|
function multicolumndayviewCalendarSelector(event, target) {
|
|
|
|
// Select the calendar associated with the day clicked
|
|
|
|
if (currentView == "multicolumndayview") {
|
|
|
|
if (target.getAttribute("calendar"))
|
|
|
|
var calendar = "[id='/" + target.getAttribute("calendar") + "']";
|
|
|
|
else
|
|
|
|
var calendar = "[id='/" + target.up("[calendar]").getAttribute("calendar") + "']";
|
|
|
|
var list = $("calendarList");
|
|
|
|
var selectedCalendar = list.down(calendar);
|
2014-09-10 16:58:46 +02:00
|
|
|
|
2014-08-27 22:50:45 +02:00
|
|
|
onRowClick(event, selectedCalendar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-28 22:09:24 +02:00
|
|
|
function onMenuCurrentView(event) {
|
2014-01-28 21:36:48 +01:00
|
|
|
var target = getTarget(event);
|
2010-02-16 14:32:02 +01:00
|
|
|
$("eventDialog").hide();
|
2010-08-26 16:14:10 +02:00
|
|
|
if (this.hasClassName('event')) {
|
2014-01-28 21:36:48 +01:00
|
|
|
// Select event cell
|
2010-08-26 16:14:10 +02:00
|
|
|
var onClick = onCalendarSelectEvent.bind(this);
|
2010-10-08 18:08:10 +02:00
|
|
|
onClick(event, true);
|
2014-01-28 21:36:48 +01:00
|
|
|
target = this;
|
2010-08-26 16:14:10 +02:00
|
|
|
}
|
2014-08-27 22:50:45 +02:00
|
|
|
multicolumndayviewCalendarSelector(event, target);
|
2014-01-28 21:36:48 +01:00
|
|
|
popupMenu(event, 'currentViewMenu', target);
|
2009-07-28 22:09:24 +02:00
|
|
|
}
|
|
|
|
|
2010-03-31 22:21:49 +02:00
|
|
|
function onMenuAllDayView(event) {
|
|
|
|
$("eventDialog").hide();
|
2014-08-27 22:50:45 +02:00
|
|
|
multicolumndayviewCalendarSelector(event, getTarget(event));
|
2014-01-28 21:36:48 +01:00
|
|
|
popupMenu(event, 'allDayViewMenu', getTarget(event));
|
2010-03-31 22:21:49 +02:00
|
|
|
}
|
|
|
|
|
2014-07-24 19:35:14 +02:00
|
|
|
function configureEventsDraggables() {
|
2014-07-11 23:04:06 +02:00
|
|
|
if ($("eventsList")) {
|
|
|
|
var rows = jQuery("tr.eventRow");
|
|
|
|
try { rows.draggable("destroy"); } catch (e) {}
|
|
|
|
rows.draggable({
|
2014-07-30 16:31:25 +02:00
|
|
|
helper: function (event) { return '<div id="DnDVisualEvents"></div>'; },
|
|
|
|
start: startDragging,
|
|
|
|
drag: whileDragging,
|
|
|
|
stop: stopDragging,
|
|
|
|
appendTo: 'body',
|
|
|
|
cursorAt: { right: 25 },
|
|
|
|
scroll: false,
|
|
|
|
distance: 4,
|
|
|
|
zIndex: 20
|
|
|
|
});
|
2014-07-24 19:35:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function configureTasksDraggables() {
|
|
|
|
if ($("tasksList")) {
|
|
|
|
var rows = jQuery("tr.taskRow");
|
|
|
|
try { rows.draggable("destroy"); } catch (e) {}
|
|
|
|
rows.draggable({
|
2014-07-30 16:31:25 +02:00
|
|
|
helper: function (event) { return '<div id="DnDVisualTasks"></div>'; },
|
|
|
|
start: startDragging,
|
|
|
|
drag: whileDragging,
|
|
|
|
stop: stopDragging,
|
|
|
|
appendTo: 'body',
|
|
|
|
cursorAt: { right: 25 },
|
|
|
|
scroll: false,
|
|
|
|
distance: 4,
|
|
|
|
zIndex: 20
|
|
|
|
});
|
2014-07-11 23:04:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function configureDroppables() {
|
2014-07-17 15:42:32 +02:00
|
|
|
jQuery("#calendarList li").droppable({ hoverClass: 'genericHoverClass',
|
|
|
|
drop: dropAction });
|
2014-07-11 23:04:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function startDragging(event, ui) {
|
2014-08-01 18:26:53 +02:00
|
|
|
var row = Event.findElement(event);
|
2014-07-11 23:04:06 +02:00
|
|
|
var handle = ui.helper;
|
2014-08-01 18:26:53 +02:00
|
|
|
var table = row.up('table');
|
|
|
|
var elements = table.getSelectedRowsId();
|
|
|
|
var count = elements.length;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-08-01 18:26:53 +02:00
|
|
|
if (count == 0 || elements.indexOf(row.id) < 0) {
|
|
|
|
onRowClick(event, row);
|
|
|
|
elements = table.getSelectedRowsId();
|
|
|
|
count = elements.length;
|
2014-07-11 23:04:06 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-08-01 18:26:53 +02:00
|
|
|
handle.html(count);
|
2014-07-11 23:04:06 +02:00
|
|
|
handle.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function whileDragging(event, ui) {
|
2014-07-16 16:30:48 +02:00
|
|
|
if (event)
|
|
|
|
var handle = ui.helper;
|
2014-07-11 23:04:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function stopDragging(event, ui) {
|
|
|
|
var handle = ui.helper;
|
|
|
|
handle.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
function dropAction(event, ui) {
|
2014-08-01 18:26:53 +02:00
|
|
|
var toId = this.id.substr(1);
|
|
|
|
var table = ui.draggable.closest('table')[0];
|
|
|
|
var itemIds = { data: table.getSelectedRowsId(),
|
|
|
|
// The table ID is either eventsList or tasksList
|
|
|
|
type: table.id.substr(0, table.id.indexOf('List')) };
|
2014-07-24 19:35:14 +02:00
|
|
|
|
|
|
|
for (var i = 0; i < itemIds.data.length; i++) {
|
2014-07-18 21:03:28 +02:00
|
|
|
// Find the event ID (.ics)
|
2014-07-24 19:35:14 +02:00
|
|
|
if (!itemIds.data[i].endsWith("ics")) {
|
|
|
|
// If it is a repeated event, substract the occurence part
|
|
|
|
if (itemIds.data[i].indexOf(".ics")) {
|
|
|
|
var x = eventIds[i].indexOf(".ics") + 4;
|
|
|
|
itemIds.data[i] = itemIds.data[i].substr(0,x);
|
2014-07-16 16:30:48 +02:00
|
|
|
}
|
2014-07-24 19:35:14 +02:00
|
|
|
else {
|
|
|
|
log("Can't find the event(.ics) on the item dragged : " + eventIds[i]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Distinction between personal calendar and a calendar with a reference ID (ex: 4535-7545-B-5D3J)
|
|
|
|
if (itemIds.data[i].search(toId+"-") == -1) {
|
|
|
|
var x = itemIds.data[i].indexOf('-');
|
|
|
|
if (itemIds.data[i].indexOf('-') == 4) {
|
|
|
|
var regEx = new RegExp(/\w+\-\w+\-\w+\-\w+/);
|
|
|
|
var fromId = regEx.exec(itemIds.data[i]);
|
|
|
|
var eventICS = itemIds.data[i].substr(fromId[0].length + 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var regEx = new RegExp(/\w+/);
|
|
|
|
var fromId = regEx.exec(itemIds.data[i]);
|
|
|
|
var eventICS = itemIds.data[i].substr(fromId[0].length + 1);
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-24 19:35:14 +02:00
|
|
|
if (itemIds.type == "events") {
|
2014-07-18 15:46:31 +02:00
|
|
|
var destinationCalendar = "destination=" + toId;
|
|
|
|
var params = destinationCalendar + "&days=0&start=0&duration=0";
|
|
|
|
var urlstr = ApplicationBaseURL + "/" + fromId + "/" + eventICS + "/adjust?" + params;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-18 15:46:31 +02:00
|
|
|
triggerAjaxRequest(urlstr, updateEventFromDraggingCallback);
|
2014-07-16 16:30:48 +02:00
|
|
|
}
|
2014-07-24 19:35:14 +02:00
|
|
|
else if (itemIds.type == "tasks") {
|
|
|
|
var params = "moveToCalendar=" + toId;
|
|
|
|
var urlstr = ApplicationBaseURL + "/" + fromId + "/" + eventICS + "/saveAsTask?" + params;
|
|
|
|
triggerAjaxRequest(urlstr, updateTaskFromDraggingCallback);
|
|
|
|
}
|
2014-07-11 23:04:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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");
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
2012-09-07 21:46:49 +02:00
|
|
|
handle.upperBlock = $("schedulerTabs");
|
2009-07-19 18:41:42 +02:00
|
|
|
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() {
|
2014-07-16 16:30:48 +02:00
|
|
|
var selector = $("calendarSelector");
|
|
|
|
updateCalendarStatus(); // triggers the initial events refresh
|
|
|
|
selector.changeNotification = updateCalendarsList;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var list = $("calendarList");
|
|
|
|
list.on("mousedown", onCalendarSelectionChange);
|
|
|
|
list.on("dblclick", onCalendarModify);
|
|
|
|
list.on("selectstart", listRowMouseDownHandler);
|
|
|
|
list.attachMenu("calendarsMenu");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var items = list.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
var input = items[i].childNodesWithTag("input")[0];
|
2014-07-22 19:26:28 +02:00
|
|
|
var activeTasks = items[i].childNodesWithTag("span")[1];
|
2014-07-16 16:30:48 +02:00
|
|
|
$(input).observe("click", clickEventWrapper(updateCalendarStatus));
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
var links = $("calendarSelectorButtons").childNodesWithTag("a");
|
|
|
|
$(links[0]).observe("click", clickEventWrapper(onCalendarNew));
|
|
|
|
$(links[1]).observe("click", clickEventWrapper(onCalendarWebAdd));
|
|
|
|
$(links[2]).observe("click", clickEventWrapper(onCalendarAdd));
|
|
|
|
$(links[3]).observe("click", clickEventWrapper(onCalendarRemove));
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 22:16:43 +02:00
|
|
|
function onCalendarSelectionChange(event) {
|
|
|
|
var target = Event.element(event);
|
2014-07-08 23:19:55 +02:00
|
|
|
if (target.tagName == 'DIV' || target.tagName == 'SPAN') {
|
2011-05-31 22:16:43 +02:00
|
|
|
target = target.parentNode;
|
2013-11-13 20:46:08 +01:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2011-05-31 22:16:43 +02:00
|
|
|
onRowClick(event, target);
|
|
|
|
}
|
|
|
|
|
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");
|
2012-07-10 02:29:13 +02:00
|
|
|
var width = 410;
|
|
|
|
var height = 410;
|
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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
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
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-05-12 21:25:50 +02:00
|
|
|
$(function() {
|
2014-07-30 16:31:25 +02:00
|
|
|
var properties = window.open(url, windowID,
|
|
|
|
"width="+width+",height="+height+",resizable=0");
|
|
|
|
properties.focus();
|
|
|
|
}).delay(0.1);
|
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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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;
|
2014-07-30 16:31:25 +02:00
|
|
|
// log("nodeID: " + nodeID);
|
2010-03-10 22:53:26 +01:00
|
|
|
var calendarNode = $(nodeID);
|
2014-07-08 23:19:55 +02:00
|
|
|
var displayNameNode = calendarNode.childNodesWithTag("span")[0];
|
2014-08-25 16:12:09 +02:00
|
|
|
displayNameNode.innerHTML = calendarName.escapeHTML();
|
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() {
|
2012-04-18 22:03:07 +02:00
|
|
|
disposeDialog();
|
2010-08-19 16:19:24 +02:00
|
|
|
var calendarUrl = this.value;
|
2009-09-10 19:26:57 +02:00
|
|
|
if (calendarUrl) {
|
2012-10-20 22:40:44 +02:00
|
|
|
var url = ApplicationBaseURL + "/addWebCalendar";
|
|
|
|
var parameters = "url=" + encodeURIComponent(calendarUrl);
|
2012-04-18 22:03:07 +02:00
|
|
|
triggerAjaxRequest(url, addWebCalendarCallback, calendarUrl, parameters,
|
|
|
|
{ "Content-type": "application/x-www-form-urlencoded" });
|
2009-09-10 19:26:57 +02:00
|
|
|
}
|
|
|
|
}
|
2012-04-18 22:03:07 +02:00
|
|
|
|
|
|
|
function addWebCalendarCallback(http) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
var data = http.responseText.evalJSON(true);
|
|
|
|
if (!data || data["error"] || !data["name"] || !data["folderID"]) {
|
|
|
|
showAlertDialog (_("An error occurred while importing calendar."));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (UserSettings['Calendar']) {
|
|
|
|
var webCalendars = UserSettings['Calendar']['WebCalendars'];
|
|
|
|
if (!webCalendars) {
|
|
|
|
webCalendars = {};
|
|
|
|
UserSettings['Calendar']['WebCalendars'] = webCalendars;
|
|
|
|
}
|
|
|
|
webCalendars[data["folderID"]] = http.callbackData;
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-18 22:03:07 +02:00
|
|
|
appendCalendar(data["name"], data["folderID"]);
|
|
|
|
reloadWebCalendar(data["folderID"]);
|
|
|
|
}
|
2009-09-10 19:49:07 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-04-18 19:12:42 +02:00
|
|
|
showAlertDialog (_("An error occurred while importing calendar."));
|
2009-09-10 19:49:07 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-04-18 22:03:07 +02:00
|
|
|
// if (data.imported) {
|
|
|
|
// appendCalendar(data.displayname, "/" + data.name);
|
|
|
|
// refreshEvents();
|
|
|
|
// refreshTasks();
|
|
|
|
// changeCalendarDisplay();
|
|
|
|
// }
|
|
|
|
// else if (data.status && data.status == 401) {
|
|
|
|
// reauthenticateWebCalendar(data.name, data.url);
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// }
|
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");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-09-02 21:14:15 +02:00
|
|
|
var url = ApplicationBaseURL + folderId + "/import";
|
|
|
|
$("uploadForm").action = url;
|
|
|
|
$("calendarFile").value = "";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-09-02 21:14:15 +02:00
|
|
|
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;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-09-02 21:14:15 +02:00
|
|
|
var div = $("uploadDialog");
|
2009-09-03 19:53:38 +02:00
|
|
|
var res = $("uploadResults");
|
2015-11-06 15:40:36 +01:00
|
|
|
|
|
|
|
var windowHeight = window.height();
|
|
|
|
var bottomOffset = windowHeight - div.getDimensions().height - top;
|
|
|
|
if (bottomOffset < 0)
|
|
|
|
top += bottomOffset;
|
|
|
|
|
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;
|
2012-05-28 22:30:35 +02:00
|
|
|
if ($("calendarFile").value.length) {
|
2014-07-16 16:30:48 +02:00
|
|
|
var btn = jQuery('#uploadSubmit');
|
|
|
|
jQuery('#uploadCancel').fadeOut('fast');
|
|
|
|
btn.addClass("disabled");
|
|
|
|
btn.children('span').text(_('Uploading'));
|
|
|
|
rc = true;
|
2012-05-28 22:30:35 +02:00
|
|
|
}
|
2009-09-02 21:14:15 +02:00
|
|
|
return rc;
|
|
|
|
}
|
2009-10-28 18:48:22 +01:00
|
|
|
function uploadCompleted(response) {
|
2012-05-28 22:30:35 +02:00
|
|
|
jQuery('#uploadCancel').show();
|
|
|
|
var btn = jQuery('#uploadSubmit');
|
|
|
|
btn.removeClass("disabled");
|
|
|
|
btn.children('span').text(_('Upload'));
|
2009-09-03 19:53:38 +02:00
|
|
|
var div = $("uploadResults");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2013-06-19 21:07:19 +02:00
|
|
|
try {
|
2014-07-16 16:30:48 +02:00
|
|
|
data = response.evalJSON(true);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
if (data.imported < 0)
|
2013-06-19 21:07:19 +02:00
|
|
|
$("uploadResultsContent").update(_("An error occurred while importing calendar."));
|
2014-07-16 16:30:48 +02:00
|
|
|
else if (data.imported == 0)
|
2013-06-19 21:07:19 +02:00
|
|
|
$("uploadResultsContent").update(_("No event was imported."));
|
2014-07-16 16:30:48 +02:00
|
|
|
else {
|
2013-06-19 21:07:19 +02:00
|
|
|
$("uploadResultsContent").update(_("A total of %{0} events were imported in the calendar.").formatted(data.imported));
|
|
|
|
refreshEventsAndDisplay();
|
2014-07-16 16:30:48 +02:00
|
|
|
}
|
2013-06-19 21:07:19 +02:00
|
|
|
} catch (e) {
|
2014-07-16 16:30:48 +02:00
|
|
|
$("uploadResultsContent").update(_("An error occurred while importing calendar."));
|
2009-09-03 20:37:08 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02: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
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
function appendCalendar(folderName, folderPath) {
|
2009-07-19 18:41:42 +02:00
|
|
|
var owner;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (folderPath) {
|
|
|
|
owner = getSubscribedFolderOwner(folderPath);
|
|
|
|
folderPath = accessToSubscribedFolder(folderPath);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
folderPath = "/" + folderName;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
if (!owner)
|
|
|
|
owner = UserLogin;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2011-11-03 12:54:03 +01:00
|
|
|
//log ("append name: " + folderName + "; path: " + folderPath + "; owner: " + owner);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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");
|
2014-07-30 16:31:25 +02: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);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var checkBox = createElement("input", null, "checkBox", { checked: 1 },
|
|
|
|
{ type: "checkbox" }, li);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
li.appendChild(document.createTextNode(" "));
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var colorBox = document.createElement("div");
|
2013-11-13 20:46:08 +01:00
|
|
|
colorBox.appendChild(document.createTextNode("\u00a0"));
|
2014-07-22 19:26:28 +02:00
|
|
|
li.appendChild(colorBox);
|
|
|
|
|
|
|
|
var displayName = document.createElement("span");
|
2014-09-17 15:45:44 +02:00
|
|
|
displayName.appendChild(document.createTextNode(folderName));
|
2014-07-22 19:26:28 +02:00
|
|
|
li.appendChild(displayName);
|
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
$(colorBox).addClassName("colorBox");
|
|
|
|
$(colorBox).addClassName('calendarFolder' + folderPath.substr(1));
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
// Check the checkbox (required for IE)
|
|
|
|
li.getElementsByTagName("input")[0].checked = true;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2011-05-31 22:16:43 +02:00
|
|
|
// Register event on checkbox
|
2012-04-18 21:23:09 +02:00
|
|
|
$(checkBox).on("click", clickEventWrapper(updateCalendarStatus));
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var url = URLForFolderID(folderPath) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folderPath);
|
2014-07-30 16:31:25 +02: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";
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-12-06 19:05:54 +01:00
|
|
|
var styles = ' .calendarFolder' + folderPath.substr(1)
|
2014-07-30 16:31:25 +02:00
|
|
|
+ ' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }'
|
|
|
|
+ ' div.colorBox.calendarFolder' + folderPath.substr(1)
|
|
|
|
+ ' { color: ' + color + ' !important; }';
|
|
|
|
|
2012-12-06 19:05:54 +01:00
|
|
|
if (styleElement.styleSheet) styleElement.styleSheet.cssText = styles; // IE
|
|
|
|
else styleElement.appendChild(document.createTextNode(styles)); // Mozilla + Webkit
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
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) {
|
2013-06-27 17:06:07 +02:00
|
|
|
appendCalendar(folderData["folderName"].unescapeHTML(), folderData["folder"]);
|
2009-07-19 18:41:42 +02:00
|
|
|
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);
|
2011-04-25 15:56:33 +02:00
|
|
|
var list = $(node.parentNode);
|
|
|
|
node.deselect();
|
|
|
|
list.removeChild(node);
|
2009-07-19 18:41:42 +02:00
|
|
|
if (removeFolderRequestCount == 0) {
|
2011-04-25 15:56:33 +02:00
|
|
|
list.down("li").selectElement(); // personal calendar
|
2009-07-19 18:41:42 +02:00
|
|
|
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++) {
|
|
|
|
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 {
|
2010-11-23 23:33:09 +01:00
|
|
|
deletePersonalCalendar(nodes[i]);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2009-09-04 21:08:21 +02:00
|
|
|
else {
|
|
|
|
var folderUrl = ApplicationBaseURL + folderId;
|
2011-12-23 20:55:05 +01:00
|
|
|
nodes[i].deselect();
|
2009-09-04 21:08:21 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2014-07-30 16:31:25 +02: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) {
|
2014-09-17 15:45:44 +02:00
|
|
|
var displayName = folderElement.childNodesWithTag("span")[0].innerHTML.strip().unescapeHTML();
|
2010-08-19 23:26:31 +02:00
|
|
|
showConfirmDialog(_("Confirmation"),
|
2014-07-08 23:19:55 +02:00
|
|
|
_("Are you sure you want to delete the calendar \"%{0}\"?").formatted(displayName),
|
2010-08-19 23:26:31 +02:00
|
|
|
deletePersonalCalendarConfirm.bind(folderElement));
|
|
|
|
}
|
|
|
|
|
|
|
|
function deletePersonalCalendarConfirm() {
|
2010-11-23 23:33:09 +01:00
|
|
|
var folderId = this.getAttribute("id").substr(1);
|
|
|
|
this.deselect();
|
|
|
|
this.hide();
|
2010-08-19 23:26:31 +02:00
|
|
|
removeFolderRequestCount++;
|
2014-04-08 21:32:13 +02:00
|
|
|
var url = ApplicationBaseURL + "/" + folderId + "/delete";
|
2010-11-23 23:33:09 +01:00
|
|
|
triggerAjaxRequest(url, deletePersonalCalendarCallback, this);
|
2010-08-19 23:26:31 +02:00
|
|
|
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)) {
|
2010-11-23 23:33:09 +01:00
|
|
|
var folderElement = http.callbackData;
|
|
|
|
if (folderElement) {
|
|
|
|
var list = folderElement.parentNode;
|
|
|
|
list.removeChild(folderElement);
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
|
|
|
removeFolderRequestCount--;
|
|
|
|
if (removeFolderRequestCount == 0) {
|
|
|
|
refreshEvents();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-23 23:33:09 +01:00
|
|
|
else {
|
2009-07-19 18:41:42 +02:00
|
|
|
log ("ajax problem 5: " + http.status);
|
2010-11-23 23:33:09 +01:00
|
|
|
var folderElement = http.callbackData;
|
|
|
|
folderElement.show();
|
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2007-06-08 01:23:07 +02:00
|
|
|
function configureLists() {
|
2013-07-11 19:46:38 +02:00
|
|
|
// Move calendar view if lists are collapsed
|
|
|
|
if (!$("schedulerTabs").visible()) {
|
|
|
|
$('calendarView').setStyle({ top: '0' }).show();
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-09-28 21:42:49 +02:00
|
|
|
// TASK LIST
|
|
|
|
var list = $("tasksList");
|
2009-07-19 18:41:42 +02:00
|
|
|
list.multiselect = true;
|
2012-09-28 21:42:49 +02:00
|
|
|
configureSortableTableHeaders(list);
|
|
|
|
TableKit.Resizable.init(list, {'trueResize' : true, 'keepWidth' : true});
|
|
|
|
list.down("tbody").on("mousedown", onTasksSelectionChange);
|
|
|
|
list.down("tbody").on("selectstart", listRowMouseDownHandler);
|
|
|
|
list.down("tbody").attachMenu("tasksListMenu");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
var input = $("showHideCompletedTasks");
|
|
|
|
input.observe("click", onShowCompletedTasks);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-08-17 22:07:54 +02:00
|
|
|
if (showCompletedTasks)
|
2014-07-16 16:30:48 +02:00
|
|
|
input.checked = true;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2012-09-28 21:42:49 +02:00
|
|
|
// EVENT LIST
|
2009-07-19 18:41:42 +02:00
|
|
|
list = $("eventsList");
|
|
|
|
list.multiselect = true;
|
|
|
|
configureSortableTableHeaders(list);
|
|
|
|
TableKit.Resizable.init(list, {'trueResize' : true, 'keepWidth' : true});
|
2012-09-07 21:46:49 +02:00
|
|
|
list.down("tbody").on("mousedown", onEventsSelectionChange);
|
2012-09-28 21:42:49 +02:00
|
|
|
list.down("tbody").attachMenu("eventsListMenu");
|
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);
|
2014-07-30 16:31:25 +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();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-29 19:54:48 +02:00
|
|
|
if (!$(document.body).hasClassName("popup"))
|
2012-11-12 22:36:30 +01:00
|
|
|
drawNowLine();
|
2009-07-23 15:57:35 +02:00
|
|
|
}
|
|
|
|
|
2012-11-12 22:36:30 +01:00
|
|
|
function drawNowLine() {
|
2014-07-16 16:30:48 +02:00
|
|
|
var d = new Date();
|
|
|
|
var hours = d.getHours();
|
|
|
|
var minutes = d.getMinutes();
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
if (currentView == "dayview") {
|
|
|
|
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;
|
|
|
|
var targets = $$("DIV#daysView DIV.days DIV.day[day=" + day
|
|
|
|
+ "] DIV.hourCells");
|
|
|
|
}
|
|
|
|
else if (currentView == "multicolumndayview") {
|
|
|
|
var targets = $$("DIV#daysView DIV.hourCells");
|
|
|
|
}
|
|
|
|
else if (currentView == "weekview")
|
|
|
|
var targets = $$("DIV#daysView DIV.days DIV.dayOfToday DIV.hourCells");
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-06-25 23:39:48 +02:00
|
|
|
else {
|
2014-07-16 16:30:48 +02:00
|
|
|
var targets = [];
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
if (targets[0] != undefined) {
|
|
|
|
if (currentView == "multicolumndayview") {
|
|
|
|
var nbCalendars = targets.length;
|
|
|
|
for(var i = 0; i < nbCalendars; i++){
|
|
|
|
var target = targets[i].getElementsByClassName("clickableHourCell")[hours];
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
if (target) {
|
|
|
|
var div = targets[i].getElementsByClassName("nowLineDisplay")[0];
|
|
|
|
if (!div)
|
|
|
|
div = new Element("div", {'class': 'nowLineDisplay'});
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
div.style.top = parseInt((minutes * target.offsetHeight / 60) - 1) + "px";
|
|
|
|
target.insertBefore(div, target.firstChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var target = targets[0].getElementsByClassName("clickableHourCell")[hours];
|
|
|
|
if (target) {
|
|
|
|
var div = targets[0].getElementsByClassName("nowLineDisplay")[0];
|
|
|
|
if (!div)
|
|
|
|
div = new Element("div", {'class': 'nowLineDisplay'});
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-07-16 16:30:48 +02:00
|
|
|
div.style.top = parseInt((minutes * target.offsetHeight / 60) - 1) + "px";
|
|
|
|
target.insertBefore(div, target.firstChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setTimeout("drawNowLine ();", 60000); // 1 min.
|
2013-08-27 15:04:26 +02:00
|
|
|
}
|
2008-09-18 20:03:59 +02:00
|
|
|
}
|
|
|
|
|
2013-07-11 19:46:38 +02:00
|
|
|
function onListCollapse(event, element) {
|
|
|
|
var img = element.select('img').first();
|
|
|
|
var tabs = $("schedulerTabs");
|
|
|
|
var handle = $("rightDragHandle");
|
|
|
|
var view = jQuery("#calendarView");
|
|
|
|
var state = 'collapse';
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2013-07-11 19:46:38 +02:00
|
|
|
if (tabs.visible()) {
|
|
|
|
img.removeClassName('collapse').addClassName('rise');
|
|
|
|
handle.hide();
|
|
|
|
view.animate({ top: '0' }, 200, function() {
|
2014-07-30 16:31:25 +02:00
|
|
|
tabs.hide();
|
|
|
|
});
|
2013-07-11 19:46:38 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
state = 'rise';
|
|
|
|
img.removeClassName('rise').addClassName('collapse');
|
|
|
|
tabs.show();
|
|
|
|
tabs.controller.onWindowResize();
|
|
|
|
view.animate({ top: handle.getStyle('top') }, 200, function() {
|
2014-07-30 16:31:25 +02:00
|
|
|
handle.show();
|
|
|
|
});
|
2013-07-11 19:46:38 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = ApplicationBaseURL + "/saveListState";
|
2013-07-11 19:46:38 +02:00
|
|
|
var params = "state=" + state;
|
|
|
|
triggerAjaxRequest(url, null, null, params,
|
|
|
|
{ "Content-type": "application/x-www-form-urlencoded" });
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2013-07-11 19:46:38 +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
|
2014-02-04 22:25:52 +01:00
|
|
|
|| (keyCode == Event.KEY_BACKSPACE)) {
|
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);
|
2014-05-16 22:28:43 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-07 21:46:49 +02:00
|
|
|
function saveTabState(event) {
|
|
|
|
var tab = $(event).memo;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2014-03-04 19:23:55 +01:00
|
|
|
var url = ApplicationBaseURL + "/saveSelectedList";
|
2012-09-07 21:46:49 +02:00
|
|
|
var params = "list=" + tab;
|
|
|
|
triggerAjaxRequest(url, null, null, params,
|
|
|
|
{ "Content-type": "application/x-www-form-urlencoded" });
|
|
|
|
}
|
|
|
|
|
2011-05-31 21:12:46 +02:00
|
|
|
function initScheduler() {
|
2012-09-28 21:42:49 +02:00
|
|
|
sorting["event-header"] = "";
|
|
|
|
sorting["task-header"] = "";
|
|
|
|
sorting["event-attribute"] = "start";
|
|
|
|
sorting["task-attribute"] = "end";
|
|
|
|
sorting["event-ascending"] = true;
|
|
|
|
sorting["task-ascending"] = true;
|
2014-07-30 16:31:25 +02: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");
|
2014-05-08 23:17:05 +02:00
|
|
|
eventListFilter = node.value;
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2010-04-12 19:51:59 +02:00
|
|
|
var tabsContainer = $("schedulerTabs");
|
|
|
|
var controller = new SOGoTabsController();
|
|
|
|
controller.attachToTabsContainer(tabsContainer);
|
2012-09-28 21:07:09 +02:00
|
|
|
tabsContainer.on("tabs:click", saveTabState);
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2011-04-01 20:40:51 +02:00
|
|
|
if (UserSettings['ShowCompletedTasks']) {
|
|
|
|
showCompletedTasks = parseInt(UserSettings['ShowCompletedTasks']);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
showCompletedTasks = 0;
|
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
initDateSelectorEvents();
|
|
|
|
initCalendarSelector();
|
|
|
|
configureSearchField();
|
|
|
|
configureLists();
|
|
|
|
$(document.body).observe("click", onBodyClickHandler);
|
2009-11-04 23:13:20 +01:00
|
|
|
// Calendar import form
|
|
|
|
$("uploadCancel").observe("click", hideCalendarImport);
|
|
|
|
$("uploadOK").observe("click", hideImportResults);
|
2013-07-11 19:46:38 +02:00
|
|
|
$("calendarView").on("click", "#listCollapse", onListCollapse);
|
2010-07-30 22:10:00 +02:00
|
|
|
Event.observe(document, "keydown", onDocumentKeydown);
|
2014-09-10 16:47:18 +02:00
|
|
|
|
|
|
|
initRefreshViewCheckTimer()
|
2009-07-19 18:41:42 +02:00
|
|
|
}
|
2014-07-30 16:31:25 +02:00
|
|
|
|
2009-07-19 18:41:42 +02:00
|
|
|
onWindowResize.defer();
|
|
|
|
Event.observe(window, "resize", onWindowResize);
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 20:47:28 +01:00
|
|
|
document.observe("generic:loaded", initScheduler);
|