2007-03-29 20:05:23 +02:00
|
|
|
/* JavaScript for SOGoCalendar */
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
var sortOrder = '';
|
|
|
|
var sortKey = '';
|
2006-08-31 01:13:18 +02:00
|
|
|
var listFilter = 'view_today';
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
var listOfSelection = null;
|
2007-01-30 14:50:52 +01:00
|
|
|
var selectedCalendarCell;
|
2006-10-12 23:05:32 +02:00
|
|
|
|
2007-04-03 16:24:09 +02:00
|
|
|
var showCompletedTasks = 0;
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
var currentDay = '';
|
2006-11-15 22:54:47 +01:00
|
|
|
var currentView = "dayview";
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
var cachedDateSelectors = new Array();
|
|
|
|
|
2006-10-14 01:37:27 +02:00
|
|
|
var contactSelectorAction = 'calendars-contacts';
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
var eventsToDelete = new Array();
|
|
|
|
var ownersOfEventsToDelete = new Array();
|
|
|
|
|
2007-04-28 00:06:58 +02:00
|
|
|
var usersRightsWindowHeight = 250;
|
|
|
|
var usersRightsWindowWidth = 502;
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function newEvent(sender, type) {
|
2007-05-22 16:38:54 +02:00
|
|
|
var day = sender.getAttribute("day");
|
|
|
|
if (!day)
|
|
|
|
day = currentDay;
|
|
|
|
|
|
|
|
var user = UserLogin;
|
|
|
|
if (sender.parentNode.getAttribute("id") != "toolbar"
|
|
|
|
&& currentView == "multicolumndayview" && type == "event")
|
|
|
|
user = sender.parentNode.parentNode.getAttribute("user");
|
|
|
|
|
|
|
|
var hour = sender.getAttribute("hour");
|
|
|
|
var urlstr = UserFolderURL + "../" + user + "/Calendar/new" + type;
|
|
|
|
var params = new Array();
|
|
|
|
if (day)
|
|
|
|
params.push("day=" + day);
|
|
|
|
if (hour)
|
|
|
|
params.push("hm=" + hour);
|
|
|
|
if (params.length > 0)
|
|
|
|
urlstr += "?" + params.join("&");
|
|
|
|
|
|
|
|
window.open(urlstr, "", "width=490,height=470,resizable=0");
|
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
2006-08-15 22:52:23 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMenuNewEventClick(event) {
|
|
|
|
newEvent(this, "event");
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMenuNewTaskClick(event) {
|
|
|
|
newEvent(this, "task");
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2006-10-17 00:35:22 +02:00
|
|
|
function _editEventId(id, owner) {
|
|
|
|
var urlBase;
|
|
|
|
if (owner)
|
|
|
|
urlBase = UserFolderURL + "../" + owner + "/";
|
|
|
|
urlBase += "Calendar/"
|
|
|
|
|
|
|
|
var urlstr = urlBase + id + "/edit";
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
var win = window.open(urlstr, "SOGo_edit_" + id,
|
2007-04-06 23:30:13 +02:00
|
|
|
"width=490,height=470,resizable=0");
|
2006-08-22 00:36:33 +02:00
|
|
|
win.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
function editEvent() {
|
2006-10-12 23:05:32 +02:00
|
|
|
if (listOfSelection) {
|
2006-10-17 00:35:22 +02:00
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-10-12 23:05:32 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++)
|
2006-10-27 17:03:48 +02:00
|
|
|
_editEventId(nodes[i].getAttribute("id"),
|
|
|
|
nodes[i].getAttribute("owner"));
|
2007-01-30 14:50:52 +01:00
|
|
|
} else if (selectedCalendarCell) {
|
|
|
|
_editEventId(selectedCalendarCell.getAttribute("aptCName"),
|
|
|
|
selectedCalendarCell.getAttribute("owner"));
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2006-08-25 22:49:34 +02:00
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
2006-10-18 23:53:47 +02:00
|
|
|
function _batchDeleteEvents() {
|
|
|
|
var events = eventsToDelete.shift();
|
|
|
|
var owner = ownersOfEventsToDelete.shift();
|
2006-10-17 00:35:22 +02:00
|
|
|
var urlstr = (UserFolderURL + "../" + owner + "/Calendar/batchDelete?ids="
|
|
|
|
+ events.join('/'));
|
2006-10-18 23:53:47 +02:00
|
|
|
document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
|
|
|
|
deleteEventCallback,
|
|
|
|
events);
|
2006-10-17 00:35:22 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteEvent() {
|
2006-10-12 23:05:32 +02:00
|
|
|
if (listOfSelection) {
|
2006-10-17 00:35:22 +02:00
|
|
|
var nodes = listOfSelection.getSelectedRows();
|
2006-10-12 23:05:32 +02:00
|
|
|
|
|
|
|
if (nodes.length > 0) {
|
2006-11-06 18:44:07 +01:00
|
|
|
var label = "";
|
|
|
|
if (listOfSelection == $("tasksList"))
|
|
|
|
label = labels["taskDeleteConfirmation"].decodeEntities();
|
|
|
|
else
|
|
|
|
label = labels["appointmentDeleteConfirmation"].decodeEntities();
|
|
|
|
|
|
|
|
if (confirm(label)) {
|
2006-10-18 23:53:47 +02:00
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
2006-10-17 00:35:22 +02:00
|
|
|
var sortedNodes = new Array();
|
|
|
|
var owners = new Array();
|
|
|
|
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var owner = nodes[i].getAttribute("owner");
|
2006-10-18 23:53:47 +02:00
|
|
|
if (!sortedNodes[owner]) {
|
2006-10-17 00:35:22 +02:00
|
|
|
sortedNodes[owner] = new Array();
|
|
|
|
owners.push(owner);
|
2006-10-18 23:53:47 +02:00
|
|
|
}
|
2006-10-17 00:35:22 +02:00
|
|
|
sortedNodes[owner].push(nodes[i].getAttribute("id"));
|
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
for (var i = 0; i < owners.length; i++) {
|
|
|
|
ownersOfEventsToDelete.push(owners[i]);
|
|
|
|
eventsToDelete.push(sortedNodes[owners[i]]);
|
|
|
|
}
|
|
|
|
_batchDeleteEvents();
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
2007-01-30 14:50:52 +01:00
|
|
|
else if (selectedCalendarCell) {
|
|
|
|
var label = labels["appointmentDeleteConfirmation"].decodeEntities();
|
|
|
|
if (confirm(label)) {
|
|
|
|
if (document.deleteEventAjaxRequest) {
|
|
|
|
document.deleteEventAjaxRequest.aborted = true;
|
|
|
|
document.deleteEventAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
eventsToDelete.push([selectedCalendarCell.getAttribute("aptCName")]);
|
|
|
|
ownersOfEventsToDelete.push(selectedCalendarCell.getAttribute("owner"));
|
|
|
|
_batchDeleteEvents();
|
|
|
|
}
|
|
|
|
}
|
2006-11-13 23:31:41 +01:00
|
|
|
else
|
|
|
|
window.alert("no selection");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-08-25 22:49:34 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-07 19:14:29 +01:00
|
|
|
function modifyEvent(sender, modification) {
|
|
|
|
var currentLocation = '' + window.location;
|
|
|
|
var arr = currentLocation.split("/");
|
|
|
|
arr[arr.length-1] = modification;
|
2006-11-15 01:10:53 +01:00
|
|
|
|
|
|
|
document.modifyEventAjaxRequest = triggerAjaxRequest(arr.join("/"),
|
|
|
|
modifyEventCallback,
|
|
|
|
modification);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-01-04 23:30:48 +01:00
|
|
|
function closeInvitationWindow() {
|
|
|
|
var closeDiv = document.createElement("div");
|
|
|
|
closeDiv.addClassName("javascriptPopupBackground");
|
|
|
|
var closePseudoWin = document.createElement("div");
|
|
|
|
closePseudoWin.addClassName("javascriptMessagePseudoWindow");
|
|
|
|
closePseudoWin.style.top = "0px;";
|
|
|
|
closePseudoWin.style.left = "0px;";
|
|
|
|
closePseudoWin.style.right = "0px;";
|
|
|
|
closePseudoWin.appendChild(document.createTextNode(labels["closeThisWindowMessage"].decodeEntities()));
|
|
|
|
document.body.appendChild(closeDiv);
|
|
|
|
document.body.appendChild(closePseudoWin);
|
|
|
|
}
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
function modifyEventCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
log("closing window...?");
|
2007-01-04 23:30:48 +01:00
|
|
|
if (queryParameters["mail-invitation"] == "yes")
|
|
|
|
closeInvitationWindow();
|
2007-01-30 15:02:27 +01:00
|
|
|
else {
|
|
|
|
window.opener.setTimeout("refreshAppointmentsAndDisplay();", 100);
|
|
|
|
window.setTimeout("window.close();", 100);
|
|
|
|
}
|
2006-11-15 01:10:53 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
log("showing alert...");
|
|
|
|
window.alert(labels["eventPartStatModificationError"]);
|
|
|
|
}
|
|
|
|
document.modifyEventAjaxRequest = null;
|
|
|
|
}
|
2006-11-07 19:14:29 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function deleteEventCallback(http) {
|
2006-08-25 22:49:34 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2007-01-30 19:18:30 +01:00
|
|
|
var nodes = http.callbackData;
|
2006-10-12 23:05:32 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var node = $(nodes[i]);
|
2007-01-30 19:18:30 +01:00
|
|
|
if (node)
|
|
|
|
node.parentNode.removeChild(node);
|
2006-10-12 23:05:32 +02:00
|
|
|
}
|
2006-10-18 23:53:47 +02:00
|
|
|
if (eventsToDelete.length)
|
|
|
|
_batchDeleteEvents();
|
|
|
|
else {
|
|
|
|
document.deleteEventAjaxRequest = null;
|
|
|
|
refreshAppointments();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
2006-08-25 22:49:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
2006-08-14 22:32:30 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function editDoubleClickedEvent(node) {
|
2006-10-17 00:35:22 +02:00
|
|
|
_editEventId(node.getAttribute("id"),
|
|
|
|
node.getAttribute("owner"));
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-08-25 22:49:34 +02:00
|
|
|
function onSelectAll() {
|
|
|
|
var list = $("appointmentsList");
|
|
|
|
list.selectRowsMatchingClass("appointmentRow");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
function displayAppointment(event) {
|
|
|
|
_editEventId(this.getAttribute("aptCName"),
|
|
|
|
this.getAttribute("owner"));
|
2006-08-15 22:52:23 +02:00
|
|
|
|
2006-11-15 18:59:47 +01:00
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
2006-09-05 20:43:20 +02:00
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
2006-08-15 22:52:23 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onDaySelect(node) {
|
2006-09-07 00:27:46 +02:00
|
|
|
var day = node.getAttribute("day");
|
2006-11-15 22:54:47 +01:00
|
|
|
var needRefresh = (listFilter == 'view_selectedday'
|
|
|
|
&& day != currentDay);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
var td = node.getParentWithTagName("td");
|
|
|
|
var table = td.getParentWithTagName("table");
|
|
|
|
|
|
|
|
// log ("table.selected: " + table.selected);
|
|
|
|
|
|
|
|
if (document.selectedDate)
|
2006-12-20 23:55:54 +01:00
|
|
|
document.selectedDate.deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-12-20 23:55:54 +01:00
|
|
|
td.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
document.selectedDate = td;
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day } );
|
2006-11-15 22:54:47 +01:00
|
|
|
if (needRefresh)
|
2006-08-22 00:36:33 +02:00
|
|
|
refreshAppointments();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onDateSelectorGotoMonth(node) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day, true);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onCalendarGotoDay(node) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var day = node.getAttribute("date");
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day } );
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function gotoToday() {
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay('');
|
2006-08-24 20:48:33 +02:00
|
|
|
changeCalendarDisplay();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function setDateSelectorContent(content) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var div = $("dateSelectorView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
div.innerHTML = content;
|
|
|
|
if (currentDay.length > 0)
|
|
|
|
restoreCurrentDaySelection(div);
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function dateSelectorCallback(http) {
|
2006-08-19 00:40:04 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.dateSelectorAjaxRequest = null;
|
2006-09-07 17:50:03 +02:00
|
|
|
var content = http.responseText;
|
|
|
|
setDateSelectorContent(content);
|
|
|
|
cachedDateSelectors[http.callbackData] = content;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function appointmentsListCallback(http) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var div = $("appointmentsListView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2006-10-11 20:12:02 +02:00
|
|
|
document.appointmentsListAjaxRequest = null;
|
2006-08-19 00:40:04 +02:00
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
var params = parseQueryParameters(http.callbackData);
|
|
|
|
sortKey = params["sort"];
|
|
|
|
sortOrder = params["desc"];
|
2006-11-13 23:31:41 +01:00
|
|
|
var list = $("appointmentsList");
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(list, "selectionchange", onAppointmentsSelectionChange.bindAsEventListener(list), true);
|
2006-11-09 23:55:04 +01:00
|
|
|
configureSortableTableHeaders();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function tasksListCallback(http) {
|
2006-10-11 20:12:02 +02:00
|
|
|
var div = $("tasksListView");
|
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.tasksListAjaxRequest = null;
|
2006-11-13 23:31:41 +01:00
|
|
|
var list = $("tasksList");
|
2006-11-15 01:10:53 +01:00
|
|
|
var scroll = list.scrollTop;
|
|
|
|
div.innerHTML = http.responseText;
|
|
|
|
list = $("tasksList");
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(list, "selectionchange", onTasksSelectionChange.bindAsEventListener(list), true);
|
2006-11-15 01:10:53 +01:00
|
|
|
list.scrollTop = scroll;
|
2006-10-11 20:12:02 +02:00
|
|
|
if (http.callbackData) {
|
|
|
|
var selectedNodesId = http.callbackData;
|
|
|
|
for (var i = 0; i < selectedNodesId.length; i++)
|
2006-12-20 23:55:54 +01:00
|
|
|
$(selectedNodesId[i]).select();
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function restoreCurrentDaySelection(div) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var elements = div.getElementsByTagName("a");
|
|
|
|
var day = null;
|
2006-11-03 00:17:55 +01:00
|
|
|
var i = 9;
|
2006-08-19 00:40:04 +02:00
|
|
|
while (!day && i < elements.length)
|
|
|
|
{
|
|
|
|
day = elements[i].getAttribute("day");
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (day
|
2006-11-06 18:44:07 +01:00
|
|
|
&& day.substr(0, 6) == currentDay.substr(0, 6)) {
|
2006-08-19 00:40:04 +02:00
|
|
|
for (i = 0; i < elements.length; i++) {
|
|
|
|
day = elements[i].getAttribute("day");
|
|
|
|
if (day && day == currentDay) {
|
|
|
|
var td = elements[i].getParentWithTagName("td");
|
|
|
|
if (document.selectedDate)
|
2006-12-20 23:55:54 +01:00
|
|
|
document.selectedDate.deselect();
|
|
|
|
td.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
document.selectedDate = td;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeDateSelectorDisplay(day, keepCurrentDay) {
|
2006-08-19 00:40:04 +02:00
|
|
|
var url = ApplicationBaseURL + "dateselector";
|
|
|
|
if (day)
|
|
|
|
url += "?day=" + day;
|
|
|
|
|
2006-09-07 00:27:46 +02:00
|
|
|
if (day != currentDay) {
|
|
|
|
if (!keepCurrentDay)
|
|
|
|
currentDay = day;
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-09-07 17:50:03 +02:00
|
|
|
var month = day.substr(0, 6);
|
|
|
|
if (cachedDateSelectors[month]) {
|
2006-10-17 00:35:22 +02:00
|
|
|
// log ("restoring cached selector for month: " + month);
|
2006-09-07 17:50:03 +02:00
|
|
|
setDateSelectorContent(cachedDateSelectors[month]);
|
|
|
|
}
|
|
|
|
else {
|
2006-10-17 00:35:22 +02:00
|
|
|
// log ("loading selector for month: " + month);
|
2006-09-07 17:50:03 +02:00
|
|
|
if (document.dateSelectorAjaxRequest) {
|
|
|
|
document.dateSelectorAjaxRequest.aborted = true;
|
|
|
|
document.dateSelectorAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dateSelectorAjaxRequest
|
|
|
|
= triggerAjaxRequest(url,
|
|
|
|
dateSelectorCallback,
|
|
|
|
month);
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeCalendarDisplay(time, newView) {
|
2006-12-19 18:06:07 +01:00
|
|
|
var url = ApplicationBaseURL + ((newView) ? newView : currentView);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-01-30 14:50:52 +01:00
|
|
|
selectedCalendarCell = null;
|
|
|
|
|
2006-10-12 18:46:24 +02:00
|
|
|
var day = null;
|
|
|
|
var hour = null;
|
|
|
|
if (time) {
|
|
|
|
day = time['day'];
|
|
|
|
hour = time['hour'];
|
|
|
|
}
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
if (!day)
|
2006-09-07 00:27:46 +02:00
|
|
|
day = currentDay;
|
2006-08-19 00:40:04 +02:00
|
|
|
if (day)
|
|
|
|
url += "?day=" + day;
|
|
|
|
|
2006-11-06 18:44:07 +01:00
|
|
|
// if (newView)
|
2006-10-17 00:35:22 +02:00
|
|
|
// log ("switching to view: " + newView);
|
2006-08-24 20:48:33 +02:00
|
|
|
// log ("changeCalendarDisplay: " + url);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
if (document.dayDisplayAjaxRequest) {
|
2006-08-22 00:36:33 +02:00
|
|
|
// log ("aborting day ajaxrq");
|
2006-08-19 00:40:04 +02:00
|
|
|
document.dayDisplayAjaxRequest.aborted = true;
|
|
|
|
document.dayDisplayAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.dayDisplayAjaxRequest = triggerAjaxRequest(url,
|
2006-08-24 20:48:33 +02:00
|
|
|
calendarDisplayCallback,
|
|
|
|
{ "view": newView,
|
2006-10-11 20:12:02 +02:00
|
|
|
"day": day,
|
|
|
|
"hour": hour });
|
2006-08-24 20:48:33 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _ensureView(view) {
|
|
|
|
if (currentView != view)
|
|
|
|
changeCalendarDisplay(null, view);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onDayOverview() {
|
2006-08-24 20:48:33 +02:00
|
|
|
return _ensureView("dayview");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMulticolumnDayOverview() {
|
2007-02-13 23:01:02 +01:00
|
|
|
return _ensureView("multicolumndayview");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onWeekOverview() {
|
2006-08-24 20:48:33 +02:00
|
|
|
return _ensureView("weekview");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onMonthOverview() {
|
2006-08-24 20:48:33 +02:00
|
|
|
return _ensureView("monthview");
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function scrollDayView(hour) {
|
2006-10-11 20:12:02 +02:00
|
|
|
var rowNumber;
|
|
|
|
if (hour) {
|
|
|
|
if (hour.length == 3)
|
|
|
|
rowNumber = parseInt(hour.substr(0, 1));
|
|
|
|
else {
|
|
|
|
if (hour.substr(0, 1) == "0")
|
|
|
|
rowNumber = parseInt(hour.substr(1, 1));
|
|
|
|
else
|
|
|
|
rowNumber = parseInt(hour.substr(0, 2));
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
rowNumber = 8;
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
var daysView = $("daysView");
|
|
|
|
var hours = daysView.childNodesWithTag("div")[0].childNodesWithTag("div");
|
|
|
|
if (hours.length > 0)
|
|
|
|
daysView.parentNode.scrollTop = hours[rowNumber + 1].offsetTop;
|
2006-10-04 00:59:07 +02:00
|
|
|
}
|
|
|
|
|
2006-11-15 01:53:59 +01:00
|
|
|
function onClickableCellsDblClick(event) {
|
|
|
|
newEvent(this, 'event');
|
2006-11-15 18:59:47 +01:00
|
|
|
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
2006-11-15 01:53:59 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function calendarDisplayCallback(http) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var div = $("calendarView");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
// log ("calendardisplaycallback: " + div);
|
2006-08-19 00:40:04 +02:00
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
2007-01-05 17:10:48 +01:00
|
|
|
document.dayDisplayAjaxRequest = null;
|
2006-08-19 00:40:04 +02:00
|
|
|
div.innerHTML = http.responseText;
|
2006-08-24 20:48:33 +02:00
|
|
|
if (http.callbackData["view"])
|
|
|
|
currentView = http.callbackData["view"];
|
|
|
|
if (http.callbackData["day"])
|
2006-09-07 00:27:46 +02:00
|
|
|
currentDay = http.callbackData["day"];
|
2006-10-11 20:12:02 +02:00
|
|
|
var hour = null;
|
|
|
|
if (http.callbackData["hour"])
|
2006-10-18 23:53:47 +02:00
|
|
|
hour = http.callbackData["hour"];
|
2006-11-15 22:54:47 +01:00
|
|
|
var contentView;
|
|
|
|
if (currentView == "monthview")
|
|
|
|
contentView = $("calendarContent");
|
|
|
|
else {
|
2006-11-03 00:17:55 +01:00
|
|
|
scrollDayView(hour);
|
2006-12-14 22:20:13 +01:00
|
|
|
// log("cbtest1");
|
2006-11-15 22:54:47 +01:00
|
|
|
contentView = $("daysView");
|
|
|
|
}
|
|
|
|
var appointments = document.getElementsByClassName("appointment", contentView);
|
|
|
|
for (var i = 0; i < appointments.length; i++) {
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(appointments[i], "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(appointments[i], "click", onCalendarSelectAppointment);
|
|
|
|
Event.observe(appointments[i], "dblclick", displayAppointment);
|
2006-11-15 22:54:47 +01:00
|
|
|
}
|
|
|
|
var days = document.getElementsByClassName("day", contentView);
|
|
|
|
if (currentView == "monthview")
|
|
|
|
for (var i = 0; i < days.length; i++) {
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(days[i], "click", onCalendarSelectDay);
|
|
|
|
Event.observe(days[i], "dblclick", onClickableCellsDblClick);
|
2006-11-15 18:59:47 +01:00
|
|
|
}
|
2006-11-15 22:54:47 +01:00
|
|
|
else
|
2006-11-15 18:59:47 +01:00
|
|
|
for (var i = 0; i < days.length; i++) {
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(days[i], "click", onCalendarSelectDay);
|
2006-11-15 18:59:47 +01:00
|
|
|
var clickableCells = document.getElementsByClassName("clickableHourCell",
|
|
|
|
days[i]);
|
2006-11-15 22:54:47 +01:00
|
|
|
for (var j = 0; j < clickableCells.length; j++)
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(clickableCells[j], "dblclick", onClickableCellsDblClick);
|
2006-11-15 18:59:47 +01:00
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
// log("cbtest1");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("ajax fuckage");
|
|
|
|
}
|
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function assignCalendar(name) {
|
|
|
|
if (typeof(skycalendar) != "undefined") {
|
|
|
|
var node = $(name);
|
|
|
|
|
|
|
|
node.calendar = new skycalendar(node);
|
|
|
|
node.calendar.setCalendarPage(ResourcesURL + "/skycalendar.html");
|
|
|
|
var dateFormat = node.getAttribute("dateFormat");
|
|
|
|
if (dateFormat)
|
|
|
|
node.calendar.setDateFormat(dateFormat);
|
|
|
|
}
|
2006-08-31 01:13:18 +02:00
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
function popupCalendar(node) {
|
|
|
|
var nodeId = node.getAttribute("inputId");
|
|
|
|
var input = $(nodeId);
|
|
|
|
input.calendar.popup();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
return false;
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onAppointmentContextMenu(event, element) {
|
2006-12-19 18:06:07 +01:00
|
|
|
var topNode = $("appointmentsList");
|
2006-10-17 00:35:22 +02:00
|
|
|
// log(topNode);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-12-19 18:06:07 +01:00
|
|
|
var menu = $("appointmentsListMenu");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(menu, "hideMenu", onAppointmentContextMenuHide);
|
2007-05-22 16:38:54 +02:00
|
|
|
popupMenu(event, "appointmentsListMenu", element);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2006-12-19 18:06:07 +01:00
|
|
|
var topNode = $("appointmentsList");
|
2006-08-22 00:36:33 +02:00
|
|
|
var selectedNodes = topNode.getSelectedRows();
|
|
|
|
topNode.menuSelectedRows = selectedNodes;
|
|
|
|
for (var i = 0; i < selectedNodes.length; i++)
|
2006-12-20 23:55:54 +01:00
|
|
|
selectedNodes[i].deselect();
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
topNode.menuSelectedEntry = element;
|
2006-12-20 23:55:54 +01:00
|
|
|
element.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onAppointmentContextMenuHide(event) {
|
2006-12-19 18:06:07 +01:00
|
|
|
var topNode = $("appointmentsList");
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
if (topNode.menuSelectedEntry) {
|
2006-12-20 23:55:54 +01:00
|
|
|
topNode.menuSelectedEntry.deselect();
|
2006-08-19 00:40:04 +02:00
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
|
|
|
if (topNode.menuSelectedRows) {
|
|
|
|
var nodeIds = topNode.menuSelectedRows;
|
|
|
|
for (var i = 0; i < nodeIds.length; i++) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var node = $(nodeIds[i]);
|
2006-12-20 23:55:54 +01:00
|
|
|
node.select();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
topNode.menuSelectedRows = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onAppointmentsSelectionChange() {
|
2006-11-13 23:31:41 +01:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
2006-10-12 23:05:32 +02:00
|
|
|
$("tasksList").addClassName("_unfocused");
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onTasksSelectionChange() {
|
2006-11-13 23:31:41 +01:00
|
|
|
listOfSelection = this;
|
|
|
|
this.removeClassName("_unfocused");
|
2006-10-12 23:05:32 +02:00
|
|
|
$("appointmentsList").addClassName("_unfocused");
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function _loadAppointmentHref(href) {
|
2006-08-24 23:14:18 +02:00
|
|
|
if (document.appointmentsListAjaxRequest) {
|
|
|
|
document.appointmentsListAjaxRequest.aborted = true;
|
|
|
|
document.appointmentsListAjaxRequest.abort();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
var url = ApplicationBaseURL + href;
|
2006-08-24 23:14:18 +02:00
|
|
|
document.appointmentsListAjaxRequest
|
2006-11-15 01:10:53 +01:00
|
|
|
= triggerAjaxRequest(url, appointmentsListCallback, href);
|
2006-08-19 00:40:04 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function _loadTasksHref(href) {
|
|
|
|
if (document.tasksListAjaxRequest) {
|
|
|
|
document.tasksListAjaxRequest.aborted = true;
|
|
|
|
document.tasksListAjaxRequest.abort();
|
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
url = ApplicationBaseURL + href;
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
var selectedIds = $("tasksList").getSelectedNodesId();
|
|
|
|
document.tasksListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, tasksListCallback, selectedIds);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onHeaderClick(event) {
|
2006-12-14 22:20:13 +01:00
|
|
|
// log("onHeaderClick: " + this.link);
|
2006-11-09 23:55:04 +01:00
|
|
|
_loadAppointmentHref(this.link);
|
|
|
|
|
|
|
|
event.preventDefault();
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function refreshAppointments() {
|
2006-08-24 23:14:18 +02:00
|
|
|
return _loadAppointmentHref("aptlist?desc=" + sortOrder
|
|
|
|
+ "&sort=" + sortKey
|
|
|
|
+ "&day=" + currentDay
|
|
|
|
+ "&filterpopup=" + listFilter);
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
function refreshTasks() {
|
2007-04-03 16:24:09 +02:00
|
|
|
return _loadTasksHref("taskslist?show-completed=" + showCompletedTasks);
|
2006-10-11 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function refreshAppointmentsAndDisplay() {
|
2006-10-18 23:53:47 +02:00
|
|
|
refreshAppointments();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
function onListFilterChange() {
|
2006-08-24 20:48:33 +02:00
|
|
|
var node = $("filterpopup");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
listFilter = node.value;
|
|
|
|
// log ("listFilter = " + listFilter);
|
|
|
|
|
|
|
|
return refreshAppointments();
|
|
|
|
}
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onAppointmentClick(event) {
|
2006-08-22 21:18:30 +02:00
|
|
|
var node = event.target.getParentWithTagName("tr");
|
2006-09-07 00:27:46 +02:00
|
|
|
var day = node.getAttribute("day");
|
2006-10-11 20:12:02 +02:00
|
|
|
var hour = node.getAttribute("hour");
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2006-10-11 20:12:02 +02:00
|
|
|
changeCalendarDisplay( { "day": day, "hour": hour} );
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
2006-08-22 21:18:30 +02:00
|
|
|
|
|
|
|
return onRowClick(event);
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function selectMonthInMenu(menu, month) {
|
2006-10-17 00:35:22 +02:00
|
|
|
var entries = menu.childNodes[1].childNodesWithTag("LI");
|
2006-08-22 21:18:30 +02:00
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
2006-10-17 00:35:22 +02:00
|
|
|
var entryMonth = entry.getAttribute("month");
|
|
|
|
if (entryMonth == month)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function selectYearInMenu(menu, month) {
|
2006-08-22 21:18:30 +02:00
|
|
|
var entries = menu.childNodes[1].childNodes;
|
|
|
|
for (i = 0; i < entries.length; i++) {
|
|
|
|
var entry = entries[i];
|
|
|
|
if (entry instanceof HTMLLIElement) {
|
|
|
|
var entryMonth = entry.innerHTML;
|
|
|
|
if (entryMonth == month)
|
|
|
|
entry.addClassName("currentMonth");
|
|
|
|
else
|
|
|
|
entry.removeClassName("currentMonth");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function popupMonthMenu(event, menuId) {
|
2006-08-22 21:18:30 +02:00
|
|
|
var node = event.target;
|
|
|
|
|
|
|
|
if (event.button == 0) {
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
|
|
|
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(event, document.currentPopupMenu);
|
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
var popup = $(menuId);
|
2006-08-22 21:18:30 +02:00
|
|
|
var id = node.getAttribute("id");
|
|
|
|
if (id == "monthLabel")
|
|
|
|
selectMonthInMenu(popup, node.getAttribute("month"));
|
|
|
|
else
|
|
|
|
selectYearInMenu(popup, node.innerHTML);
|
|
|
|
|
|
|
|
var diff = (popup.offsetWidth - node.offsetWidth) /2;
|
|
|
|
|
|
|
|
popup.style.top = (node.offsetTop + 95) + "px";
|
|
|
|
popup.style.left = (node.offsetLeft - diff) + "px";
|
|
|
|
popup.style.visibility = "visible";
|
|
|
|
|
|
|
|
bodyOnClick = "" + document.body.getAttribute("onclick");
|
|
|
|
document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');");
|
|
|
|
document.currentPopupMenu = popup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onMonthMenuItemClick(event) {
|
|
|
|
var month = '' + this.getAttribute("month");
|
2006-08-24 20:48:33 +02:00
|
|
|
var year = '' + $("yearLabel").innerHTML;
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
changeDateSelectorDisplay(year + month + "01", true);
|
|
|
|
|
|
|
|
// event.cancelBubble();
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
function onYearMenuItemClick(event) {
|
2006-08-24 20:48:33 +02:00
|
|
|
var month = '' + $("monthLabel").getAttribute("month");;
|
2007-05-22 16:38:54 +02:00
|
|
|
var year = '' + this.innerHTML;
|
2006-08-22 21:18:30 +02:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
changeDateSelectorDisplay(year + month + "01", true);
|
2006-08-22 21:18:30 +02:00
|
|
|
}
|
2006-08-31 01:13:18 +02:00
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onSearchFormSubmit() {
|
2006-08-31 01:13:18 +02:00
|
|
|
log ("search not implemented");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onCalendarSelectAppointment() {
|
2006-09-07 00:27:46 +02:00
|
|
|
var list = $("appointmentsList");
|
|
|
|
list.deselectAll();
|
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
var aptCName = this.getAttribute("aptCName");
|
2007-01-30 14:50:52 +01:00
|
|
|
if (selectedCalendarCell)
|
|
|
|
selectedCalendarCell.deselect();
|
|
|
|
this.select();
|
|
|
|
selectedCalendarCell = this;
|
2006-10-11 20:12:02 +02:00
|
|
|
var row = $(aptCName);
|
2006-11-03 00:17:55 +01:00
|
|
|
if (row) {
|
|
|
|
var div = row.parentNode.parentNode.parentNode;
|
|
|
|
div.scrollTop = row.offsetTop - (div.offsetHeight / 2);
|
2006-12-20 23:55:54 +01:00
|
|
|
row.select();
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function onCalendarSelectDay(event) {
|
2007-02-13 23:01:02 +01:00
|
|
|
var day;
|
|
|
|
if (currentView == "multicolumndayview")
|
|
|
|
day = this.parentNode.getAttribute("day");
|
|
|
|
else
|
|
|
|
day = this.getAttribute("day");
|
2006-11-15 22:54:47 +01:00
|
|
|
var needRefresh = (listFilter == 'view_selectedday'
|
|
|
|
&& day != currentDay);
|
2006-09-07 00:27:46 +02:00
|
|
|
|
2006-11-03 00:17:55 +01:00
|
|
|
if (currentView == 'weekview')
|
2006-11-15 01:10:53 +01:00
|
|
|
changeWeekCalendarDisplayOfSelectedDay(this);
|
2006-11-03 00:17:55 +01:00
|
|
|
else if (currentView == 'monthview')
|
2006-11-15 01:10:53 +01:00
|
|
|
changeMonthCalendarDisplayOfSelectedDay(this);
|
2006-09-07 00:27:46 +02:00
|
|
|
changeDateSelectorDisplay(day);
|
|
|
|
|
2007-01-30 19:18:30 +01:00
|
|
|
if (listOfSelection) {
|
|
|
|
listOfSelection.addClassName("_unfocused");
|
|
|
|
listOfSelection = null;
|
|
|
|
}
|
|
|
|
|
2006-11-15 22:54:47 +01:00
|
|
|
if (needRefresh)
|
|
|
|
refreshAppointments();
|
2006-09-07 00:27:46 +02:00
|
|
|
}
|
2006-10-11 20:12:02 +02:00
|
|
|
|
2006-12-19 20:17:35 +01:00
|
|
|
function changeWeekCalendarDisplayOfSelectedDay(node) {
|
2006-11-15 01:10:53 +01:00
|
|
|
var days = document.getElementsByClassName("day", node.parentNode);
|
2006-10-31 23:59:57 +01:00
|
|
|
|
2006-11-15 01:10:53 +01:00
|
|
|
for (var i = 0; i < days.length; i++)
|
|
|
|
if (days[i] != node)
|
|
|
|
days[i].removeClassName("selectedDay");
|
|
|
|
|
|
|
|
node.addClassName("selectedDay");
|
2006-10-31 23:59:57 +01:00
|
|
|
}
|
|
|
|
|
2007-03-13 00:06:48 +01:00
|
|
|
function findMonthCalendarSelectedCell(daysContainer) {
|
|
|
|
var found = false;
|
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
while (!found && i < daysContainer.childNodes.length) {
|
|
|
|
var currentNode = daysContainer.childNodes[i];
|
|
|
|
if (currentNode instanceof HTMLDivElement
|
|
|
|
&& currentNode.hasClassName("selectedDay")) {
|
|
|
|
daysContainer.selectedCell = currentNode;
|
|
|
|
found = true;
|
|
|
|
}
|
2006-11-03 00:17:55 +01:00
|
|
|
else
|
2007-03-13 00:06:48 +01:00
|
|
|
i++;
|
|
|
|
}
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function changeMonthCalendarDisplayOfSelectedDay(node) {
|
2007-03-13 00:06:48 +01:00
|
|
|
var daysContainer = node.parentNode;
|
|
|
|
if (!daysContainer.selectedCell)
|
|
|
|
findMonthCalendarSelectedCell(daysContainer);
|
|
|
|
|
|
|
|
if (daysContainer.selectedCell)
|
|
|
|
daysContainer.selectedCell.removeClassName("selectedDay");
|
|
|
|
daysContainer.selectedCell = node;
|
|
|
|
node.addClassName("selectedDay");
|
2006-11-03 00:17:55 +01:00
|
|
|
}
|
|
|
|
|
2007-04-03 16:24:09 +02:00
|
|
|
function onShowCompletedTasks(node) {
|
|
|
|
showCompletedTasks = (node.checked ? 1 : 0);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
return refreshTasks();
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function updateTaskStatus(node) {
|
2006-10-11 20:12:02 +02:00
|
|
|
var taskId = node.parentNode.getAttribute("id");
|
2006-10-17 21:49:47 +02:00
|
|
|
var taskOwner = node.parentNode.getAttribute("owner");
|
2006-10-11 20:12:02 +02:00
|
|
|
var newStatus = (node.checked ? 1 : 0);
|
2006-10-17 21:49:47 +02:00
|
|
|
// log ("update task status: " + taskId);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
var http = createHTTPClient();
|
|
|
|
|
2006-10-17 21:49:47 +02:00
|
|
|
url = (UserFolderURL + "../" + taskOwner + "/Calendar/"
|
|
|
|
+ taskId + "/changeStatus?status=" + newStatus);
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
if (http) {
|
2006-10-17 21:49:47 +02:00
|
|
|
// log ("url: " + url);
|
2006-10-11 20:12:02 +02:00
|
|
|
// TODO: add parameter to signal that we are only interested in OK
|
|
|
|
http.url = url;
|
|
|
|
http.open("GET", url, false /* not async */);
|
|
|
|
http.send("");
|
|
|
|
if (http.status == 200)
|
|
|
|
refreshTasks();
|
2006-10-17 21:49:47 +02:00
|
|
|
} else
|
|
|
|
log ("no http client?");
|
2006-10-11 20:12:02 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function updateCalendarStatus(event) {
|
2006-10-14 01:37:27 +02:00
|
|
|
var list = new Array();
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
var nodes = $("calendarList").childNodesWithTag("li");
|
2006-10-14 01:37:27 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2006-10-17 17:50:43 +02:00
|
|
|
var input = nodes[i].childNodesWithTag("input")[0];
|
2007-03-29 20:05:23 +02:00
|
|
|
if (input.checked) {
|
|
|
|
var folderId = nodes[i].getAttribute("id");
|
|
|
|
var elems = folderId.split(":");
|
|
|
|
if (elems.length > 1)
|
|
|
|
list.push(elems[0]);
|
|
|
|
else
|
|
|
|
list.push(UserLogin);
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2006-10-17 17:50:43 +02:00
|
|
|
if (!list.length) {
|
2007-03-29 20:05:23 +02:00
|
|
|
list.push(UserLogin);
|
|
|
|
nodes[0].childNodesWithTag("input")[0].checked = true;
|
2006-10-17 17:50:43 +02:00
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
// ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
|
2007-03-29 20:05:23 +02:00
|
|
|
// + list.join(",") + "/Calendar/");
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
var folderID = this.parentNode.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID);
|
|
|
|
if (this.checked)
|
|
|
|
urlstr += "/activateFolder";
|
|
|
|
else
|
|
|
|
urlstr += "/deactivateFolder";
|
|
|
|
triggerAjaxRequest(urlstr, calendarStatusCallback, folderID);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
updateCalendarsList();
|
|
|
|
refreshAppointments();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function calendarStatusCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 204) {
|
|
|
|
refreshAppointments();
|
|
|
|
refreshTasks();
|
|
|
|
changeCalendarDisplay();
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
else {
|
|
|
|
var folder = $(http.callbackData);
|
|
|
|
var input = folder.childNodesWithTag("input")[0];
|
|
|
|
input.checked = (!input.checked);
|
|
|
|
}
|
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function calendarEntryCallback(http) {
|
|
|
|
var disabled = true;
|
|
|
|
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200)
|
|
|
|
disabled = (http.responseText == "0");
|
|
|
|
var entry = $(http.callbackData);
|
|
|
|
var input = entry.childNodesWithTag("input")[0];
|
|
|
|
input.disabled = disabled;
|
|
|
|
if (disabled) {
|
|
|
|
input.checked = false;
|
|
|
|
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) {
|
2007-03-29 20:05:23 +02:00
|
|
|
var list = $("calendarList").childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var folderID = list[i].getAttribute("id");
|
|
|
|
var url = URLForFolderID(folderID) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folderID);
|
2006-12-19 18:06:07 +01:00
|
|
|
}
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function addContact(tag, fullContactName, contactId, contactName, contactEmail) {
|
2006-12-19 18:06:07 +01:00
|
|
|
var uids = $("uixselector-calendarsList-uidList");
|
2006-10-17 00:35:22 +02:00
|
|
|
// log("addContact");
|
2006-10-14 01:37:27 +02:00
|
|
|
if (contactId)
|
|
|
|
{
|
|
|
|
var re = new RegExp("(^|,)" + contactId + "($|,)");
|
|
|
|
|
|
|
|
if (!re.test(uids.value))
|
|
|
|
{
|
|
|
|
if (uids.value.length > 0)
|
|
|
|
uids.value += ',' + contactId;
|
|
|
|
else
|
|
|
|
uids.value = contactId;
|
2007-03-29 20:05:23 +02:00
|
|
|
var names = $("calendarList");
|
2006-12-19 18:06:07 +01:00
|
|
|
var listElems = names.childNodesWithTag("li");
|
2006-12-20 17:45:52 +01:00
|
|
|
var colorDef = indexColor(listElems.length);
|
|
|
|
names.appendChild(userCalendarEntry(contactId, colorDef));
|
2006-10-17 00:35:22 +02:00
|
|
|
|
2006-10-14 01:37:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-19 16:41:32 +02:00
|
|
|
|
2006-10-23 23:37:53 +02:00
|
|
|
function validateBrowseURL(input) {
|
2006-12-14 22:20:13 +01:00
|
|
|
var button = $("browseURLBtn");
|
2006-10-23 23:37:53 +02:00
|
|
|
|
|
|
|
if (input.value.length) {
|
|
|
|
if (!button.enabled)
|
|
|
|
enableAnchor(button);
|
|
|
|
} else if (!button.disabled)
|
|
|
|
disableAnchor(button);
|
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function browseURL(anchor, event) {
|
2006-10-23 23:37:53 +02:00
|
|
|
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
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function initializeMenus() {
|
2007-05-22 16:38:54 +02:00
|
|
|
menus["menuIds"] = new Array("monthListMenu", "yearListMenu",
|
|
|
|
"appointmentsListMenu",
|
|
|
|
"calendarsMenu",
|
|
|
|
"searchMenu");
|
|
|
|
var dateMenu = new Array();
|
|
|
|
for (var i = 0; i < 12; i++)
|
|
|
|
dateMenu.push(onMonthMenuItemClick);
|
|
|
|
menus["monthListMenu"] = dateMenu;
|
|
|
|
|
|
|
|
dateMenu = new Array();
|
|
|
|
for (var i = 0; i < 11; i++)
|
|
|
|
dateMenu.push(onYearMenuItemClick);
|
|
|
|
menus["yearListMenu"] = dateMenu;
|
|
|
|
|
|
|
|
menus["appointmentsListMenu"] = new Array(onMenuNewEventClick, "-",
|
|
|
|
onMenuNewTaskClick,
|
|
|
|
editEvent, deleteEvent, "-",
|
|
|
|
onSelectAll, "-",
|
|
|
|
null, null);
|
2007-05-22 17:19:52 +02:00
|
|
|
menus["calendarsMenu"] = new Array(null, null, "-", null, null, "-",
|
2007-05-22 16:38:54 +02:00
|
|
|
null, "-", onMenuSharing);
|
|
|
|
menus["searchMenu"] = new Array(setSearchCriteria);
|
|
|
|
|
|
|
|
initMenus();
|
2007-05-22 17:24:08 +02:00
|
|
|
var selector = $("calendarSelector");
|
|
|
|
if (selector)
|
|
|
|
selector.attachMenu("calendarsMenu");
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:12:23 +02:00
|
|
|
function onMenuSharing(event) {
|
2007-03-29 20:05:23 +02:00
|
|
|
var folders = $("calendarList");
|
2006-12-14 22:20:13 +01:00
|
|
|
var selected = folders.getSelectedNodes()[0];
|
2007-05-22 16:38:54 +02:00
|
|
|
/* FIXME: activation of the context menu should preferable select the entry
|
|
|
|
above which the event has occured */
|
|
|
|
if (selected) {
|
|
|
|
var folderID = selected.getAttribute("id");
|
|
|
|
var urlstr = URLForFolderID(folderID) + "/acls";
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
openAclWindow(urlstr);
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureDragHandles() {
|
|
|
|
var handle = $("verticalDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.leftBlock=$("leftPanel");
|
|
|
|
handle.rightBlock=$("rightPanel");
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.upperBlock=$("appointmentsListView");
|
|
|
|
handle.lowerBlock=$("calendarView");
|
|
|
|
}
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function initCalendarSelector() {
|
|
|
|
var selector = $("calendarSelector");
|
2006-12-14 22:20:13 +01:00
|
|
|
updateCalendarStatus();
|
|
|
|
selector.changeNotification = updateCalendarsList;
|
2006-12-19 18:06:07 +01:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
var list = $("calendarList").childNodesWithTag("li");
|
2006-12-19 18:06:07 +01:00
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var input = list[i].childNodesWithTag("input")[0];
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(input, "change", updateCalendarStatus);
|
|
|
|
Event.observe(list[i], "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(list[i], "click", onRowClick);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var links = $("calendarSelectorButtons").childNodesWithTag("a");
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(links[0], "click", onCalendarAdd);
|
|
|
|
Event.observe(links[1], "click", onCalendarRemove);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarAdd(event) {
|
|
|
|
openUserFolderSelector(onFolderSubscribeCB, "calendar");
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
function appendCalendar(folderName, folder) {
|
|
|
|
var calendarList = $("calendarList");
|
|
|
|
var lis = calendarList.childNodesWithTag("li");
|
|
|
|
var color = indexColor(lis.length);
|
|
|
|
log ("color: " + color);
|
|
|
|
var li = document.createElement("li");
|
|
|
|
li.setAttribute("id", folder);
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(li, "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(li, "click", onRowClick);
|
2007-03-29 20:05:23 +02:00
|
|
|
var checkBox = document.createElement("input");
|
|
|
|
checkBox.addClassName("checkBox");
|
|
|
|
checkBox.type = "checkbox";
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(checkBox, "change", updateCalendarStatus);
|
2007-03-29 20:05:23 +02:00
|
|
|
li.appendChild(checkBox);
|
2007-04-26 03:15:26 +02:00
|
|
|
li.appendChild(document.createTextNode(" "));
|
2007-03-29 20:05:23 +02:00
|
|
|
var colorBox = document.createElement("div");
|
|
|
|
colorBox.appendChild(document.createTextNode("OO"));
|
|
|
|
colorBox.addClassName("colorBox");
|
|
|
|
if (color) {
|
|
|
|
colorBox.style.color = color + ";";
|
|
|
|
colorBox.style.backgroundColor = color + ";";
|
|
|
|
}
|
|
|
|
li.appendChild(colorBox);
|
2007-04-06 23:30:13 +02:00
|
|
|
li.appendChild(document.createTextNode(" " + folderName));
|
2007-03-29 20:05:23 +02:00
|
|
|
|
|
|
|
calendarList.appendChild(li);
|
|
|
|
|
|
|
|
var contactId = folder.split(":")[0];
|
|
|
|
var styles = document.getElementsByTagName("style");
|
2007-04-26 03:15:26 +02:00
|
|
|
|
|
|
|
var url = URLForFolderID(folder) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, calendarEntryCallback, folder);
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
styles[0].innerHTML += ('.ownerIs' + contactId + ' {'
|
|
|
|
+ ' background-color: '
|
|
|
|
+ color
|
|
|
|
+ ' !important; }');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderSubscribeCB(folderData) {
|
|
|
|
var folder = $(folderData["folder"]);
|
|
|
|
if (!folder)
|
|
|
|
appendCalendar(folderData["folderName"], folderData["folder"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderUnsubscribeCB(folderId) {
|
|
|
|
var node = $(folderId);
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCalendarRemove(event) {
|
|
|
|
var nodes = $("calendarList").getSelectedNodes();
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
nodes[0].deselect();
|
|
|
|
var folderId = nodes[0].getAttribute("id");
|
|
|
|
var folderIdElements = folderId.split(":");
|
|
|
|
if (folderIdElements.length > 1) {
|
|
|
|
unsubscribeFromFolder(folderId, onFolderUnsubscribeCB, folderId);
|
|
|
|
}
|
2006-12-19 18:06:07 +01:00
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
|
|
|
|
event.preventDefault();
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
function configureSearchField() {
|
|
|
|
var searchValue = $("searchValue");
|
|
|
|
|
2007-05-25 16:36:43 +02:00
|
|
|
Event.observe(searchValue, "mousedown", onSearchMouseDown);
|
|
|
|
Event.observe(searchValue, "click", popupSearchMenu);
|
|
|
|
Event.observe(searchValue, "blur", onSearchBlur);
|
|
|
|
Event.observe(searchValue, "focus", onSearchFocus);
|
|
|
|
Event.observe(searchValue, "keydown", onSearchKeyDown);
|
2007-03-22 22:14:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
function initCalendars() {
|
2007-03-22 22:14:17 +01:00
|
|
|
if (!document.body.hasClassName("popup")) {
|
2007-03-29 20:05:23 +02:00
|
|
|
initCalendarSelector();
|
2007-03-22 22:14:17 +01:00
|
|
|
configureSearchField();
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-28 18:12:06 +02:00
|
|
|
addEvent(window, 'DOMContentLoaded', initCalendars);
|