2009-07-19 18:41:42 +02:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2007-03-29 20:05:23 +02:00
|
|
|
/* JavaScript for SOGoContacts */
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2008-08-11 17:06:19 +02:00
|
|
|
var cachedContacts = {};
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2007-06-01 22:35:51 +02:00
|
|
|
var usersRightsWindowHeight = 200;
|
2007-04-28 00:06:58 +02:00
|
|
|
var usersRightsWindowWidth = 450;
|
|
|
|
|
2008-08-21 16:35:02 +02:00
|
|
|
var Contact = {
|
2009-07-20 23:06:33 +02:00
|
|
|
currentAddressBook: null,
|
|
|
|
currentContact: null,
|
|
|
|
deleteContactsRequestCount: null
|
2008-08-21 16:35:02 +02:00
|
|
|
};
|
|
|
|
|
2006-08-03 23:28:33 +02:00
|
|
|
function validateEditorInput(sender) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var errortext = "";
|
|
|
|
var field;
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
field = document.pageform.subject;
|
|
|
|
if (field.value == "")
|
|
|
|
errortext = errortext + labels.error_missingsubject + "\n";
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (!hasRecipients())
|
|
|
|
errortext = errortext + labels.error_missingrecipients + "\n";
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (errortext.length > 0) {
|
|
|
|
alert(labels.error_validationfailed + ":\n"
|
|
|
|
+ errortext);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-06-28 22:37:27 +02:00
|
|
|
function openContactsFolder(contactsFolder, reload, idx) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if ((contactsFolder && contactsFolder != Contact.currentAddressBook)
|
|
|
|
|| reload) {
|
|
|
|
Contact.currentAddressBook = contactsFolder;
|
|
|
|
var url = URLForFolderID(Contact.currentAddressBook) +
|
|
|
|
"/view?noframe=1";
|
|
|
|
|
|
|
|
var searchValue = search["value"];
|
|
|
|
if (searchValue && searchValue.length > 0)
|
|
|
|
url += ("&search=" + search["criteria"]
|
|
|
|
+ "&value=" + escape(searchValue.utf8encode()));
|
|
|
|
var sortAttribute = sorting["attribute"];
|
|
|
|
if (sortAttribute && sortAttribute.length > 0)
|
|
|
|
url += ("&sort=" + sorting["attribute"]
|
|
|
|
+ "&asc=" + sorting["ascending"]);
|
|
|
|
|
|
|
|
var selection;
|
|
|
|
if (idx) {
|
|
|
|
selection = [idx];
|
|
|
|
}
|
|
|
|
else if (contactsFolder == Contact.currentAddressBook) {
|
|
|
|
var contactsList = $("contactsList");
|
|
|
|
if (contactsList)
|
|
|
|
selection = contactsList.getSelectedRowsId();
|
|
|
|
// else
|
|
|
|
// window.alert("no contactsList");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
selection = null;
|
|
|
|
|
|
|
|
if (document.contactsListAjaxRequest) {
|
|
|
|
document.contactsListAjaxRequest.aborted = true;
|
|
|
|
document.contactsListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.contactsListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, contactsListCallback, selection);
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function openContactsFolderAtIndex(element) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var idx = element.getAttribute("idx");
|
|
|
|
var url = URLForFolderID(Contact.currentAddressBook) + "/view?noframe=1&idx=" + idx;
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (document.contactsListAjaxRequest) {
|
|
|
|
document.contactsListAjaxRequest.aborted = true;
|
|
|
|
document.contactsListAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
document.contactsListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, contactsListCallback);
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function contactsListCallback(http) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (http.status == 200) {
|
|
|
|
document.contactsListAjaxRequest = null;
|
2008-07-08 13:32:43 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
var div = $("contactsListContent");
|
|
|
|
var table = $("contactsList");
|
|
|
|
if (table) {
|
|
|
|
// Update table
|
|
|
|
var data = http.responseText;
|
|
|
|
var html = data.replace(/^(.*\n)*.*(<table(.*\n)*)$/, "$2");
|
|
|
|
var tbody = table.tBodies[0];
|
|
|
|
var tmp = document.createElement('div');
|
|
|
|
$(tmp).update(html);
|
|
|
|
table.replaceChild($(tmp).select("table tbody")[0], tbody);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Add table
|
|
|
|
div.update(http.responseText);
|
|
|
|
table = $("contactsList");
|
|
|
|
table.multiselect = true;
|
|
|
|
table.observe("mousedown", onContactSelectionChange);
|
|
|
|
configureSortableTableHeaders(table);
|
|
|
|
TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true});
|
|
|
|
configureDraggables();
|
|
|
|
}
|
|
|
|
var rows = table.tBodies[0].rows;
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
var row = $(rows[i]);
|
|
|
|
row.observe("mousedown", onRowClick);
|
|
|
|
row.observe("dblclick", onContactRowDblClick);
|
|
|
|
row.observe("selectstart", listRowMouseDownHandler);
|
|
|
|
row.observe("contextmenu", onContactContextMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sorting["attribute"] && sorting["attribute"].length > 0) {
|
|
|
|
var sortHeader;
|
|
|
|
if (sorting["attribute"] == "c_cn")
|
|
|
|
sortHeader = $("nameHeader");
|
|
|
|
else if (sorting["attribute"] == "c_mail")
|
|
|
|
sortHeader = $("mailHeader");
|
|
|
|
else if (sorting["attribute"] == "c_screenname")
|
|
|
|
sortHeader = $("screenNameHeader");
|
|
|
|
else if (sorting["attribute"] == "c_o")
|
|
|
|
sortHeader = $("orgHeader");
|
|
|
|
else if (sorting["attribute"] == "c_telephonenumber")
|
|
|
|
sortHeader = $("phoneHeader");
|
|
|
|
else
|
|
|
|
sortHeader = null;
|
|
|
|
|
|
|
|
if (sortHeader) {
|
|
|
|
var sortImages = $(table.tHead).select(".sortImage");
|
|
|
|
$(sortImages).each(function(item) {
|
|
|
|
item.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
var sortImage = createElement("img", "messageSortImage", "sortImage");
|
|
|
|
sortHeader.insertBefore(sortImage, sortHeader.firstChild);
|
|
|
|
if (sorting["ascending"])
|
|
|
|
sortImage.src = ResourcesURL + "/title_sortdown_12x12.png";
|
|
|
|
else
|
|
|
|
sortImage.src = ResourcesURL + "/title_sortup_12x12.png";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var selected = http.callbackData;
|
|
|
|
if (selected) {
|
|
|
|
for (var i = 0; i < selected.length; i++) {
|
|
|
|
var row = $(selected[i]);
|
|
|
|
if (row) {
|
|
|
|
var rowPosition = row.rowIndex * row.getHeight();
|
|
|
|
if (div.getHeight() < rowPosition)
|
|
|
|
div.scrollTop = rowPosition; // scroll to selected contact
|
|
|
|
row.selectElement();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var table = $("contactsList");
|
|
|
|
if (table) {
|
|
|
|
var sortImages = $(table.tHead).select(".sortImage");
|
|
|
|
$(sortImages).each(function(item) {
|
|
|
|
item.remove();
|
|
|
|
});
|
|
|
|
var tBody = $(table.tBodies[0]);
|
|
|
|
var length = tBody.rows.length;
|
|
|
|
for (var i = length - 1; i > -1; i--)
|
|
|
|
tBody.removeChild(tBody.rows[i]);
|
|
|
|
}
|
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
else
|
|
|
|
log ("ajax problem 1: status = " + http.status);
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2008-03-25 20:59:13 +01:00
|
|
|
function onContactContextMenu(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactsList = $("contactsList");
|
|
|
|
var menu = $("contactMenu");
|
|
|
|
menu.observe("hideMenu", onContactContextMenuHide);
|
|
|
|
if (contactsList)
|
|
|
|
popupMenu(event, "contactMenu", contactsList.getSelectedRows());
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onContactContextMenuHide(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var topNode = $("contactsList");
|
2006-11-03 20:40:12 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (topNode.menuSelectedEntry) {
|
|
|
|
$(topNode.menuSelectedEntry).deselect();
|
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
|
|
|
if (topNode.menuSelectedRows) {
|
|
|
|
var nodes = topNode.menuSelectedRows;
|
|
|
|
for (var i = 0; i < nodes.length; i++)
|
|
|
|
$(nodes[i]).selectElement();
|
|
|
|
topNode.menuSelectedRows = null;
|
|
|
|
}
|
2006-11-03 20:40:12 +01:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onFolderMenuHide(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var topNode = $('d');
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (topNode.menuSelectedEntry) {
|
|
|
|
topNode.menuSelectedEntry.deselect();
|
|
|
|
topNode.menuSelectedEntry = null;
|
|
|
|
}
|
|
|
|
if (topNode.selectedEntry)
|
|
|
|
topNode.selectedEntry.selectElement();
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2008-07-09 19:11:18 +02:00
|
|
|
function _onContactMenuAction(folderItem, action, refresh) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var selectedFolders = $("contactFolders").getSelectedNodes();
|
2009-09-02 15:24:02 +02:00
|
|
|
var folderId = $(folderItem).readAttribute("folderId");
|
|
|
|
if (folderId)
|
|
|
|
folderId = folderId.substring (1);
|
2009-07-20 23:06:33 +02:00
|
|
|
if (Object.isArray(document.menuTarget) && selectedFolders.length > 0) {
|
|
|
|
var selectedFolderId = $(selectedFolders[0]).readAttribute("id");
|
|
|
|
var contactIds = $(document.menuTarget).collect(function(row) {
|
|
|
|
return row.getAttribute("id");
|
|
|
|
});
|
|
|
|
|
2009-08-25 15:12:14 +02:00
|
|
|
for (var i = 0; i < contactIds.length; i++) {
|
|
|
|
if (contactIds[i].endsWith ("vlf")) {
|
|
|
|
alert (labels["Lists can't be moved or copied."]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
var url = ApplicationBaseURL + selectedFolderId + "/" + action
|
|
|
|
+ "?folder=" + folderId + "&uid="
|
|
|
|
+ contactIds.join("&uid=");
|
2008-07-09 19:11:18 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (refresh)
|
|
|
|
triggerAjaxRequest(url, actionContactCallback, selectedFolderId);
|
|
|
|
else
|
|
|
|
triggerAjaxRequest(url, actionContactCallback);
|
|
|
|
}
|
2008-07-09 19:11:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onContactMenuCopy(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
_onContactMenuAction(this, "copy", false);
|
2008-07-09 19:11:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onContactMenuMove(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
_onContactMenuAction(this, "move", true);
|
2008-07-09 19:11:18 +02:00
|
|
|
}
|
|
|
|
|
2009-09-02 15:24:02 +02:00
|
|
|
function onMenuExportContact (event) {
|
|
|
|
var selectedFolders = $("contactFolders").getSelectedNodes();
|
|
|
|
var selectedFolderId = $(selectedFolders[0]).readAttribute("id");
|
|
|
|
if (selectedFolderId != "/shared") {
|
|
|
|
var contactIds = $(document.menuTarget).collect(function(row) {
|
|
|
|
return row.getAttribute("id");
|
|
|
|
});
|
|
|
|
var url = ApplicationBaseURL + selectedFolderId + "/export"
|
|
|
|
+ "?uid=" + contactIds.join("&uid=");
|
|
|
|
window.location.href = url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-09 19:11:18 +02:00
|
|
|
function actionContactCallback(http) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if (http.readyState == 4)
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var refreshFolderId = http.callbackData;
|
|
|
|
if (refreshFolderId)
|
|
|
|
openContactsFolder(refreshFolderId, true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var html = new Element("div").update(http.responseText);
|
|
|
|
var error = html.select("p").first().firstChild.nodeValue.trim();
|
|
|
|
log("actionContactCallback failed: error " + http.status + " (" + error + ")");
|
|
|
|
if (parseInt(http.status) == 403)
|
|
|
|
window.alert(clabels["You don't have the required privileges to perform the operation."]);
|
|
|
|
else if (error)
|
|
|
|
window.alert(labels[error]);
|
|
|
|
refreshCurrentFolder();
|
|
|
|
}
|
2008-07-09 19:11:18 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function loadContact(idx) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if (document.contactAjaxRequest) {
|
|
|
|
document.contactAjaxRequest.aborted = true;
|
|
|
|
document.contactAjaxRequest.abort();
|
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (cachedContacts[Contact.currentAddressBook + "/" + idx]) {
|
|
|
|
var div = $('contactView');
|
|
|
|
Contact.currentContact = idx;
|
|
|
|
div.innerHTML = cachedContacts[Contact.currentAddressBook + "/" + idx];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var url = (URLForFolderID(Contact.currentAddressBook)
|
|
|
|
+ "/" + idx + "/view?noframe=1");
|
|
|
|
document.contactAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, contactLoadCallback, idx);
|
|
|
|
}
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function contactLoadCallback(http) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var div = $('contactView');
|
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 200) {
|
|
|
|
document.contactAjaxRequest = null;
|
|
|
|
var content = http.responseText;
|
|
|
|
cachedContacts[Contact.currentAddressBook + "/" + http.callbackData] = content;
|
|
|
|
Contact.currentContact = http.callbackData;
|
|
|
|
div.innerHTML = content;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
log ("ajax problem 2: " + http.status);
|
|
|
|
refreshCurrentFolder();
|
|
|
|
}
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var rowSelectionCount = 0;
|
|
|
|
|
|
|
|
validateControls();
|
|
|
|
|
|
|
|
function showElement(e, shouldShow) {
|
2009-07-20 23:06:33 +02:00
|
|
|
e.style.display = shouldShow ? "" : "none";
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function enableElement(e, shouldEnable) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if(!e)
|
|
|
|
return;
|
|
|
|
if(shouldEnable) {
|
|
|
|
if(e.hasAttribute("disabled"))
|
|
|
|
e.removeAttribute("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
e.setAttribute("disabled", "1");
|
|
|
|
}
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function validateControls() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var e = $("moveto");
|
|
|
|
this.enableElement(e, rowSelectionCount > 0);
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function moveTo(uri) {
|
2009-07-20 23:06:33 +02:00
|
|
|
alert("MoveTo: " + uri);
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* contact menu entries */
|
2008-03-25 20:59:13 +01:00
|
|
|
function onContactRowDblClick(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var cname = this.getAttribute('id');
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
openContactWindow(URLForFolderID(Contact.currentAddressBook)
|
|
|
|
+ "/" + cname + "/edit", cname);
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return false;
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2008-03-25 20:59:13 +01:00
|
|
|
function onContactSelectionChange(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var rows = this.getSelectedRowsId();
|
2008-03-25 20:59:13 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (rows.length == 1) {
|
|
|
|
var node = $(rows[0]);
|
|
|
|
loadContact(node.getAttribute('id'));
|
|
|
|
}
|
|
|
|
else if (rows.length > 1) {
|
|
|
|
$('contactView').update();
|
|
|
|
Contact.currentContact = null;
|
|
|
|
}
|
2008-03-25 20:59:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:54:46 +02:00
|
|
|
function onMenuEditContact(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
onToolbarEditSelectedContacts(event);
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:54:46 +02:00
|
|
|
function onMenuWriteToContact(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
onToolbarWriteToSelectedContacts(event);
|
2007-09-14 20:20:51 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (document.body.hasClassName("popup"))
|
|
|
|
window.close();
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2008-02-08 00:09:16 +01:00
|
|
|
function onMenuAIMContact(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactRow = $(document.menuTarget.getAttribute('id'));
|
|
|
|
var aimCell = contactRow.down('td', 2);
|
2008-02-08 00:09:16 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
window.location.href = "aim:goim?ScreenName=" + aimCell.firstChild.nodeValue;
|
2008-02-08 00:09:16 +01:00
|
|
|
}
|
|
|
|
|
2007-05-22 16:54:46 +02:00
|
|
|
function onMenuDeleteContact(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
onToolbarDeleteSelectedContacts(event);
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onToolbarEditSelectedContacts(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactsList = $('contactsList');
|
|
|
|
var rows = contactsList.getSelectedRowsId();
|
2006-08-19 00:40:04 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (rows.length == 0) {
|
|
|
|
window.alert(labels["Please select a contact."]);
|
|
|
|
return false;
|
|
|
|
}
|
2007-12-03 15:13:10 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
openContactWindow(URLForFolderID(Contact.currentAddressBook)
|
|
|
|
+ "/" + rows[i] + "/edit", rows[i]);
|
|
|
|
}
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return false;
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onToolbarWriteToSelectedContacts(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactsList = $('contactsList');
|
|
|
|
var rows = contactsList.getSelectedRowsId();
|
|
|
|
var rowsWithEmail = 0;
|
2007-11-06 23:34:42 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (rows.length == 0) {
|
|
|
|
openMailComposeWindow(ApplicationBaseURL + "Mail/compose");
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
openMailComposeWindow(ApplicationBaseURL + "../Mail/compose"
|
|
|
|
+ "?folder=" + Contact.currentAddressBook.substring(1)
|
|
|
|
+ "&uid=" + rows.join("&uid="));
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (document.body.hasClassName("popup"))
|
|
|
|
window.close();
|
2008-07-08 13:32:43 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return false;
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2008-07-08 13:32:43 +02:00
|
|
|
function onToolbarDeleteSelectedContacts(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactsList = $('contactsList');
|
|
|
|
var rows = contactsList.getSelectedRowsId();
|
|
|
|
|
|
|
|
if (rows.length) {
|
|
|
|
var label = labels["Are you sure you want to delete the selected contacts?"];
|
|
|
|
if (window.confirm(label)) {
|
|
|
|
for (var i = 0; i < rows.length; i++) {
|
|
|
|
delete cachedContacts[Contact.currentAddressBook + "/" + rows[i]];
|
|
|
|
var urlstr = (URLForFolderID(Contact.currentAddressBook) + "/"
|
|
|
|
+ rows[i] + "/delete");
|
|
|
|
Contact.deleteContactsRequestCount++;
|
|
|
|
triggerAjaxRequest(urlstr, onContactDeleteEventCallback,
|
|
|
|
rows[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.alert(labels["Please select a contact."]);
|
2008-08-11 17:06:19 +02:00
|
|
|
}
|
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return false;
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2008-08-11 17:06:19 +02:00
|
|
|
function onContactDeleteEventCallback(http) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var row = $(http.callbackData);
|
|
|
|
if (Contact.currentContact == http.callbackData) {
|
|
|
|
$("contactView").update();
|
|
|
|
Contact.currentContact = null;
|
|
|
|
}
|
|
|
|
Contact.deleteContactsRequestCount--;
|
|
|
|
if (Contact.deleteContactsRequestCount == 0) {
|
|
|
|
var nextRow = row.next("tr");
|
|
|
|
if (!nextRow)
|
|
|
|
nextRow = row.previous("tr");
|
|
|
|
if (nextRow) {
|
|
|
|
Contact.currentContact = nextRow.getAttribute("id");
|
|
|
|
nextRow.selectElement();
|
|
|
|
loadContact(Contact.currentContact);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
row.parentNode.removeChild(row);
|
|
|
|
}
|
|
|
|
else if (parseInt(http.status) == 403) {
|
|
|
|
var row = $(http.callbackData);
|
|
|
|
var displayName = row.down("TD.displayName").firstChild.nodeValue.trim();
|
|
|
|
Contact.deleteContactsRequestCount--;
|
|
|
|
window.alert(labels["You cannot delete the card of \"%{0}\"."].formatted(displayName));
|
|
|
|
}
|
2008-08-09 20:27:38 +02:00
|
|
|
}
|
2008-08-11 17:06:19 +02:00
|
|
|
}
|
|
|
|
|
2006-08-03 23:28:33 +02:00
|
|
|
function newEmailTo(sender) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var mailto = sanitizeMailTo(sender.parentNode.parentNode.menuTarget.innerHTML);
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
if (mailto.length > 0)
|
|
|
|
openMailComposeWindow("compose?mailto=" + mailto);
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return false; /* stop following the link */
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function onHeaderClick(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var headerId = this.getAttribute("id");
|
|
|
|
var newSortAttribute;
|
|
|
|
if (headerId == "nameHeader")
|
|
|
|
newSortAttribute = "c_cn";
|
|
|
|
else if (headerId == "mailHeader")
|
|
|
|
newSortAttribute = "c_mail";
|
|
|
|
else if (headerId == "screenNameHeader")
|
|
|
|
newSortAttribute = "c_screenname";
|
|
|
|
else if (headerId == "orgHeader")
|
|
|
|
newSortAttribute = "c_o";
|
|
|
|
else if (headerId == "phoneHeader")
|
|
|
|
newSortAttribute = "c_telephonenumber";
|
|
|
|
|
|
|
|
if (sorting["attribute"] == newSortAttribute)
|
|
|
|
sorting["ascending"] = !sorting["ascending"];
|
|
|
|
else {
|
|
|
|
sorting["attribute"] = newSortAttribute;
|
|
|
|
sorting["ascending"] = true;
|
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
refreshCurrentFolder();
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
Event.stop(event);
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function newContact(sender) {
|
2009-07-20 23:06:33 +02:00
|
|
|
openContactWindow(URLForFolderID(Contact.currentAddressBook) + "/newcontact");
|
2006-08-03 23:28:33 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return false; /* stop following the link */
|
2006-08-03 23:28:33 +02:00
|
|
|
}
|
2006-08-09 23:36:35 +02:00
|
|
|
|
2009-08-24 22:26:52 +02:00
|
|
|
function newList(sender) {
|
2009-09-11 21:49:31 +02:00
|
|
|
var li = $(Contact.currentAddressBook);
|
|
|
|
if (!li.hasClassName ("remote"))
|
|
|
|
openContactWindow(URLForFolderID(Contact.currentAddressBook) + "/newlist");
|
2009-08-24 22:26:52 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-12-17 18:19:10 +01:00
|
|
|
function onFolderSelectionChange(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var folderList = $("contactFolders");
|
|
|
|
var nodes = folderList.getSelectedNodes();
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
var node = getTarget(event);
|
|
|
|
if (node.tagName == 'UL')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$("contactView").update();
|
|
|
|
Contact.currentContact = null;
|
|
|
|
|
|
|
|
if (nodes[0].hasClassName("denied")) {
|
|
|
|
var div = $("contactsListContent");
|
|
|
|
div.update();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
search = {};
|
|
|
|
$("searchValue").value = "";
|
|
|
|
initCriteria();
|
|
|
|
openContactsFolder(nodes[0].getAttribute("id"));
|
|
|
|
}
|
2006-08-09 23:36:35 +02:00
|
|
|
}
|
|
|
|
|
2007-08-15 00:09:20 +02:00
|
|
|
function refreshCurrentFolder() {
|
2009-07-20 23:06:33 +02:00
|
|
|
openContactsFolder(Contact.currentAddressBook, true);
|
2006-08-09 23:36:35 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function onConfirmContactSelection(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var tag = this.getAttribute("name");
|
|
|
|
var folderLi = $(Contact.currentAddressBook);
|
|
|
|
var currentAddressBookName = folderLi.innerHTML;
|
|
|
|
var selectorList = null;
|
|
|
|
var initialValues = null;
|
2008-09-09 21:01:38 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactsList = $("contactsList");
|
|
|
|
var rows = contactsList.getSelectedRows();
|
|
|
|
for (i = 0; i < rows.length; i++) {
|
|
|
|
var cid = rows[i].getAttribute("id");
|
2009-09-10 23:00:38 +02:00
|
|
|
if (cid.endsWith (".vlf")) {
|
|
|
|
addListToOpener (tag, Contact.currentAddressBook,
|
|
|
|
currentAddressBookName, cid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var cname = '' + rows[i].getAttribute("contactname");
|
|
|
|
var email = '' + rows[i].cells[1].innerHTML;
|
2008-09-09 21:01:38 +02:00
|
|
|
|
2009-09-10 23:00:38 +02:00
|
|
|
window.opener.addContact(tag, currentAddressBookName + '/' + cname,
|
|
|
|
cid, cname, email);
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
preventDefault(event);
|
2006-11-01 21:33:03 +01:00
|
|
|
}
|
|
|
|
|
2009-09-10 23:00:38 +02:00
|
|
|
function addListToOpener (tag, aBookId, aBookName, listId) {
|
|
|
|
var url = ApplicationBaseURL + "/" + aBookId + "/" + listId + "/properties";
|
|
|
|
triggerAjaxRequest (url, addListToOpenerCallback, {
|
|
|
|
"aBookId": aBookId,
|
|
|
|
"aBookName": aBookName,
|
|
|
|
"tag": tag
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function addListToOpenerCallback (http) {
|
|
|
|
var data = http.callbackData;
|
|
|
|
var received = http.responseText.evalJSON (true);
|
|
|
|
for (var i = 0; i < received.length; i++) {
|
|
|
|
var contact = received[i];
|
|
|
|
window.opener.addContact(data.tag, data.aBookName + '/' + contact[1],
|
|
|
|
contact[0], contact[1], contact[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-06 21:09:56 +01:00
|
|
|
function refreshContacts(cname) {
|
2009-07-20 23:06:33 +02:00
|
|
|
openContactsFolder(Contact.currentAddressBook, true, cname);
|
|
|
|
delete cachedContacts[Contact.currentAddressBook + "/" + cname];
|
|
|
|
loadContact(cname);
|
2006-09-19 15:50:19 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return false;
|
2006-09-19 15:50:19 +02:00
|
|
|
}
|
2006-11-01 21:33:03 +01:00
|
|
|
|
2007-02-09 22:25:13 +01:00
|
|
|
function onAddressBookNew(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
createFolder(window.prompt(labels["Name of the Address Book"], ""),
|
|
|
|
appendAddressBook);
|
|
|
|
preventDefault(event);
|
2007-02-09 22:25:13 +01:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function appendAddressBook(name, folder) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var owner;
|
|
|
|
var result = true;
|
|
|
|
|
|
|
|
if (folder) {
|
|
|
|
owner = getSubscribedFolderOwner(folder);
|
|
|
|
folder = accessToSubscribedFolder(folder);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
folder = "/" + name;
|
|
|
|
|
|
|
|
if (!owner)
|
|
|
|
owner = UserLogin;
|
|
|
|
|
|
|
|
if ($(folder))
|
|
|
|
result = false;
|
|
|
|
else {
|
|
|
|
var contactFolders = $("contactFolders");
|
|
|
|
var items = contactFolders.childNodesWithTag("li");
|
|
|
|
var li = document.createElement("li");
|
|
|
|
li = Element.extend(li);
|
|
|
|
|
|
|
|
// Add the calendar to the proper place
|
|
|
|
var i = getListIndexForFolder(items, owner, name);
|
|
|
|
if (i != items.length) // User is subscribed to other calendars of the same owner
|
|
|
|
contactFolders.insertBefore(li, items[i]);
|
|
|
|
else
|
|
|
|
contactFolders.appendChild(li);
|
|
|
|
|
|
|
|
li.setAttribute("id", folder);
|
|
|
|
li.setAttribute("owner", owner);
|
|
|
|
li.addClassName("local");
|
|
|
|
li.appendChild(document.createTextNode(name
|
|
|
|
.replace("<", "<", "g")
|
|
|
|
.replace(">", ">", "g")));
|
|
|
|
setEventsOnAddressBook(li);
|
|
|
|
updateAddressBooksMenus();
|
|
|
|
configureDroppables();
|
|
|
|
}
|
2007-12-17 16:34:01 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return result;
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function newUserFolderCallback(folderData) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var folder = $(folderData["folder"]);
|
|
|
|
if (!folder)
|
|
|
|
appendAddressBook(folderData["folderName"], folderData["folder"]);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2007-02-09 22:25:13 +01:00
|
|
|
function onAddressBookAdd(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
openUserFolderSelector(newUserFolderCallback, "contact");
|
2006-11-01 21:33:03 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
preventDefault(event);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onFolderUnsubscribeCB(folderId) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var node = $(folderId);
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
var personal = $("/personal");
|
|
|
|
personal.selectElement();
|
|
|
|
onFolderSelectionChange();
|
2006-11-01 21:33:03 +01:00
|
|
|
}
|
|
|
|
|
2009-09-03 16:18:13 +02:00
|
|
|
function onAddressBookImport(event) {
|
|
|
|
var node = $("contactFolders").getSelectedNodes().first();
|
|
|
|
var folderId = node.getAttribute("id");
|
|
|
|
|
|
|
|
var url = ApplicationBaseURL + folderId + "/import";
|
|
|
|
$("uploadForm").action = url;
|
|
|
|
$("uploadCancel").onclick = hideContactsImport;
|
|
|
|
$("contactsFile").value = "";
|
|
|
|
|
|
|
|
var cellPosition = node.cumulativeOffset();
|
|
|
|
var cellDimensions = node.getDimensions();
|
|
|
|
var left = cellDimensions['width'] - 20;
|
|
|
|
var top = cellPosition[1];
|
|
|
|
|
|
|
|
var div = $("uploadDialog");
|
2009-09-03 19:53:38 +02:00
|
|
|
var res = $("uploadResults");
|
2009-09-03 16:18:13 +02:00
|
|
|
div.style.top = top + "px";
|
2009-09-03 19:53:38 +02:00
|
|
|
res.style.top = top + "px";
|
2009-09-03 16:18:13 +02:00
|
|
|
div.style.left = left + "px";
|
2009-09-03 19:53:38 +02:00
|
|
|
res.style.left = left + "px";
|
2009-09-03 16:18:13 +02:00
|
|
|
div.style.display = "block";
|
|
|
|
}
|
|
|
|
function hideContactsImport () {
|
|
|
|
$("uploadDialog").style.display = "none";
|
|
|
|
}
|
2009-09-03 19:53:38 +02:00
|
|
|
function hideImportResults () {
|
|
|
|
$("uploadResults").style.display = "none";
|
|
|
|
}
|
2009-09-03 16:18:13 +02:00
|
|
|
function validateUploadForm () {
|
|
|
|
rc = false;
|
|
|
|
if ($("contactsFile").value.length)
|
|
|
|
rc = true;
|
|
|
|
return rc;
|
|
|
|
}
|
2009-09-03 19:53:38 +02:00
|
|
|
function uploadCompleted (response) {
|
|
|
|
data = response.evalJSON (true);
|
|
|
|
|
|
|
|
var div = $("uploadResults");
|
|
|
|
$("uploadOK").onclick = hideImportResults;
|
2009-09-03 20:37:08 +02:00
|
|
|
if (data.imported <= 0)
|
|
|
|
$("uploadResultsContent").update (labels["An error occured while importing contacts."]);
|
|
|
|
else {
|
|
|
|
$("uploadResultsContent").update (labels["Imported contacts:"] + " " + data.imported);
|
|
|
|
refreshCurrentFolder ();
|
|
|
|
}
|
2009-09-03 19:53:38 +02:00
|
|
|
|
|
|
|
hideContactsImport ();
|
|
|
|
$("uploadResults").style.display = "block";
|
|
|
|
}
|
2009-09-03 16:18:13 +02:00
|
|
|
|
2007-02-09 22:25:13 +01:00
|
|
|
function onAddressBookRemove(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var selector = $("contactFolders");
|
|
|
|
var nodes = selector.getSelectedNodes();
|
|
|
|
if (nodes.length > 0) {
|
|
|
|
var node = $(nodes[0]);
|
|
|
|
node.deselect();
|
|
|
|
var owner = node.getAttribute("owner");
|
|
|
|
if (owner == "nobody") {
|
|
|
|
var label = labels["You cannot remove nor unsubscribe from a public addressbook."];
|
|
|
|
window.alert(label);
|
|
|
|
}
|
|
|
|
else if (owner == UserLogin) {
|
|
|
|
var folderIdElements = node.getAttribute("id").split(":");
|
|
|
|
var abId = folderIdElements[0].substr(1);
|
|
|
|
deletePersonalAddressBook(abId);
|
|
|
|
var personal = $("/personal");
|
|
|
|
personal.selectElement();
|
|
|
|
onFolderSelectionChange();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var folderId = node.getAttribute("id");
|
2009-09-04 21:08:21 +02:00
|
|
|
var folderUrl = ApplicationBaseURL + folderId;
|
|
|
|
unsubscribeFromFolder(folderUrl, owner, onFolderUnsubscribeCB, folderId);
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
2008-08-26 02:22:18 +02:00
|
|
|
}
|
2008-03-28 14:56:07 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
preventDefault(event);
|
2006-11-01 21:33:03 +01:00
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
|
2007-03-21 15:29:09 +01:00
|
|
|
function deletePersonalAddressBook(folderId) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if (folderId == "personal") {
|
|
|
|
var label = labels["You cannot remove nor unsubscribe from your personal addressbook."];
|
|
|
|
window.alert(label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var label
|
|
|
|
= labels["Are you sure you want to delete the selected address book?"];
|
|
|
|
if (window.confirm(label)) {
|
|
|
|
if (document.deletePersonalABAjaxRequest) {
|
|
|
|
document.deletePersonalABAjaxRequest.aborted = true;
|
|
|
|
document.deletePersonalABAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var url = ApplicationBaseURL + folderId + "/delete";
|
|
|
|
document.deletePersonalABAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, deletePersonalAddressBookCallback,
|
|
|
|
folderId);
|
|
|
|
}
|
|
|
|
}
|
2007-03-21 15:29:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function deletePersonalAddressBookCallback(http) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var ul = $("contactFolders");
|
2007-03-21 15:29:09 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
var children = ul.childNodesWithTag("li");
|
|
|
|
var i = 0;
|
|
|
|
var done = false;
|
|
|
|
while (!done && i < children.length) {
|
|
|
|
var currentFolderId = children[i].getAttribute("id").substr(1);
|
|
|
|
if (currentFolderId == http.callbackData) {
|
|
|
|
ul.removeChild(children[i]);
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.deletePersonalABAjaxRequest = null;
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
else
|
|
|
|
log ("ajax problem 5: " + http.status);
|
2007-03-21 15:29:09 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureDragHandles() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var handle = $("dragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.leftBlock = $("contactFoldersList");
|
|
|
|
handle.rightBlock = $("rightPanel");
|
|
|
|
handle.leftMargin = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle) {
|
|
|
|
handle.addInterface(SOGoDragHandlesInterface);
|
|
|
|
handle.upperBlock = $("contactsListContent");
|
|
|
|
handle.lowerBlock = $("contactView");
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2006-12-20 23:53:58 +01:00
|
|
|
function lookupDeniedFolders() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var list = $("contactFolders").childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
var folderID = list[i].getAttribute("id");
|
|
|
|
var url = URLForFolderID(folderID) + "/canAccessContent";
|
|
|
|
triggerAjaxRequest(url, deniedFoldersLookupCallback, folderID);
|
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function deniedFoldersLookupCallback(http) {
|
2009-07-20 23:06:33 +02:00
|
|
|
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 23:53:58 +01:00
|
|
|
}
|
|
|
|
|
2007-02-09 22:25:13 +01:00
|
|
|
function configureAbToolbar() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var toolbar = $("abToolbar");
|
|
|
|
if (toolbar) {
|
|
|
|
var links = toolbar.childNodesWithTag("a");
|
|
|
|
$(links[0]).observe("click", onAddressBookNew);
|
|
|
|
$(links[1]).observe("click", onAddressBookAdd);
|
|
|
|
$(links[2]).observe("click", onAddressBookRemove);
|
|
|
|
}
|
2007-02-09 22:25:13 +01:00
|
|
|
}
|
|
|
|
|
2008-04-15 21:48:48 +02:00
|
|
|
function configureAddressBooks() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactFolders = $("contactFolders");
|
|
|
|
if (contactFolders) {
|
|
|
|
contactFolders.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
contactFolders.observe("click", onFolderSelectionChange);
|
|
|
|
contactFolders.attachMenu("contactFoldersMenu");
|
|
|
|
var lis = contactFolders.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < lis.length; i++)
|
|
|
|
setEventsOnAddressBook(lis[i]);
|
2008-03-25 20:59:13 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
lookupDeniedFolders();
|
|
|
|
configureDroppables();
|
|
|
|
|
|
|
|
var personalFolder = $("/personal");
|
|
|
|
personalFolder.selectElement();
|
|
|
|
openContactsFolder("/personal");
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2008-07-09 19:11:18 +02:00
|
|
|
function onAddressBookMenuPrepareVisibility() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var selectedFolder = $("contactFolders").getSelectedNodes()[0];
|
|
|
|
if (selectedFolder) {
|
|
|
|
var selectedFolderId = selectedFolder.readAttribute("id");
|
|
|
|
$(this).select("li").each(function(menuEntry) {
|
|
|
|
if (menuEntry.readAttribute("folderId") == selectedFolderId)
|
|
|
|
menuEntry.addClassName("disabled");
|
|
|
|
else
|
|
|
|
menuEntry.removeClassName("disabled");
|
|
|
|
});
|
|
|
|
}
|
2009-06-29 21:08:29 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return true;
|
2008-07-09 19:11:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateAddressBooksMenus() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactFoldersList = $("contactFolders");
|
|
|
|
if (contactFoldersList) {
|
|
|
|
var pageContent = $("pageContent");
|
|
|
|
var contactFolders = contactFoldersList.select("li");
|
|
|
|
var contactActions = new Hash({ move: onContactMenuMove,
|
|
|
|
copy: onContactMenuCopy });
|
|
|
|
var actions = contactActions.keys();
|
|
|
|
for (var j = 0; j < actions.size(); j++) {
|
|
|
|
var key = actions[j];
|
|
|
|
var callbacks = new Array();
|
|
|
|
var menuId = key + "ContactMenu";
|
|
|
|
var menuDIV = $(menuId);
|
|
|
|
if (menuDIV)
|
|
|
|
menuDIV.parentNode.removeChild(menuDIV);
|
2008-07-09 19:11:18 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
menuDIV = document.createElement("div");
|
|
|
|
pageContent.appendChild(menuDIV);
|
2008-07-09 19:11:18 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
var menu = document.createElement("ul");
|
|
|
|
menuDIV.appendChild(menu);
|
2008-07-09 19:11:18 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
$(menuDIV).addClassName("menu");
|
|
|
|
menuDIV.setAttribute("id", menuId);
|
2008-07-09 19:11:18 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
var submenuIds = new Array();
|
|
|
|
for (var i = 0; i < contactFolders.length; i++) {
|
|
|
|
if (contactFolders[i].hasClassName("local")) {
|
|
|
|
var menuEntry = new Element("li",
|
|
|
|
{ folderId: contactFolders[i].readAttribute("id"),
|
|
|
|
owner: contactFolders[i].readAttribute("owner") }
|
|
|
|
).update(contactFolders[i].innerHTML);
|
|
|
|
menu.appendChild(menuEntry);
|
|
|
|
callbacks.push(contactActions.get(key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menuDIV.prepareVisibility = onAddressBookMenuPrepareVisibility;
|
|
|
|
initMenu(menuDIV, callbacks);
|
|
|
|
}
|
|
|
|
}
|
2008-07-09 19:11:18 +02:00
|
|
|
}
|
|
|
|
|
2008-04-15 21:48:48 +02:00
|
|
|
function setEventsOnAddressBook(folder) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var node = $(folder);
|
2007-05-25 16:30:56 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
node.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
node.observe("click", onRowClick);
|
|
|
|
node.observe("dblclick", onAddressBookModify);
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
|
2008-04-15 21:48:48 +02:00
|
|
|
function onAddressBookModify(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var folders = $("contactFolders");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
|
|
|
|
|
|
|
if (UserLogin == selected.getAttribute("owner")) {
|
|
|
|
var currentName = selected.innerHTML;
|
|
|
|
var newName = window.prompt(labels["Address Book Name"],
|
|
|
|
currentName);
|
|
|
|
if (newName && newName.length > 0
|
|
|
|
&& newName != currentName) {
|
|
|
|
var url = (URLForFolderID(selected.getAttribute("id"))
|
|
|
|
+ "/renameFolder?name=" + escape(newName.utf8encode()));
|
|
|
|
triggerAjaxRequest(url, folderRenameCallback,
|
|
|
|
{node: selected, name: newName});
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
window.alert(clabels["Unable to rename that folder!"]);
|
2008-02-04 23:22:14 +01:00
|
|
|
}
|
|
|
|
|
2008-03-25 20:59:13 +01:00
|
|
|
function folderRenameCallback(http) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var dict = http.callbackData;
|
|
|
|
dict["node"].innerHTML = dict["name"];
|
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2008-02-01 19:44:58 +01:00
|
|
|
}
|
|
|
|
|
2007-05-19 03:12:23 +02:00
|
|
|
function onMenuSharing(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if ($(this).hasClassName("disabled"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
var folders = $("contactFolders");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
|
|
|
var owner = selected.getAttribute("owner");
|
|
|
|
if (owner == "nobody")
|
|
|
|
window.alert(clabels["The user rights cannot be"
|
|
|
|
+ " edited for this object!"]);
|
|
|
|
else {
|
|
|
|
var title = this.innerHTML;
|
|
|
|
var url = URLForFolderID(selected.getAttribute("id"));
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
openAclWindow(url + "/acls", title);
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2008-04-15 21:48:48 +02:00
|
|
|
function onAddressBooksMenuPrepareVisibility() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var folders = $("contactFolders");
|
|
|
|
var selected = folders.getSelectedNodes();
|
|
|
|
|
|
|
|
if (selected.length > 0) {
|
|
|
|
var folderOwner = selected[0].getAttribute("owner");
|
|
|
|
|
|
|
|
var menu = $("contactFoldersMenu").down("ul");;
|
|
|
|
var listElements = menu.childNodesWithTag("li");
|
|
|
|
var modifyOption = $(listElements[0]);
|
|
|
|
var removeOption = $(listElements[5]);
|
|
|
|
var sharingOption = $(listElements[listElements.length - 1]);
|
|
|
|
|
|
|
|
// Disable the "Sharing" and "Modify" options when address book
|
|
|
|
// is not owned by user
|
|
|
|
if (folderOwner == UserLogin || IsSuperUser) {
|
|
|
|
modifyOption.removeClassName("disabled");
|
|
|
|
sharingOption.removeClassName("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
modifyOption.addClassName("disabled");
|
|
|
|
sharingOption.addClassName("disabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable the "remove" option when address book is public
|
|
|
|
if (folderOwner == "nobody")
|
|
|
|
removeOption.addClassName("disabled");
|
|
|
|
else
|
|
|
|
removeOption.removeClassName("disabled");
|
|
|
|
|
|
|
|
return true;
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
2008-08-25 19:53:27 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return false;
|
2007-11-19 23:40:13 +01:00
|
|
|
}
|
|
|
|
|
2008-02-08 00:09:16 +01:00
|
|
|
function onContactMenuPrepareVisibility() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactRows = document.menuTarget;
|
|
|
|
var selectedFolder = $("contactFolders").getSelectedNodes().first();
|
|
|
|
var options = { write: false,
|
|
|
|
aim: false };
|
|
|
|
|
|
|
|
var elements = $(this).down("ul").childElements();
|
|
|
|
var writeOption = elements[2];
|
|
|
|
var aimOption = elements[3];
|
|
|
|
var deleteOption = elements[5];
|
|
|
|
var moveOption = elements[7];
|
|
|
|
|
|
|
|
$A(contactRows).each(function(contactRow) {
|
|
|
|
var cells = contactRow.getElementsByTagName('td');
|
|
|
|
var emailCell = cells[1];
|
|
|
|
options.write |= (emailCell.firstChild != null);
|
|
|
|
var aimCell = cells[2];
|
|
|
|
options.aim |= (aimCell.firstChild != null);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (options.write)
|
|
|
|
writeOption.removeClassName("disabled");
|
|
|
|
else
|
|
|
|
writeOption.addClassName("disabled");
|
|
|
|
if (options.aim)
|
|
|
|
aimOption.removeClassName("disabled");
|
|
|
|
else
|
|
|
|
aimOption.addClassName("disabled");
|
|
|
|
|
|
|
|
if ($(selectedFolder).hasClassName("remote")) {
|
|
|
|
// Remote address books are always read-only
|
|
|
|
deleteOption.addClassName("disabled");
|
|
|
|
moveOption.addClassName("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
deleteOption.removeClassName("disabled");
|
|
|
|
moveOption.removeClassName("disabled");
|
|
|
|
}
|
2009-06-26 22:33:36 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return true;
|
2008-02-08 00:09:16 +01:00
|
|
|
}
|
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var menus = {};
|
|
|
|
menus["contactFoldersMenu"] = new Array(onAddressBookModify, "-", newContact,
|
2009-09-03 16:18:13 +02:00
|
|
|
null, "-", onAddressBookImport,
|
|
|
|
onAddressBookRemove, "-",
|
2009-07-20 23:06:33 +02:00
|
|
|
onMenuSharing);
|
|
|
|
menus["contactMenu"] = new Array(onMenuEditContact, "-",
|
|
|
|
onMenuWriteToContact, onMenuAIMContact,
|
|
|
|
"-", onMenuDeleteContact, "-",
|
2009-09-02 15:24:02 +02:00
|
|
|
"moveContactMenu", "copyContactMenu",
|
|
|
|
onMenuExportContact);
|
2009-07-20 23:06:33 +02:00
|
|
|
menus["searchMenu"] = new Array(setSearchCriteria);
|
2007-11-19 23:40:13 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactFoldersMenu = $("contactFoldersMenu");
|
|
|
|
if (contactFoldersMenu)
|
|
|
|
contactFoldersMenu.prepareVisibility = onAddressBooksMenuPrepareVisibility;
|
|
|
|
var contactMenu = $("contactMenu");
|
|
|
|
if (contactMenu)
|
|
|
|
contactMenu.prepareVisibility = onContactMenuPrepareVisibility;
|
2007-11-19 23:40:13 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
return menus;
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function configureSelectionButtons() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var container = $("contactSelectionButtons");
|
|
|
|
if (container) {
|
|
|
|
var buttons = container.select("input");
|
|
|
|
for (var i = 0; i < buttons.length; i++)
|
|
|
|
$(buttons[i]).observe("click", onConfirmContactSelection);
|
|
|
|
}
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2008-09-18 20:03:59 +02:00
|
|
|
function onWindowResize(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var handle = $("dragHandle");
|
|
|
|
if (handle)
|
|
|
|
handle.adjust();
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle)
|
|
|
|
handle.adjust();
|
2008-09-18 20:03:59 +02:00
|
|
|
}
|
|
|
|
|
2009-03-27 19:25:22 +01:00
|
|
|
function onDocumentKeydown(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var target = Event.element(event);
|
|
|
|
if (target.tagName != "INPUT")
|
|
|
|
if (event.keyCode == Event.KEY_DELETE ||
|
|
|
|
event.keyCode == Event.KEY_BACKSPACE && isMac()) {
|
|
|
|
onToolbarDeleteSelectedContacts();
|
|
|
|
Event.stop(event);
|
|
|
|
}
|
|
|
|
else if (event.keyCode == Event.KEY_DOWN ||
|
|
|
|
event.keyCode == Event.KEY_UP) {
|
|
|
|
if (Contact.currentContact) {
|
|
|
|
var row = $(Contact.currentContact);
|
|
|
|
var nextRow;
|
|
|
|
if (event.keyCode == Event.KEY_DOWN)
|
|
|
|
nextRow = row.next("tr");
|
|
|
|
else
|
|
|
|
nextRow = row.previous("tr");
|
|
|
|
if (nextRow) {
|
|
|
|
row.up().deselectAll();
|
2009-03-27 19:25:22 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
// Adjust the scollbar
|
|
|
|
var viewPort = $("contactsListContent");
|
|
|
|
var divDimensions = viewPort.getDimensions();
|
|
|
|
var rowScrollOffset = nextRow.cumulativeScrollOffset();
|
|
|
|
var rowPosition = nextRow.positionedOffset();
|
|
|
|
var divBottom = divDimensions.height + rowScrollOffset.top;
|
|
|
|
var rowBottom = rowPosition.top + nextRow.getHeight();
|
|
|
|
|
|
|
|
if (divBottom < rowBottom)
|
|
|
|
viewPort.scrollTop += rowBottom - divBottom;
|
|
|
|
else if (rowScrollOffset.top > rowPosition.top)
|
|
|
|
viewPort.scrollTop -= rowScrollOffset.top - rowPosition.top;
|
2009-03-27 19:25:22 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
// Select and load the next message
|
|
|
|
nextRow.selectElement();
|
|
|
|
loadContact(nextRow.readAttribute("id"));
|
|
|
|
}
|
|
|
|
Event.stop(event);
|
|
|
|
}
|
|
|
|
}
|
2009-03-27 19:25:22 +01:00
|
|
|
}
|
|
|
|
|
2009-08-17 22:34:18 +02:00
|
|
|
function fixSearchFieldPosition () {
|
|
|
|
var panel = $("filterPanel");
|
2009-08-24 22:26:52 +02:00
|
|
|
if (panel) {
|
|
|
|
panel.style.position = "relative";
|
|
|
|
panel.style.top = "3px";
|
|
|
|
}
|
2009-08-17 22:34:18 +02:00
|
|
|
}
|
|
|
|
|
2007-06-12 16:58:15 +02:00
|
|
|
function initContacts(event) {
|
2009-08-17 22:34:18 +02:00
|
|
|
if ($(document.body).hasClassName("popup")) {
|
2009-07-20 23:06:33 +02:00
|
|
|
configureSelectionButtons();
|
2009-08-17 22:34:18 +02:00
|
|
|
fixSearchFieldPosition ();
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
else if (Prototype.Browser.Gecko)
|
|
|
|
Event.observe(document, "keypress", onDocumentKeydown); // for FF2
|
|
|
|
else
|
|
|
|
Event.observe(document, "keydown", onDocumentKeydown);
|
|
|
|
configureAbToolbar();
|
|
|
|
configureAddressBooks();
|
|
|
|
updateAddressBooksMenus();
|
|
|
|
|
|
|
|
var table = $("contactsList");
|
|
|
|
if (table) {
|
|
|
|
// Initialize contacts table
|
|
|
|
table.multiselect = true;
|
|
|
|
table.observe("mousedown", onContactSelectionChange);
|
|
|
|
configureSortableTableHeaders(table);
|
|
|
|
TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true});
|
|
|
|
}
|
2008-09-18 20:03:59 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
onWindowResize.defer();
|
|
|
|
Event.observe(window, "resize", onWindowResize);
|
2009-03-27 19:25:22 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
// Default sort options
|
|
|
|
sorting["attribute"] = "c_cn";
|
|
|
|
sorting["ascending"] = true;
|
|
|
|
}
|
2009-06-29 20:25:29 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
function configureDraggables() {
|
|
|
|
var mainElement = $("dragDropVisual");
|
|
|
|
Draggables.empty ();
|
|
|
|
|
|
|
|
if (mainElement == null) {
|
|
|
|
mainElement = new Element ("div", {id: "dragDropVisual"});
|
|
|
|
document.body.appendChild(mainElement);
|
|
|
|
mainElement.absolutize ();
|
|
|
|
}
|
|
|
|
mainElement.hide();
|
|
|
|
|
|
|
|
new Draggable ("dragDropVisual",
|
|
|
|
{ handle: "contactsList",
|
|
|
|
onStart: startDragging,
|
|
|
|
onEnd: stopDragging,
|
|
|
|
onDrag: whileDragging,
|
|
|
|
scroll: window
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function configureDroppables() {
|
|
|
|
var drops = $$("ul#contactFolders li");
|
|
|
|
|
|
|
|
Droppables.empty ();
|
|
|
|
drops.each (function (drop) {
|
|
|
|
if (!drop.hasClassName ("remote"))
|
|
|
|
Droppables.add (drop.id,
|
|
|
|
{ hoverclass: "genericHoverClass",
|
|
|
|
onDrop: dropAction
|
|
|
|
});
|
|
|
|
});
|
2009-06-29 20:25:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function currentFolderIsRemote () {
|
2009-07-20 23:06:33 +02:00
|
|
|
rc = false;
|
|
|
|
var selectedFolders = $("contactFolders").getSelectedNodes();
|
|
|
|
if (selectedFolders.length > 0) {
|
|
|
|
var fromObject = $(selectedFolders[0]);
|
|
|
|
rc = fromObject.hasClassName ("remote");
|
|
|
|
}
|
|
|
|
return rc;
|
2009-06-29 20:25:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function startDragging (itm, e) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var target = Event.element(e);
|
|
|
|
if (target.up().up().tagName != "TBODY")
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var handle = $("dragDropVisual");
|
|
|
|
var contacts = $('contactsList').getSelectedRowsId();
|
|
|
|
var count = contacts.length;
|
|
|
|
|
2009-08-25 15:12:14 +02:00
|
|
|
handle.show();
|
|
|
|
handle.update (count);
|
|
|
|
if (e.shiftKey || currentFolderIsRemote ())
|
|
|
|
handle.addClassName ("copy");
|
2009-06-29 20:25:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function whileDragging (itm, e) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var handle = $("dragDropVisual");
|
|
|
|
if (e.shiftKey || currentFolderIsRemote ())
|
|
|
|
handle.addClassName ("copy");
|
|
|
|
else if (handle.hasClassName ("copy"))
|
|
|
|
handle.removeClassName ("copy");
|
2009-06-29 20:25:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function stopDragging () {
|
2009-07-20 23:06:33 +02:00
|
|
|
var handle = $("dragDropVisual");
|
|
|
|
handle.hide();
|
|
|
|
if (handle.hasClassName ("copy"))
|
|
|
|
handle.removeClassName ("copy");
|
2009-06-29 20:25:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function dropAction (dropped, zone, e) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var action = "move";
|
|
|
|
if ($("dragDropVisual").hasClassName ("copy"))
|
|
|
|
action = "copy";
|
|
|
|
else
|
|
|
|
$('contactView').update();
|
|
|
|
dropSelectedContacts (action, zone.id.substr (1));
|
2009-06-29 20:25:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function dropSelectedContacts (action, toId) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var selectedFolders = $("contactFolders").getSelectedNodes();
|
|
|
|
if (selectedFolders.length > 0) {
|
|
|
|
var contactIds = $('contactsList').getSelectedRowsId();
|
2009-08-25 15:12:14 +02:00
|
|
|
for (var i = 0; i < contactIds.length; i++) {
|
|
|
|
if (contactIds[i].endsWith ("vlf")) {
|
|
|
|
alert (labels["Lists can't be moved or copied."]);
|
|
|
|
return false;
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
}
|
2009-08-25 15:12:14 +02:00
|
|
|
var fromId = $(selectedFolders[0]).id;
|
|
|
|
if (!currentFolderIsRemote () || action != "move") {
|
|
|
|
var url = ApplicationBaseURL + fromId + "/" + action
|
|
|
|
+ "?folder=" + toId + "&uid="
|
|
|
|
+ contactIds.join("&uid=");
|
|
|
|
|
|
|
|
triggerAjaxRequest(url, actionContactCallback, fromId);
|
|
|
|
}
|
2009-06-29 20:25:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", initContacts);
|