+/* JavaScript for SOGoCalendar */
+
var sortOrder = '';
var sortKey = '';
var listFilter = 'view_today';
var listOfSelection = null;
var selectedCalendarCell;
-var hideCompletedTasks = 0;
+var showCompletedTasks = 0;
var currentDay = '';
var currentView = "dayview";
var eventsToDelete = new Array();
var ownersOfEventsToDelete = new Array();
+var usersRightsWindowHeight = 250;
+var usersRightsWindowWidth = 502;
+
function newEvent(sender, type) {
var day = sender.getAttribute("day");
if (!day)
if (params.length > 0)
urlstr += "?" + params.join("&");
- window.open(urlstr, "", "width=620,height=600,resizable=0");
+ window.open(urlstr, "", "width=490,height=470,resizable=0");
return false; /* stop following the link */
}
var urlstr = urlBase + id + "/edit";
var win = window.open(urlstr, "SOGo_edit_" + id,
- "width=620,height=600,resizable=0,scrollbars=0,toolbar=0," +
- "location=0,directories=0,status=0,menubar=0,copyhistory=0");
+ "width=490,height=470,resizable=0");
win.focus();
}
events);
}
-function deleteEvent()
-{
+function deleteEvent() {
if (listOfSelection) {
var nodes = listOfSelection.getSelectedRows();
}
}
-function deleteEventCallback(http)
-{
+function deleteEventCallback(http) {
if (http.readyState == 4
&& http.status == 200) {
var nodes = http.callbackData;
log ("ajax fuckage");
}
-function editDoubleClickedEvent(node)
-{
+function editDoubleClickedEvent(node) {
_editEventId(node.getAttribute("id"),
node.getAttribute("owner"));
event.returnValue = false;
}
-function onDaySelect(node)
-{
+function onDaySelect(node) {
var day = node.getAttribute("day");
var needRefresh = (listFilter == 'view_selectedday'
&& day != currentDay);
return false;
}
-function onDateSelectorGotoMonth(node)
-{
+function onDateSelectorGotoMonth(node) {
var day = node.getAttribute("date");
changeDateSelectorDisplay(day, true);
return false;
}
-function onCalendarGotoDay(node)
-{
+function onCalendarGotoDay(node) {
var day = node.getAttribute("date");
changeDateSelectorDisplay(day);
return false;
}
-function gotoToday()
-{
+function gotoToday() {
changeDateSelectorDisplay('');
changeCalendarDisplay();
return false;
}
-function setDateSelectorContent(content)
-{
+function setDateSelectorContent(content) {
var div = $("dateSelectorView");
div.innerHTML = content;
restoreCurrentDaySelection(div);
}
-function dateSelectorCallback(http)
-{
+function dateSelectorCallback(http) {
if (http.readyState == 4
&& http.status == 200) {
document.dateSelectorAjaxRequest = null;
log ("ajax fuckage");
}
-function appointmentsListCallback(http)
-{
+function appointmentsListCallback(http) {
var div = $("appointmentsListView");
if (http.readyState == 4
log ("ajax fuckage");
}
-function tasksListCallback(http)
-{
+function tasksListCallback(http) {
var div = $("tasksListView");
if (http.readyState == 4
log ("ajax fuckage");
}
-function restoreCurrentDaySelection(div)
-{
+function restoreCurrentDaySelection(div) {
var elements = div.getElementsByTagName("a");
var day = null;
var i = 9;
}
}
-function changeDateSelectorDisplay(day, keepCurrentDay)
-{
+function changeDateSelectorDisplay(day, keepCurrentDay) {
var url = ApplicationBaseURL + "dateselector";
if (day)
url += "?day=" + day;
if (!keepCurrentDay)
currentDay = day;
- log (backtrace());
var month = day.substr(0, 6);
if (cachedDateSelectors[month]) {
// log ("restoring cached selector for month: " + month);
}
}
-function changeCalendarDisplay(time, newView)
-{
+function changeCalendarDisplay(time, newView) {
var url = ApplicationBaseURL + ((newView) ? newView : currentView);
selectedCalendarCell = null;
return false;
}
-function onDayOverview()
-{
+function onDayOverview() {
return _ensureView("dayview");
}
-function onMulticolumnDayOverview()
-{
+function onMulticolumnDayOverview() {
return _ensureView("multicolumndayview");
}
-function onWeekOverview()
-{
+function onWeekOverview() {
return _ensureView("weekview");
}
-function onMonthOverview()
-{
+function onMonthOverview() {
return _ensureView("monthview");
}
-function scrollDayView(hour)
-{
+function scrollDayView(hour) {
var rowNumber;
if (hour) {
if (hour.length == 3)
event.returnValue = false;
}
-function calendarDisplayCallback(http)
-{
+function calendarDisplayCallback(http) {
var div = $("calendarView");
// log ("calendardisplaycallback: " + div);
log ("ajax fuckage");
}
-function assignCalendar(name)
-{
- 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);
+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);
+ }
}
-function popupCalendar(node)
-{
- var nodeId = node.getAttribute("inputId");
- var input = $(nodeId);
- input.calendar.popup();
+function popupCalendar(node) {
+ var nodeId = node.getAttribute("inputId");
+ var input = $(nodeId);
+ input.calendar.popup();
- return false;
+ return false;
}
-function onAppointmentContextMenu(event, element)
-{
+function onAppointmentContextMenu(event, element) {
var topNode = $("appointmentsList");
// log(topNode);
element.select();
}
-function onAppointmentContextMenuHide(event)
-{
+function onAppointmentContextMenuHide(event) {
var topNode = $("appointmentsList");
if (topNode.menuSelectedEntry) {
}
function refreshTasks() {
- return _loadTasksHref("taskslist?hide-completed=" + hideCompletedTasks);
+ return _loadTasksHref("taskslist?show-completed=" + showCompletedTasks);
}
-function refreshAppointmentsAndDisplay()
-{
+function refreshAppointmentsAndDisplay() {
refreshAppointments();
changeCalendarDisplay();
}
return refreshAppointments();
}
-function onAppointmentClick(event)
-{
+function onAppointmentClick(event) {
var node = event.target.getParentWithTagName("tr");
var day = node.getAttribute("day");
var hour = node.getAttribute("hour");
return onRowClick(event);
}
-function selectMonthInMenu(menu, month)
-{
+function selectMonthInMenu(menu, month) {
var entries = menu.childNodes[1].childNodesWithTag("LI");
for (i = 0; i < entries.length; i++) {
var entry = entries[i];
}
}
-function selectYearInMenu(menu, month)
-{
+function selectYearInMenu(menu, month) {
var entries = menu.childNodes[1].childNodes;
for (i = 0; i < entries.length; i++) {
var entry = entries[i];
}
}
-function popupMonthMenu(event, menuId)
-{
+function popupMonthMenu(event, menuId) {
var node = event.target;
if (event.button == 0) {
}
}
-function onMonthMenuItemClick(node)
-{
+function onMonthMenuItemClick(node) {
var month = '' + node.getAttribute("month");
var year = '' + $("yearLabel").innerHTML;
}
}
-function changeMonthCalendarDisplayOfSelectedDay(node)
-{
+function changeMonthCalendarDisplayOfSelectedDay(node) {
var daysContainer = node.parentNode;
if (!daysContainer.selectedCell)
findMonthCalendarSelectedCell(daysContainer);
node.addClassName("selectedDay");
}
-function onHideCompletedTasks(node)
-{
- hideCompletedTasks = (node.checked ? 1 : 0);
+function onShowCompletedTasks(node) {
+ showCompletedTasks = (node.checked ? 1 : 0);
return refreshTasks();
}
-function updateTaskStatus(node)
-{
+function updateTaskStatus(node) {
var taskId = node.parentNode.getAttribute("id");
var taskOwner = node.parentNode.getAttribute("owner");
var newStatus = (node.checked ? 1 : 0);
return false;
}
-function updateCalendarStatus()
-{
+function updateCalendarStatus(event) {
var list = new Array();
- var clist = $("calendarsList");
- var nodes = clist.childNodesWithTag("ul")[0].childNodesWithTag("li");
+ var nodes = $("calendarList").childNodesWithTag("li");
for (var i = 0; i < nodes.length; i++) {
var input = nodes[i].childNodesWithTag("input")[0];
- if (input.checked)
- list.push(nodes[i].getAttribute("uid"));
+ 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);
+ }
}
if (!list.length) {
- list.push(nodes[0].getAttribute("uid"));
- nodes[0].childNodesWithTag("input")[0].checked = true;
+ list.push(UserLogin);
+ nodes[0].childNodesWithTag("input")[0].checked = true;
}
// ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
-// + list.join(",") + "/Calendar/");
-
- updateCalendarsList();
- refreshAppointments();
- refreshTasks();
- changeCalendarDisplay();
+// + 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();
+ }
return false;
}
-function calendarUidsList()
-{
- var list = "";
-
- var nodes = $("uixselector-calendarsList-display").childNodesWithTag("li");
- for (var i = 0; i < nodes.length; i++) {
- var currentNode = nodes[i];
- var input = currentNode.childNodesWithTag("input")[0];
- if (!input.checked)
- list += "-";
- list += currentNode.getAttribute("uid") + ",";
- }
-
- return list.substr(0, list.length - 1);
-}
-
-// function updateCalendarContacts(contacts)
-// {
-// var list = contacts.split(",");
-
-// var clist = $("calendarsList");
-// var nodes = clist.childNodes[5].childNodes;
-// for (var i = 0; i < nodes.length; i++) {
-// var currentNode = nodes[i];
-// if (currentNode instanceof HTMLLIElement) {
-// var input = currentNode.childNodes[3];
-// if (!input.checked)
-// list += "-";
-// list += currentNode.getAttribute("uid") + ",";
-// }
-// }
-// }
-
-function inhibitMyCalendarEntry()
-{
- var clist = $("calendarsList");
- var nodes = clist.childNodes[5].childNodes;
- var done = false;
-
- var i = 0;
- while (!done && i < nodes.length) {
- var currentNode = nodes[i];
- if (currentNode instanceof HTMLLIElement) {
- var input = currentNode.childNodes[3];
- if (currentNode.getAttribute("uid") == UserLogin) {
- done = true;
-// currentNode.style.color = "#999;";
- currentNode.style.fontWeight = "bold;";
-// currentNode.setAttribute("onclick", "");
+function calendarStatusCallback(http) {
+ if (http.readyState == 4) {
+ if (http.status == 204) {
+ refreshAppointments();
+ refreshTasks();
+ changeCalendarDisplay();
}
- }
- i++;
- }
-}
-
-function userCalendarEntry(user, color) {
- var li = document.createElement("li");
- li.setAttribute("uid", user);
- li.addEventListener("mousedown", listRowMouseDownHandler, false);
- li.addEventListener("click", onRowClick, false);
- var colorBox = document.createElement("span");
- colorBox.addClassName("colorBox");
- if (color) {
- log("color: " + color);
- colorBox.style.backgroundColor = color + ";";
- }
- li.appendChild(colorBox);
- var checkBox = document.createElement("input");
- checkBox.addClassName("checkBox");
- checkBox.type = "checkbox";
- checkBox.addEventListener("change", updateCalendarStatus, false);
- li.appendChild(checkBox);
- var text = document.createTextNode(" " + user);
- li.appendChild(text);
-
- return li;
-}
-
-function ensureSelfIfPresent() {
- var ul = $("uixselector-calendarsList-display");
- var list = ul.childNodesWithTag("li");
- var selfEntry = userCalendarEntry(UserLogin, indexColor(0));
- selfEntry.style.fontWeight = "bold;";
- if (list.length < 1) {
- ul.appendChild(selfEntry);
- } else if (list[0].getAttribute("uid") != UserLogin) {
- ul.insertBefore(selfEntry, list[0]);
- }
+ else {
+ var folder = $(http.callbackData);
+ var input = folder.childNodesWithTag("input")[0];
+ input.checked = (!input.checked);
+ }
+ }
}
-function updateCalendarsList(method)
-{
- ensureSelfIfPresent();
- var url = (ApplicationBaseURL + "updateCalendars?ids="
- + calendarUidsList());
- if (document.calendarsListAjaxRequest) {
- document.calendarsListAjaxRequest.aborted = true;
- document.calendarsListAjaxRequest.abort();
- }
- var http = createHTTPClient();
- if (http) {
- http.url = url;
- http.open("GET", url, false);
- http.send("");
-
- if (method == "removal")
- updateCalendarStatus();
+function calendarEntryCallback(http) {
+ var disabled = true;
- http = createHTTPClient();
- http.url = ApplicationBaseURL + "checkRights";
- http.open("GET", http.url, false /* not async */);
- http.send("");
- if (http.status == 200
- && http.responseText.length > 0) {
- rights = http.responseText.split(",");
- var list = $("uixselector-calendarsList-display").childNodesWithTag("li");
- for (var i = 0; i < list.length; i++) {
- var input = list[i].childNodesWithTag("input")[0];
- if (rights[i] == "1") {
- list[i].removeClassName("denied");
- input.disabled = false;
- }
- else {
- input.checked = false;
- input.disabled = true;
- list[i].addClassName("denied");
- }
+ 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");
+ }
+}
+
+function updateCalendarsList(method) {
+ 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);
}
}
-function addContact(tag, fullContactName, contactId, contactName, contactEmail)
-{
+function addContact(tag, fullContactName, contactId, contactName, contactEmail) {
var uids = $("uixselector-calendarsList-uidList");
// log("addContact");
if (contactId)
uids.value += ',' + contactId;
else
uids.value = contactId;
- var names = $("uixselector-calendarsList-display");
+ var names = $("calendarList");
var listElems = names.childNodesWithTag("li");
var colorDef = indexColor(listElems.length);
names.appendChild(userCalendarEntry(contactId, colorDef));
- var styles = document.getElementsByTagName("style");
- styles[0].innerHTML += ('.ownerIs' + contactId + ' {'
- + ' background-color: '
- + colorDef
- + ' !important; }');
}
}
return false;
}
-function onChangeCalendar(list) {
- var form = document.forms.editform;
- log ("before: " + form.getAttribute("action"));
- var urlElems = form.getAttribute("action").split("/");
- urlElems[urlElems.length-4]
- = list.childNodesWithTag("option")[list.value].innerHTML;
- form.setAttribute("action", urlElems.join("/"));
- log ("after: " + form.getAttribute("action"));
-}
-
function validateBrowseURL(input) {
var button = $("browseURLBtn");
"appointmentsListMenu", "calendarsMenu", "searchMenu");
initMenusNamed(menus);
- $("calendarsList").attachMenu("calendarsMenu");
+ $("calendarSelector").attachMenu("calendarsMenu");
var accessRightsMenuEntry = $("accessRightsMenuEntry");
accessRightsMenuEntry.addEventListener("mouseup",
}
function onAccessRightsMenuEntryMouseUp(event) {
- var folders = $("uixselector-calendarsList-display");
+ var folders = $("calendarList");
var selected = folders.getSelectedNodes()[0];
- var uid = selected.getAttribute("uid");
- log("application base url: " + ApplicationBaseURL);
- if (uid == UserLogin)
- url = ApplicationBaseURL + "acls";
- else
- url = UserFolderURL + "../" + uid + "/Calendar/acls";
+ var folderID = selected.getAttribute("id");
+ var urlstr = URLForFolderID(folderID) + "/acls";
- openAclWindow(url, uid);
+ openAclWindow(urlstr);
}
function configureDragHandles() {
}
}
-function initCalendarContactsSelector() {
- var selector = $("calendarsList");
- inhibitMyCalendarEntry();
+function initCalendarSelector() {
+ var selector = $("calendarSelector");
updateCalendarStatus();
selector.changeNotification = updateCalendarsList;
- var list = $("uixselector-calendarsList-display").childNodesWithTag("li");
+ var list = $("calendarList").childNodesWithTag("li");
for (var i = 0; i < list.length; i++) {
var input = list[i].childNodesWithTag("input")[0];
input.addEventListener("change", updateCalendarStatus, false);
+ list[i].addEventListener("mousedown", listRowMouseDownHandler, false);
+ list[i].addEventListener("click", onRowClick, false);
+// list[i].addEventListener("contextmenu", onContactFoldersContextMenu, false);
}
+
+ var links = $("calendarSelectorButtons").childNodesWithTag("a");
+ links[0].addEventListener("click", onCalendarAdd, false);
+ links[1].addEventListener("click", onCalendarRemove, false);
+}
+
+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);
+ li.addEventListener("mousedown", listRowMouseDownHandler, false);
+ li.addEventListener("click", onRowClick, false);
+ var checkBox = document.createElement("input");
+ checkBox.addClassName("checkBox");
+ checkBox.type = "checkbox";
+ checkBox.addEventListener("change", updateCalendarStatus, false);
+ li.appendChild(checkBox);
+ li.appendChild(document.createTextNode(" "));
+ 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);
+ li.appendChild(document.createTextNode(" " + folderName));
+
+ calendarList.appendChild(li);
+
+ var contactId = folder.split(":")[0];
+ var styles = document.getElementsByTagName("style");
+
+ var url = URLForFolderID(folder) + "/canAccessContent";
+ triggerAjaxRequest(url, calendarEntryCallback, folder);
+
+ styles[0].innerHTML += ('.ownerIs' + contactId + ' {'
+ + ' background-color: '
+ + color
+ + ' !important; }');
}
-function initCalendars() {
- if (!document.body.hasClassName("popup"))
- initCalendarContactsSelector();
+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 onSchedulerBodyKeyUp(event) {
- if (event.which == 46) {
- window.alert("coucou");
- deleteEvent();
- event.cancelBubble = true;
+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);
+ }
+ }
+
+ event.preventDefault();
+}
+
+function configureSearchField() {
+ var searchValue = $("searchValue");
+
+ searchValue.addEventListener("mousedown", onSearchMouseDown, false);
+ searchValue.addEventListener("click", popupSearchMenu, false);
+ searchValue.addEventListener("blur", onSearchBlur, false);
+ searchValue.addEventListener("focus", onSearchFocus, false);
+ searchValue.addEventListener("keydown", onSearchKeyDown, false);
+}
+
+function initCalendars() {
+ if (!document.body.hasClassName("popup")) {
+ initCalendarSelector();
+ configureSearchField();
}
}
window.addEventListener("load", initCalendars, false);
-// document.body.addEventListener("keyup", onSchedulerBodyKeyUp, false);