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
|
|
|
|
2012-02-01 22:11:28 +01:00
|
|
|
var usersRightsWindowHeight = 194;
|
2007-04-28 00:06:58 +02:00
|
|
|
var usersRightsWindowWidth = 450;
|
|
|
|
|
2008-08-21 16:35:02 +02:00
|
|
|
var Contact = {
|
2011-04-14 20:01:02 +02:00
|
|
|
currentAddressBook: "/personal",
|
2009-07-20 23:06:33 +02:00
|
|
|
currentContact: null,
|
2010-08-19 23:26:31 +02:00
|
|
|
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;
|
2011-12-02 08:22:47 +01:00
|
|
|
var url = URLForFolderID(Contact.currentAddressBook, "Contacts") +
|
2009-07-20 23:06:33 +02:00
|
|
|
"/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
|
|
|
|
selection = null;
|
|
|
|
|
|
|
|
if (document.contactsListAjaxRequest) {
|
|
|
|
document.contactsListAjaxRequest.aborted = true;
|
|
|
|
document.contactsListAjaxRequest.abort();
|
|
|
|
}
|
2011-12-02 08:22:47 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
document.contactsListAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, contactsListCallback, selection);
|
2008-04-15 22:12:51 +02:00
|
|
|
}
|
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");
|
2011-04-14 20:01:02 +02:00
|
|
|
var tbody = table.tBodies[0];
|
|
|
|
var rows = tbody.getElementsByTagName("TR");
|
2011-12-02 08:22:47 +01:00
|
|
|
var fullView = (table.tHead.rows[0].cells.length > 2);
|
2011-04-14 20:01:02 +02:00
|
|
|
var data = [];
|
|
|
|
if (http.responseText.length > 0)
|
|
|
|
data = http.responseText.evalJSON(true);
|
|
|
|
|
|
|
|
tbody.deselectAll();
|
|
|
|
|
|
|
|
div.scrollTop = 0;
|
|
|
|
if (data.length > 0) {
|
|
|
|
// Replace existing rows
|
|
|
|
for (var i = 0; i < data.length && i < rows.length; i++) {
|
|
|
|
var contact = data[i];
|
|
|
|
var row = rows[i];
|
|
|
|
row.className = contact["c_component"];
|
|
|
|
row.setAttribute("id", contact["c_name"]);
|
|
|
|
row.setAttribute("categories", contact["c_categories"]);
|
|
|
|
row.setAttribute("contactname", contact["c_cn"]);
|
|
|
|
var cells = row.getElementsByTagName("TD");
|
|
|
|
$(cells[0]).update(contact["c_cn"]);
|
|
|
|
$(cells[1]).update(contact["c_mail"]);
|
2011-12-02 08:22:47 +01:00
|
|
|
if (fullView) {
|
|
|
|
$(cells[2]).update(contact["c_screenname"]);
|
|
|
|
$(cells[3]).update(contact["c_o"]);
|
|
|
|
$(cells[4]).update(contact["c_telephonenumber"]);
|
|
|
|
}
|
2011-04-14 20:01:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add extra rows
|
|
|
|
for (var j = i; j < data.length; j++) {
|
|
|
|
var contact = data[j];
|
|
|
|
var row = createElement("tr",
|
|
|
|
contact["c_name"],
|
|
|
|
contact["c_component"],
|
|
|
|
null,
|
|
|
|
{ categories: contact["c_categories"],
|
|
|
|
contactname: contact["c_cn"] },
|
|
|
|
tbody);
|
|
|
|
var cell = createElement("td",
|
|
|
|
null,
|
|
|
|
( "displayName" ),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
row);
|
|
|
|
cell.appendChild(document.createTextNode(contact["c_cn"]));
|
2011-12-02 08:22:47 +01:00
|
|
|
cell.title = contact["c_cn"];
|
2011-04-14 20:01:02 +02:00
|
|
|
|
|
|
|
cell = document.createElement("td");
|
|
|
|
row.appendChild(cell);
|
2011-12-02 08:22:47 +01:00
|
|
|
if (contact["c_mail"]) {
|
2011-04-14 20:01:02 +02:00
|
|
|
cell.appendChild(document.createTextNode(contact["c_mail"]));
|
2011-12-02 08:22:47 +01:00
|
|
|
cell.title = contact["c_mail"];
|
|
|
|
}
|
2011-04-14 20:01:02 +02:00
|
|
|
|
2011-12-02 08:22:47 +01:00
|
|
|
if (fullView) {
|
|
|
|
cell = document.createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
if (contact["c_screenname"])
|
|
|
|
cell.appendChild(document.createTextNode(contact["c_screenname"]));
|
|
|
|
|
|
|
|
cell = document.createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
if (contact["c_o"])
|
|
|
|
cell.appendChild(document.createTextNode(contact["c_o"]));
|
|
|
|
|
|
|
|
cell = document.createElement("td");
|
|
|
|
row.appendChild(cell);
|
|
|
|
if (contact["c_telephonenumber"])
|
|
|
|
cell.appendChild(document.createTextNode(contact["c_telephonenumber"]));
|
|
|
|
}
|
2011-04-14 20:01:02 +02:00
|
|
|
}
|
2011-05-31 21:12:46 +02:00
|
|
|
|
|
|
|
configureDraggables();
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
2011-04-14 20:01:02 +02:00
|
|
|
|
|
|
|
// Remove unnecessary rows
|
|
|
|
for (i = rows.length - 1; i >= data.length; i--) {
|
|
|
|
tbody.removeChild(rows[i]);
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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"])
|
2009-11-04 23:13:20 +01:00
|
|
|
sortImage.src = ResourcesURL + "/arrow-up.png";
|
2011-04-14 20:01:02 +02:00
|
|
|
else
|
|
|
|
sortImage.src = ResourcesURL + "/arrow-down.png";
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
}
|
2011-04-14 20:01:02 +02:00
|
|
|
|
|
|
|
// Restore selection and scroll to first selected node
|
|
|
|
var selection = http.callbackData;
|
2011-12-06 20:28:44 +01:00
|
|
|
if (selection && tbody.refreshSelectionByIds(selection) > 0) {
|
2011-04-14 20:01:02 +02:00
|
|
|
for (var i = 0; i < selection.length; i++) {
|
|
|
|
var row = $(selection[i]);
|
2009-07-20 23:06:33 +02:00
|
|
|
if (row) {
|
|
|
|
var rowPosition = row.rowIndex * row.getHeight();
|
|
|
|
if (div.getHeight() < rowPosition)
|
|
|
|
div.scrollTop = rowPosition; // scroll to selected contact
|
2012-02-08 16:41:57 +01:00
|
|
|
row.selectElement();
|
2011-04-14 20:01:02 +02:00
|
|
|
break;
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 20:28:44 +01:00
|
|
|
else
|
|
|
|
tbody.deselectAll();
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
else {
|
2011-04-14 20:01:02 +02:00
|
|
|
// No more access to this address book; empty the list
|
2009-07-20 23:06:33 +02:00
|
|
|
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) {
|
2011-06-01 23:10:25 +02:00
|
|
|
var target = Event.element(event);
|
|
|
|
var contact = target.up('TR');
|
2009-07-20 23:06:33 +02:00
|
|
|
var contactsList = $("contactsList");
|
2011-06-01 23:10:25 +02:00
|
|
|
var contacts = contactsList.getSelectedRows();
|
|
|
|
|
|
|
|
if (contacts.indexOf(contact) < 0) {
|
|
|
|
onRowClick(event, target);
|
|
|
|
contacts = contactsList.getSelectedRows();
|
|
|
|
}
|
|
|
|
|
2011-06-02 21:23:31 +02:00
|
|
|
if (contactsList) {
|
|
|
|
var menu = $("contactMenu");
|
|
|
|
menu.observe("contextmenu:hide", onContactContextMenuHide);
|
2011-06-01 23:10:25 +02:00
|
|
|
popupMenu(event, "contactMenu", contacts);
|
2011-06-02 21:23:31 +02:00
|
|
|
}
|
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;
|
|
|
|
}
|
2011-06-02 21:23:31 +02:00
|
|
|
|
|
|
|
this.stopObserving("contextmenu:hide", onContactContextMenuHide);
|
2006-11-03 20:40:12 +01: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")) {
|
2011-05-31 21:12:46 +02:00
|
|
|
showAlertDialog(_("Lists can't be moved or copied."));
|
2009-08-25 15:12:14 +02:00
|
|
|
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();
|
2012-01-04 16:26:30 +01:00
|
|
|
var canExport = (selectedFolders[0].getAttribute("owner") != "nobody");
|
|
|
|
if (canExport) {
|
|
|
|
var selectedFolderId = $(selectedFolders[0]).readAttribute("id");
|
2012-02-08 16:41:57 +01:00
|
|
|
var contactIds = document.menuTarget.collect(function(row) {
|
|
|
|
return row.readAttribute("id");
|
|
|
|
});
|
2009-09-02 15:24:02 +02:00
|
|
|
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)
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("You don't have the required privileges to perform the operation."));
|
2009-07-20 23:06:33 +02:00
|
|
|
else if (error)
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(labels[error]);
|
2009-07-20 23:06:33 +02:00
|
|
|
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) {
|
2011-04-14 20:01:02 +02:00
|
|
|
var t = getTarget(event);
|
|
|
|
var cname = t.parentNode.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) {
|
2011-12-02 08:22:47 +01:00
|
|
|
var contactView = $("contactView");
|
2011-04-14 20:01:02 +02:00
|
|
|
if (event) {
|
|
|
|
// Update rows selection
|
|
|
|
var t = getTarget(event);
|
|
|
|
onRowClick(event, t);
|
|
|
|
}
|
2011-12-02 08:22:47 +01:00
|
|
|
if (contactView) {
|
|
|
|
var rows = this.parentNode.getSelectedRowsId();
|
2008-03-25 20:59:13 +01:00
|
|
|
|
2011-12-02 08:22:47 +01:00
|
|
|
if (rows.length == 1) {
|
|
|
|
var node = $(rows[0]);
|
|
|
|
loadContact(node.getAttribute('id'));
|
|
|
|
}
|
|
|
|
else if (rows.length > 1) {
|
|
|
|
$('contactView').update();
|
|
|
|
Contact.currentContact = null;
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
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) {
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("Please select a contact."));
|
2009-07-20 23:06:33 +02:00
|
|
|
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) {
|
2010-10-11 22:13:26 +02:00
|
|
|
showAlertDialog(_("Please select a contact."));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
openMailComposeWindow(ApplicationBaseURL + "../Mail/compose"
|
|
|
|
+ "?folder=" + Contact.currentAddressBook.substring(1)
|
|
|
|
+ "&uid=" + rows.join("&uid="));
|
|
|
|
if (document.body.hasClassName("popup"))
|
|
|
|
window.close();
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
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();
|
|
|
|
|
2010-09-22 22:10:25 +02:00
|
|
|
if (rows && rows.length)
|
2010-08-19 23:26:31 +02:00
|
|
|
showConfirmDialog(_("Confirmation"),
|
|
|
|
_("Are you sure you want to delete the selected contacts?"),
|
|
|
|
onToolbarDeleteSelectedContactsConfirm);
|
2010-09-22 22:10:25 +02:00
|
|
|
else if (!onAddressBookRemove(event))
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("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
|
|
|
}
|
|
|
|
|
2010-08-04 19:59:43 +02:00
|
|
|
function onToolbarDeleteSelectedContactsConfirm(dialogId) {
|
2011-07-13 18:05:30 +02:00
|
|
|
disposeDialog();
|
2010-08-04 19:59:43 +02:00
|
|
|
var contactsList = $('contactsList');
|
|
|
|
var rows = contactsList.getSelectedRowsId();
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2011-12-30 21:39:07 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2011-12-30 21:39:07 +01:00
|
|
|
if (row) {
|
|
|
|
row.deselect();
|
|
|
|
row.parentNode.removeChild(row);
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
else if (parseInt(http.status) == 403) {
|
|
|
|
var row = $(http.callbackData);
|
2010-08-05 17:57:09 +02:00
|
|
|
row.show();
|
2009-10-26 16:52:45 +01:00
|
|
|
var displayName = row.readAttribute("contactname");
|
2009-07-20 23:06:33 +02:00
|
|
|
Contact.deleteContactsRequestCount--;
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("You cannot delete the card of \"%{0}\".").formatted(displayName));
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
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);
|
2012-01-04 16:26:30 +01:00
|
|
|
var listEditing = li.getAttribute("list-editing");
|
|
|
|
if (listEditing && listEditing == "available")
|
2009-09-14 14:56:05 +02:00
|
|
|
openContactWindow(URLForFolderID(Contact.currentAddressBook) + "/newlist");
|
2012-01-04 16:26:30 +01:00
|
|
|
else
|
|
|
|
showAlertDialog(_("You cannot create a list in a shared address book."));
|
2010-03-25 16:42:52 +01:00
|
|
|
|
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");
|
|
|
|
|
|
|
|
if (event) {
|
|
|
|
var node = getTarget(event);
|
|
|
|
if (node.tagName == 'UL')
|
|
|
|
return;
|
2011-05-31 21:12:46 +02:00
|
|
|
// Update rows selection
|
|
|
|
onRowClick(event, node);
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 21:12:46 +02:00
|
|
|
var nodes = folderList.getSelectedNodes();
|
2009-07-20 23:06:33 +02:00
|
|
|
$("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
|
|
|
}
|
|
|
|
|
2011-12-02 08:22:47 +01:00
|
|
|
/* Only used in UIxMailEditor */
|
2007-03-29 20:05:23 +02:00
|
|
|
function onConfirmContactSelection(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var tag = this.getAttribute("name");
|
2011-12-02 08:22:47 +01:00
|
|
|
var folder = $("contactFolder");
|
|
|
|
var currentAddressBookName = folder.textContent;
|
2009-07-20 23:06:33 +02:00
|
|
|
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 {
|
2011-04-14 20:01:02 +02:00
|
|
|
var cname = '' + rows[i].readAttribute("contactname");
|
2009-09-10 23:00:38 +02:00
|
|
|
var email = '' + rows[i].cells[1].innerHTML;
|
2011-12-02 08:22:47 +01:00
|
|
|
addContact(tag, currentAddressBookName + '/' + cname,
|
|
|
|
cid, cname, email);
|
2009-09-10 23:00:38 +02:00
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
2008-04-15 22:12:51 +02:00
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
this.blur(); // required by IE
|
|
|
|
Event.stop(event);
|
|
|
|
|
|
|
|
return false;
|
2006-11-01 21:33:03 +01:00
|
|
|
}
|
|
|
|
|
2009-09-10 23:00:38 +02:00
|
|
|
function addListToOpener (tag, aBookId, aBookName, listId) {
|
2011-12-02 08:22:47 +01:00
|
|
|
var url = UserFolderURL + "Contacts/" + aBookId + "/" + listId + "/properties";
|
2009-09-10 23:00:38 +02:00
|
|
|
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];
|
2011-12-02 08:22:47 +01:00
|
|
|
addContact(data.tag, data.aBookName + '/' + contact[1],
|
|
|
|
contact[0], contact[1], contact[2]);
|
2009-09-10 23:00:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
2011-04-29 00:00:52 +02:00
|
|
|
showPromptDialog(_("New Addressbook..."), _("Name of the Address Book"), onAddressBookNewConfirm);
|
2009-07-20 23:06:33 +02:00
|
|
|
preventDefault(event);
|
2007-02-09 22:25:13 +01:00
|
|
|
}
|
|
|
|
|
2010-08-19 16:19:24 +02:00
|
|
|
function onAddressBookNewConfirm() {
|
|
|
|
if (this.value.length > 0)
|
|
|
|
createFolder(this.value, appendAddressBook);
|
|
|
|
disposeDialog();
|
|
|
|
}
|
|
|
|
|
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);
|
2012-03-01 21:23:25 +01:00
|
|
|
li.setAttribute("list-editing", "available");
|
2009-07-20 23:06:33 +02:00
|
|
|
li.addClassName("local");
|
|
|
|
li.appendChild(document.createTextNode(name
|
|
|
|
.replace("<", "<", "g")
|
|
|
|
.replace(">", ">", "g")));
|
|
|
|
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);
|
2010-02-08 18:01:39 +01:00
|
|
|
node.deselect();
|
2009-07-20 23:06:33 +02:00
|
|
|
node.parentNode.removeChild(node);
|
2010-02-08 18:01:39 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
var personal = $("/personal");
|
|
|
|
personal.selectElement();
|
|
|
|
onFolderSelectionChange();
|
2006-11-01 21:33:03 +01:00
|
|
|
}
|
|
|
|
|
2010-04-19 18:35:35 +02:00
|
|
|
function onAddressBookExport(event) {
|
|
|
|
var node = $("contactFolders").getSelectedNodes().first();
|
|
|
|
var folderID = node.getAttribute("id");
|
|
|
|
var url = URLForFolderID(folderID) + "/exportFolder";
|
|
|
|
window.location.href = url;
|
|
|
|
|
|
|
|
event.stop();
|
2012-03-13 16:56:03 +01:00
|
|
|
hideMenu(document.currentPopupMenu);
|
2010-04-19 18:35:35 +02: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;
|
|
|
|
$("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-11-04 23:13:20 +01:00
|
|
|
res.setStyle({ top: top + "px", left: left + "px" });
|
|
|
|
div.setStyle({ top: top + "px", left: left + "px" });
|
|
|
|
div.show();
|
2009-09-03 16:18:13 +02:00
|
|
|
}
|
2009-11-04 23:13:20 +01:00
|
|
|
function hideContactsImport(event) {
|
|
|
|
$("uploadDialog").hide();
|
2009-09-03 16:18:13 +02:00
|
|
|
}
|
2009-11-04 23:13:20 +01:00
|
|
|
|
2009-09-03 19:53:38 +02:00
|
|
|
function hideImportResults () {
|
2009-11-04 23:13:20 +01:00
|
|
|
$("uploadResults").hide();
|
2009-09-03 19:53:38 +02:00
|
|
|
}
|
2009-09-03 16:18:13 +02:00
|
|
|
function validateUploadForm () {
|
|
|
|
rc = false;
|
|
|
|
if ($("contactsFile").value.length)
|
|
|
|
rc = true;
|
|
|
|
return rc;
|
|
|
|
}
|
2009-10-28 18:48:22 +01:00
|
|
|
function uploadCompleted(response) {
|
|
|
|
data = response.evalJSON(true);
|
2009-09-03 19:53:38 +02:00
|
|
|
|
|
|
|
var div = $("uploadResults");
|
2009-09-03 20:37:08 +02:00
|
|
|
if (data.imported <= 0)
|
2010-06-02 21:11:15 +02:00
|
|
|
$("uploadResultsContent").update(_("An error occured while importing contacts."));
|
2009-10-28 18:48:22 +01:00
|
|
|
else if (data.imported == 0)
|
2010-06-02 21:11:15 +02:00
|
|
|
$("uploadResultsContent").update(_("No card was imported."));
|
2009-09-03 20:37:08 +02:00
|
|
|
else {
|
2010-06-02 21:11:15 +02:00
|
|
|
$("uploadResultsContent").update(_("A total of %{0} cards were imported in the addressbook.").formatted(data.imported));
|
2009-11-04 23:13:20 +01:00
|
|
|
refreshCurrentFolder();
|
2009-09-03 20:37:08 +02:00
|
|
|
}
|
2009-09-03 19:53:38 +02:00
|
|
|
|
2009-11-04 23:13:20 +01:00
|
|
|
hideContactsImport();
|
|
|
|
$("uploadResults").show();
|
2009-09-03 19:53:38 +02:00
|
|
|
}
|
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]);
|
|
|
|
var owner = node.getAttribute("owner");
|
|
|
|
if (owner == "nobody") {
|
2010-06-02 21:11:15 +02:00
|
|
|
var label = _("You cannot remove nor unsubscribe from a public addressbook.");
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(label);
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
else if (owner == UserLogin) {
|
|
|
|
var folderIdElements = node.getAttribute("id").split(":");
|
|
|
|
var abId = folderIdElements[0].substr(1);
|
|
|
|
deletePersonalAddressBook(abId);
|
|
|
|
}
|
|
|
|
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);
|
2010-09-22 22:10:25 +02:00
|
|
|
|
|
|
|
return (nodes.length > 0);
|
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) {
|
2010-08-19 23:26:31 +02:00
|
|
|
if (folderId == "personal")
|
2010-08-10 15:47:11 +02:00
|
|
|
showAlertDialog(_("You cannot remove nor unsubscribe from your personal addressbook."));
|
2010-08-19 23:26:31 +02:00
|
|
|
else
|
|
|
|
showConfirmDialog(_("Confirmation"),
|
|
|
|
_("Are you sure you want to delete the selected address book?"),
|
|
|
|
deletePersonalAddressBookConfirm.bind(this, folderId));
|
|
|
|
|
2010-08-05 17:57:09 +02:00
|
|
|
return false;
|
|
|
|
}
|
2010-08-04 19:59:43 +02:00
|
|
|
|
2010-08-19 23:26:31 +02:00
|
|
|
function deletePersonalAddressBookConfirm(folderId) {
|
2010-08-04 19:59:43 +02:00
|
|
|
if (document.deletePersonalABAjaxRequest) {
|
|
|
|
document.deletePersonalABAjaxRequest.aborted = true;
|
|
|
|
document.deletePersonalABAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var url = ApplicationBaseURL + folderId + "/delete";
|
|
|
|
document.deletePersonalABAjaxRequest
|
|
|
|
= triggerAjaxRequest(url, deletePersonalAddressBookCallback,
|
|
|
|
folderId);
|
|
|
|
|
2010-08-19 16:19:24 +02:00
|
|
|
disposeDialog();
|
2007-03-21 15:29:09 +01:00
|
|
|
}
|
|
|
|
|
2010-08-04 19:59:43 +02:00
|
|
|
|
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) {
|
2010-02-08 18:01:39 +01:00
|
|
|
children[i].deselect();
|
2009-07-20 23:06:33 +02:00
|
|
|
ul.removeChild(children[i]);
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
}
|
2010-02-08 18:01:39 +01:00
|
|
|
var personal = $("/personal");
|
|
|
|
personal.selectElement();
|
|
|
|
onFolderSelectionChange();
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
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) {
|
2011-05-31 21:12:46 +02:00
|
|
|
contactFolders.on("mousedown", onFolderSelectionChange);
|
|
|
|
contactFolders.on("dblclick", onAddressBookModify);
|
2011-05-31 22:16:43 +02:00
|
|
|
contactFolders.on("selectstart", listRowMouseDownHandler);
|
2009-07-20 23:06:33 +02:00
|
|
|
contactFolders.attachMenu("contactFoldersMenu");
|
2008-03-25 20:59:13 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
lookupDeniedFolders();
|
|
|
|
configureDroppables();
|
|
|
|
|
2011-04-14 20:01:02 +02:00
|
|
|
// Select initial addressbook
|
|
|
|
$(Contact.currentAddressBook).selectElement();
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
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 onAddressBookModify(event) {
|
2009-07-20 23:06:33 +02:00
|
|
|
var folders = $("contactFolders");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
2011-05-31 21:12:46 +02:00
|
|
|
if (selected.getAttribute("owner") != "nobody") {
|
2010-09-20 16:11:05 +02:00
|
|
|
var currentName = selected.innerHTML.unescapeHTML();
|
2010-08-19 16:19:24 +02:00
|
|
|
showPromptDialog(_("Properties"),
|
|
|
|
_("Address Book Name"),
|
|
|
|
onAddressBookModifyConfirm,
|
|
|
|
currentName);
|
|
|
|
}
|
2008-02-04 23:22:14 +01:00
|
|
|
}
|
|
|
|
|
2010-08-19 16:19:24 +02:00
|
|
|
function onAddressBookModifyConfirm() {
|
|
|
|
var folders = $("contactFolders");
|
|
|
|
var selected = folders.getSelectedNodes()[0];
|
|
|
|
var newName = this.value;
|
|
|
|
var currentName = this.getAttribute("previousValue");
|
|
|
|
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});
|
|
|
|
}
|
|
|
|
disposeDialog();
|
|
|
|
}
|
|
|
|
|
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];
|
2012-01-04 16:26:30 +01:00
|
|
|
var aclEditing = selected.getAttribute("acl-editing");
|
|
|
|
if (aclEditing && aclEditing == "available") {
|
2009-07-20 23:06:33 +02:00
|
|
|
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);
|
|
|
|
}
|
2012-01-04 16:26:30 +01:00
|
|
|
else
|
|
|
|
showAlertDialog(_("The user rights cannot be edited for this object!"));
|
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");
|
2010-04-19 18:35:35 +02:00
|
|
|
var modifyOption = listElements[0];
|
2012-01-04 16:26:30 +01:00
|
|
|
var newListOption = listElements[3];
|
2010-04-19 18:35:35 +02:00
|
|
|
var removeOption = listElements[5];
|
|
|
|
var exportOption = listElements[7];
|
2012-01-04 16:26:30 +01:00
|
|
|
var importOption = listElements[8];
|
2010-04-19 18:35:35 +02:00
|
|
|
var sharingOption = listElements[listElements.length - 1];
|
2009-07-20 23:06:33 +02:00
|
|
|
|
|
|
|
// Disable the "Sharing" and "Modify" options when address book
|
|
|
|
// is not owned by user
|
|
|
|
if (folderOwner == UserLogin || IsSuperUser) {
|
2012-01-04 16:26:30 +01:00
|
|
|
modifyOption.removeClassName("disabled"); // WARNING: will fail
|
|
|
|
// for super users
|
|
|
|
// anyway
|
|
|
|
var aclEditing = selected[0].getAttribute("acl-editing");
|
|
|
|
if (aclEditing && aclEditing == "available") {
|
|
|
|
sharingOption.removeClassName("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sharingOption.addClassName("disabled");
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
modifyOption.addClassName("disabled");
|
|
|
|
sharingOption.addClassName("disabled");
|
|
|
|
}
|
|
|
|
|
2012-01-04 16:26:30 +01:00
|
|
|
var listEditing = selected[0].getAttribute("list-editing");
|
|
|
|
if (listEditing && listEditing == "available") {
|
|
|
|
newListOption.removeClassName("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newListOption.addClassName("disabled");
|
|
|
|
}
|
|
|
|
|
2010-04-19 18:35:35 +02:00
|
|
|
/* Disable the "remove" and "export ab" options when address book is
|
|
|
|
public */
|
|
|
|
if (folderOwner == "nobody") {
|
|
|
|
exportOption.addClassName("disabled");
|
2012-01-04 16:26:30 +01:00
|
|
|
importOption.addClassName("disabled");
|
2009-07-20 23:06:33 +02:00
|
|
|
removeOption.addClassName("disabled");
|
2010-04-19 18:35:35 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
exportOption.removeClassName("disabled");
|
2012-01-04 16:26:30 +01:00
|
|
|
importOption.removeClassName("disabled");
|
|
|
|
if (selected[0].getAttribute("id") == "/personal") {
|
|
|
|
removeOption.addClassName("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
removeOption.removeClassName("disabled");
|
|
|
|
}
|
2010-04-19 18:35:35 +02:00
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
|
|
|
|
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();
|
2010-11-01 20:32:19 +01:00
|
|
|
|
|
|
|
var categoriesOption = elements[1];
|
|
|
|
if (selectedFolder.getAttribute("owner") == UserLogin) {
|
|
|
|
categoriesOption.removeClassName("disabled");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
categoriesOption.addClassName("disabled");
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
|
|
|
|
$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);
|
|
|
|
});
|
|
|
|
|
2010-11-01 20:32:19 +01:00
|
|
|
var writeOption = elements[3];
|
2009-07-20 23:06:33 +02:00
|
|
|
if (options.write)
|
|
|
|
writeOption.removeClassName("disabled");
|
|
|
|
else
|
|
|
|
writeOption.addClassName("disabled");
|
2010-11-01 20:32:19 +01:00
|
|
|
|
|
|
|
var aimOption = elements[4];
|
2009-07-20 23:06:33 +02:00
|
|
|
if (options.aim)
|
|
|
|
aimOption.removeClassName("disabled");
|
|
|
|
else
|
|
|
|
aimOption.addClassName("disabled");
|
|
|
|
|
2010-11-01 20:32:19 +01:00
|
|
|
var deleteOption = elements[6];
|
|
|
|
var moveOption = elements[8];
|
2009-07-20 23:06:33 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-12-02 08:22:47 +01:00
|
|
|
var originalGetMenus = null;
|
|
|
|
if (typeof getMenus == 'function') {
|
|
|
|
originalGetMenus = getMenus;
|
|
|
|
}
|
|
|
|
getMenus = function() {
|
2009-07-20 23:06:33 +02:00
|
|
|
var menus = {};
|
|
|
|
menus["contactFoldersMenu"] = new Array(onAddressBookModify, "-", newContact,
|
2010-04-19 18:35:35 +02:00
|
|
|
newList, "-",
|
2009-09-03 16:18:13 +02:00
|
|
|
onAddressBookRemove, "-",
|
2010-04-19 18:35:35 +02:00
|
|
|
onAddressBookExport, onAddressBookImport, "-",
|
2009-07-20 23:06:33 +02:00
|
|
|
onMenuSharing);
|
2010-11-01 20:32:19 +01:00
|
|
|
menus["contactMenu"] = new Array(onMenuEditContact,
|
|
|
|
"categoriesMenu",
|
|
|
|
"-",
|
2009-07-20 23:06:33 +02:00
|
|
|
onMenuWriteToContact, onMenuAIMContact,
|
|
|
|
"-", onMenuDeleteContact, "-",
|
2009-09-02 15:24:02 +02:00
|
|
|
"moveContactMenu", "copyContactMenu",
|
|
|
|
onMenuExportContact);
|
2010-10-26 22:19:37 +02:00
|
|
|
menus["searchMenu"] = new Array(setSearchCriteria, 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
|
|
|
|
2011-12-02 08:22:47 +01:00
|
|
|
if (originalGetMenus) {
|
|
|
|
var originalMenus = originalGetMenus();
|
|
|
|
if (originalMenus)
|
|
|
|
menus = Object.extend(menus, originalMenus);
|
|
|
|
}
|
|
|
|
|
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) {
|
2009-11-04 23:13:20 +01:00
|
|
|
var buttons = container.select("A.button");
|
|
|
|
for (var i = 0; i < buttons.length; i++) {
|
2009-07-20 23:06:33 +02:00
|
|
|
$(buttons[i]).observe("click", onConfirmContactSelection);
|
2009-11-04 23:13:20 +01:00
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
2007-03-29 20:05:23 +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);
|
2010-10-08 22:57:24 +02:00
|
|
|
if (target.tagName != "INPUT") {
|
|
|
|
var keyCode = event.keyCode;
|
|
|
|
if (!keyCode) {
|
|
|
|
keyCode = event.charCode;
|
|
|
|
if (keyCode == "a".charCodeAt(0)) {
|
|
|
|
keyCode = "A".charCodeAt(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (keyCode == Event.KEY_DELETE ||
|
|
|
|
keyCode == Event.KEY_BACKSPACE && isMac()) {
|
2009-07-20 23:06:33 +02:00
|
|
|
onToolbarDeleteSelectedContacts();
|
|
|
|
Event.stop(event);
|
|
|
|
}
|
2010-10-08 22:57:24 +02:00
|
|
|
else if (keyCode == Event.KEY_DOWN ||
|
|
|
|
keyCode == Event.KEY_UP) {
|
2009-07-20 23:06:33 +02:00
|
|
|
if (Contact.currentContact) {
|
|
|
|
var row = $(Contact.currentContact);
|
|
|
|
var nextRow;
|
2010-10-08 22:57:24 +02:00
|
|
|
if (keyCode == Event.KEY_DOWN)
|
2009-07-20 23:06:33 +02:00
|
|
|
nextRow = row.next("tr");
|
|
|
|
else
|
|
|
|
nextRow = row.previous("tr");
|
|
|
|
if (nextRow) {
|
|
|
|
row.up().deselectAll();
|
2010-07-30 22:10:00 +02: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;
|
2011-04-14 20:01:02 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
// Select and load the next message
|
|
|
|
nextRow.selectElement();
|
|
|
|
loadContact(nextRow.readAttribute("id"));
|
|
|
|
}
|
|
|
|
Event.stop(event);
|
|
|
|
}
|
|
|
|
}
|
2010-08-26 19:21:41 +02:00
|
|
|
else if (((isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1))
|
2010-10-08 22:57:24 +02:00
|
|
|
&& keyCode == "A".charCodeAt(0)) { // Ctrl-A
|
2010-07-30 22:10:00 +02:00
|
|
|
$("contactsList").selectAll();
|
|
|
|
Event.stop(event);
|
|
|
|
}
|
2010-10-08 22:57:24 +02:00
|
|
|
}
|
2009-03-27 19:25:22 +01:00
|
|
|
}
|
|
|
|
|
2010-01-13 06:14:36 +01:00
|
|
|
/*function fixSearchFieldPosition () {
|
2009-08-17 22:34:18 +02:00
|
|
|
var panel = $("filterPanel");
|
2009-08-24 22:26:52 +02:00
|
|
|
if (panel) {
|
|
|
|
panel.style.position = "relative";
|
2009-11-04 23:13:20 +01:00
|
|
|
panel.style.top = "7px";
|
2009-08-24 22:26:52 +02:00
|
|
|
}
|
2010-01-13 06:14:36 +01:00
|
|
|
}*/
|
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-11-04 23:13:20 +01:00
|
|
|
}
|
2010-05-04 21:49:35 +02:00
|
|
|
|
|
|
|
var tabsContainer = $("smallToolbarContainer");
|
2010-05-04 22:19:09 +02:00
|
|
|
if (tabsContainer) {
|
|
|
|
var controller = new SOGoTabsController();
|
|
|
|
controller.attachToTabsContainer(tabsContainer);
|
|
|
|
configureAbToolbar();
|
2010-05-04 21:49:35 +02:00
|
|
|
|
2010-05-04 22:39:01 +02:00
|
|
|
// Addressbook import form
|
|
|
|
$("uploadCancel").observe("click", hideContactsImport);
|
|
|
|
$("uploadOK").observe("click", hideImportResults);
|
|
|
|
}
|
2010-05-04 21:49:35 +02:00
|
|
|
|
2010-07-30 22:10:00 +02:00
|
|
|
Event.observe(document, "keydown", onDocumentKeydown);
|
2010-01-13 06:14:36 +01:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
configureAddressBooks();
|
2011-05-31 21:12:46 +02:00
|
|
|
configureDraggables();
|
2009-07-20 23:06:33 +02:00
|
|
|
updateAddressBooksMenus();
|
|
|
|
|
|
|
|
var table = $("contactsList");
|
|
|
|
if (table) {
|
2011-04-14 20:01:02 +02:00
|
|
|
// Initialize event delegation on contacts table
|
2009-07-20 23:06:33 +02:00
|
|
|
table.multiselect = true;
|
2011-04-19 16:25:53 +02:00
|
|
|
var tbody = $(table.tBodies[0]);
|
2011-06-01 23:10:25 +02:00
|
|
|
tbody.on("click", onContactSelectionChange);
|
2011-12-02 08:22:47 +01:00
|
|
|
if ($("contactView")) {
|
|
|
|
tbody.on("dblclick", onContactRowDblClick);
|
|
|
|
tbody.on("selectstart", listRowMouseDownHandler);
|
|
|
|
tbody.on("contextmenu", onContactContextMenu);
|
|
|
|
resetCategoriesMenu();
|
|
|
|
TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true});
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
configureSortableTableHeaders(table);
|
|
|
|
}
|
2011-04-14 20:01:02 +02:00
|
|
|
|
2011-12-02 08:22:47 +01:00
|
|
|
if (typeof onWindowResize != 'function') {
|
|
|
|
// When loaded from the mail editor, onWindowResize is
|
|
|
|
// already registered
|
2011-12-14 04:13:00 +01:00
|
|
|
onWindowResize = onContactsWindowResize;
|
2011-12-02 08:22:47 +01:00
|
|
|
onWindowResize.defer();
|
|
|
|
Event.observe(window, "resize", onWindowResize);
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
// Default sort options
|
|
|
|
sorting["attribute"] = "c_cn";
|
|
|
|
sorting["ascending"] = true;
|
2010-11-01 20:32:19 +01:00
|
|
|
}
|
|
|
|
|
2011-12-14 04:13:00 +01:00
|
|
|
onContactsWindowResize = function (event) {
|
2011-12-02 08:22:47 +01:00
|
|
|
var handle = $("dragHandle");
|
|
|
|
if (handle)
|
|
|
|
handle.adjust();
|
|
|
|
handle = $("rightDragHandle");
|
|
|
|
if (handle)
|
|
|
|
handle.adjust();
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:32:19 +01:00
|
|
|
function resetCategoriesMenu() {
|
|
|
|
var menu = $("categoriesMenu");
|
|
|
|
if (menu) {
|
|
|
|
menu.parentNode.removeChild(menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
menu = createElement("div", "categoriesMenu", "menu");
|
|
|
|
var menuUL = createElement("ul", null, "choiceMenu");
|
|
|
|
menu.appendChild(menuUL);
|
|
|
|
if (UserDefaults && UserDefaults["SOGoContactsCategories"]) {
|
|
|
|
for (var i = 0;
|
|
|
|
i < UserDefaults["SOGoContactsCategories"].length;
|
|
|
|
i++) {
|
|
|
|
var catName = UserDefaults["SOGoContactsCategories"][i];
|
|
|
|
if (catName.length > 0) {
|
|
|
|
var menuLI = createElement("li");
|
2011-11-24 02:12:38 +01:00
|
|
|
menuLI.observe("mousedown", onCategoriesMenuItemClick);
|
2010-11-01 20:32:19 +01:00
|
|
|
menuLI.category = catName;
|
|
|
|
menuLI.appendChild(document.createTextNode(catName));
|
|
|
|
menuUL.appendChild(menuLI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.prepareVisibility = onCategoriesMenuPrepareVisibility;
|
|
|
|
|
|
|
|
var pageContent = $("pageContent");
|
|
|
|
pageContent.appendChild(menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCategoriesMenuPrepareVisibility() {
|
2010-11-08 19:47:11 +01:00
|
|
|
var contactsList = $("contactsList");
|
|
|
|
if (contactsList) {
|
|
|
|
var rows = contactsList.getSelectedRows();
|
|
|
|
if (rows.length > 0) {
|
2011-04-14 20:01:02 +02:00
|
|
|
var catList = rows[0].readAttribute("categories");
|
2010-11-08 19:47:11 +01:00
|
|
|
var catsArray;
|
|
|
|
if (catList && catList.length > 0) {
|
|
|
|
catsArray = catList.split(",");
|
2010-11-01 20:32:19 +01:00
|
|
|
}
|
|
|
|
else {
|
2010-11-08 19:47:11 +01:00
|
|
|
catsArray = [];
|
|
|
|
}
|
|
|
|
var menu = $("categoriesMenu");
|
|
|
|
var ul = menu.down("ul");
|
|
|
|
var listElements = ul.select("li");
|
|
|
|
for (var i = 0; i < listElements.length; i++) {
|
|
|
|
var li = listElements[i];
|
|
|
|
if (catsArray.indexOf(li.category) > -1) {
|
|
|
|
li.addClassName("_chosen");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
li.removeClassName("_chosen");
|
|
|
|
}
|
2010-11-01 20:32:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-08 19:47:11 +01:00
|
|
|
return true;
|
2010-11-01 20:32:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCategoriesMenuItemClick() {
|
|
|
|
var set = !this.hasClassName("_chosen");
|
|
|
|
var method = (set ? "setCategory" : "unsetCategory");
|
|
|
|
var contactsList = $("contactsList");
|
|
|
|
var rowIds = contactsList.getSelectedRowsId();
|
|
|
|
if (rowIds.length > 0) {
|
|
|
|
for (var i = 0; i < rowIds.length; i++) {
|
|
|
|
var url = (URLForFolderID(Contact.currentAddressBook)
|
|
|
|
+ "/" + rowIds[i] + "/" + method);
|
2011-03-10 17:22:56 +01:00
|
|
|
url += "?category=" + encodeURIComponent(this.category);
|
2011-03-10 21:42:02 +01:00
|
|
|
triggerAjaxRequest(url, onCategoriesMenuItemCallback,
|
|
|
|
{ 'addressBook' : Contact.currentAddressBook, 'id' : rowIds[i] });
|
2010-11-01 20:32:19 +01:00
|
|
|
if (set) {
|
|
|
|
setCategoryOnNode($(rowIds[i]), this.category);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
unsetCategoryOnNode($(rowIds[i]), this.category);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-10 21:42:02 +01:00
|
|
|
function onCategoriesMenuItemCallback(http) {
|
|
|
|
if (http.readyState == 4)
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var contact = http.callbackData;
|
|
|
|
if (cachedContacts[contact.addressBook + "/" + contact.id])
|
|
|
|
delete cachedContacts[contact.addressBook + "/" + contact.id];
|
|
|
|
if (contact.addressBook == Contact.currentAddressBook
|
|
|
|
&& contact.id == Contact.currentContact)
|
|
|
|
loadContact(Contact.currentContact);
|
|
|
|
}
|
2011-04-14 20:01:02 +02:00
|
|
|
else if (parseInt(http.status) == 403) {
|
2011-03-10 21:42:02 +01:00
|
|
|
log("onCategoriesMenuItemCallback failed: error " + http.status + " (" + http.responseText + ")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-01 20:32:19 +01:00
|
|
|
function setCategoryOnNode(contactNode, category) {
|
|
|
|
var catList = contactNode.getAttribute("categories");
|
|
|
|
var catsArray = catList.split(",");
|
|
|
|
if (catsArray.indexOf(category) == -1) {
|
|
|
|
catsArray.push(category);
|
|
|
|
contactNode.setAttribute("categories", catsArray.join(","));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function unsetCategoryOnNode(contactNode, category) {
|
|
|
|
var catList = contactNode.getAttribute("categories");
|
|
|
|
var catsArray = catList.split(",");
|
|
|
|
var catIdx = catsArray.indexOf(category);
|
|
|
|
if (catsArray.indexOf(category) > -1) {
|
|
|
|
catsArray.splice(catIdx, 1);
|
|
|
|
contactNode.setAttribute("categories", catsArray.join(","));
|
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
2009-06-29 20:25:29 +02:00
|
|
|
|
2009-07-20 23:06:33 +02:00
|
|
|
function configureDraggables() {
|
2011-12-02 08:22:47 +01:00
|
|
|
if ($("contactFolders")) {
|
|
|
|
var mainElement = $("dragDropVisual");
|
|
|
|
Draggables.empty();
|
2009-07-20 23:06:33 +02:00
|
|
|
|
2011-12-02 08:22:47 +01:00
|
|
|
if (mainElement == null) {
|
2012-03-13 16:56:03 +01:00
|
|
|
mainElement = new Element("div", {id: "dragDropVisual"});
|
2011-12-02 08:22:47 +01:00
|
|
|
document.body.appendChild(mainElement);
|
|
|
|
mainElement.absolutize();
|
|
|
|
}
|
|
|
|
mainElement.hide();
|
2009-07-20 23:06:33 +02:00
|
|
|
|
2012-03-13 16:56:03 +01:00
|
|
|
new Draggable("dragDropVisual",
|
|
|
|
{ handle: "contactsList",
|
|
|
|
onStart: startDragging,
|
|
|
|
onEnd: stopDragging,
|
|
|
|
onDrag: whileDragging,
|
|
|
|
scroll: window,
|
|
|
|
delay: 250 });
|
2011-12-02 08:22:47 +01:00
|
|
|
}
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2012-03-13 16:56:03 +01:00
|
|
|
|
|
|
|
$("contactsListContent").setStyle({ overflow: "visible" });
|
2009-07-20 23:06:33 +02:00
|
|
|
var handle = $("dragDropVisual");
|
|
|
|
var contacts = $('contactsList').getSelectedRowsId();
|
|
|
|
var count = contacts.length;
|
2011-06-01 23:10:25 +02:00
|
|
|
var row = target.up('TR');
|
2009-07-20 23:06:33 +02:00
|
|
|
|
2011-06-01 23:10:25 +02:00
|
|
|
if (count == 0 || contacts.indexOf(row.id) < 0) {
|
|
|
|
onRowClick(e, target);
|
|
|
|
contacts = $("contactsList").getSelectedRowsId();
|
|
|
|
count = contacts.length;
|
|
|
|
}
|
|
|
|
|
2009-08-25 15:12:14 +02:00
|
|
|
handle.update (count);
|
2011-06-01 23:10:25 +02:00
|
|
|
if (e.shiftKey || currentFolderIsRemote()) {
|
|
|
|
handle.addClassName("copy");
|
2010-07-21 15:57:24 +02:00
|
|
|
}
|
2011-06-01 23:10:25 +02:00
|
|
|
handle.show();
|
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 () {
|
2012-03-13 16:56:03 +01:00
|
|
|
$("contactsListContent").setStyle({ overflow: "auto" });
|
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")) {
|
2011-05-31 21:12:46 +02:00
|
|
|
showAlertDialog(_("Lists can't be moved or copied."));
|
2009-08-25 15:12:14 +02:00
|
|
|
return false;
|
2009-07-20 23:06:33 +02:00
|
|
|
}
|
|
|
|
}
|
2009-08-25 15:12:14 +02:00
|
|
|
var fromId = $(selectedFolders[0]).id;
|
2010-07-21 15:57:24 +02:00
|
|
|
if ((!currentFolderIsRemote () || action != "move")
|
|
|
|
&& fromId.substring(1) != toId) {
|
2009-08-25 15:12:14 +02:00
|
|
|
var url = ApplicationBaseURL + fromId + "/" + action
|
|
|
|
+ "?folder=" + toId + "&uid="
|
|
|
|
+ contactIds.join("&uid=");
|
|
|
|
|
|
|
|
triggerAjaxRequest(url, actionContactCallback, fromId);
|
|
|
|
}
|
2009-06-29 20:25:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-11 15:14:48 +01:00
|
|
|
function onContactsReload () {
|
|
|
|
openContactsFolder(Contact.currentAddressBook, true);
|
|
|
|
}
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", initContacts);
|