Monotone-Parent: 5a9d1a37ff5b7e57b7c92db2cc2c56d3af92d80c

Monotone-Revision: 1c7442ef9f84ce58c394c1539163f94d731b3545

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2008-07-08T11:32:43
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle
2008-07-08 11:32:43 +00:00
parent fe445c22f1
commit a19563f78b
9 changed files with 197 additions and 168 deletions
+38 -69
View File
@@ -87,10 +87,10 @@ function contactsListCallback(http) {
var tmp = document.createElement('div');
$(tmp).update(html);
table.replaceChild($(tmp).select("table tbody")[0], tbody);
var rows = table.tBodies[0].rows;
for (var i = 0; i < rows.length; i++) {
var row = $(rows[i]);
var row = $(rows[i]);
row.observe("mousedown", onRowClick);
row.observe("dblclick", onContactRowDblClick);
row.observe("selectstart", listRowMouseDownHandler);
@@ -105,7 +105,7 @@ function contactsListCallback(http) {
configureSortableTableHeaders(table);
TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true});
}
if (sorting["attribute"] && sorting["attribute"].length > 0) {
var sortHeader;
if (sorting["attribute"] == "displayName")
@@ -120,13 +120,13 @@ function contactsListCallback(http) {
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"])
@@ -135,7 +135,7 @@ function contactsListCallback(http) {
sortImage.src = ResourcesURL + "/title_sortup_12x12.png";
}
}
var selected = http.callbackData;
if (selected) {
for (var i = 0; i < selected.length; i++) {
@@ -179,16 +179,8 @@ function onAddressBooksContextMenu(event) {
function onContactContextMenu(event) {
var menu = $("contactMenu");
var topNode = $('contactsList');
var selectedNodes = topNode.getSelectedRows();
if (selectedNodes.length > 1) {
// TODO: Add support for selection of multiple contacts
}
else {
menu.observe("hideMenu", onContactContextMenuHide);
popupMenu(event, "contactMenu", this);
}
menu.observe("hideMenu", onContactContextMenuHide);
popupMenu(event, "contactMenu", this);
}
function onContactContextMenuHide(event) {
@@ -260,8 +252,10 @@ function contactLoadCallback(http) {
cachedContacts[currentAddressBook + "/" + http.callbackData] = content;
div.innerHTML = content;
}
else
else {
log ("ajax problem 2: " + http.status);
refreshCurrentFolder();
}
}
var rowSelectionCount = 0;
@@ -315,17 +309,11 @@ function onContactSelectionChange(event) {
}
function onMenuEditContact(event) {
var contactId = document.menuTarget.getAttribute('id');
openContactWindow(URLForFolderID(currentAddressBook)
+ "/" + contactId + "/edit", contactId);
onToolbarEditSelectedContacts(event);
}
function onMenuWriteToContact(event) {
var contactId = document.menuTarget.getAttribute('id');
openMailComposeWindow(ApplicationBaseURL + currentAddressBook
+ "/" + contactId + "/write");
onToolbarWriteToSelectedContacts(event);
if (document.body.hasClassName("popup"))
window.close();
@@ -339,7 +327,7 @@ function onMenuAIMContact(event) {
}
function onMenuDeleteContact(event) {
uixDeleteSelectedContacts(this);
onToolbarDeleteSelectedContacts(event);
}
function onToolbarEditSelectedContacts(event) {
@@ -369,65 +357,46 @@ function onToolbarWriteToSelectedContacts(event) {
return false;
}
for (var i = 0; i < rows.length; i++) {
var emailCell = $(rows[i]).down('td', 1);
if (emailCell.firstChild) { // .nodeValue is the contact email address
rowsWithEmail++;
openMailComposeWindow(ApplicationBaseURL + currentAddressBook
+ "/" + rows[i] + "/write");
}
}
openMailComposeWindow(ApplicationBaseURL + "../Mail/compose"
+ "?folder=" + currentAddressBook.substring(1)
+ "&uid=" + rows.join("&uid="));
if (rowsWithEmail == 0) {
window.alert(labels["The selected contact has no email address."]);
}
else if (document.body.hasClassName("popup"))
if (document.body.hasClassName("popup"))
window.close();
return false;
}
function uixDeleteSelectedContacts(sender) {
var failCount = 0;
function onToolbarDeleteSelectedContacts(event) {
var contactsList = $('contactsList');
var rows = contactsList.getSelectedRowsId();
if (rows.length == 0) {
window.alert(labels["Please select a contact."]);
return false;
}
var contactView = $('contactView');
for (var i = 0; i < rows.length; i++) {
var url, http, rowElem;
/* send AJAX request (synchronously) */
var url;
url = (URLForFolderID(currentAddressBook) + "/"
+ rows[i] + "/delete");
http = createHTTPClient();
http.open("POST", url, false /* not async */);
http.send("");
http.setRequestHeader("Content-Length", 0);
if (http.status != 200) { /* request failed */
failCount++;
http = null;
continue;
}
http = null;
/* remove from page */
/* line-through would be nicer, but hiding is OK too */
rowElem = $(rows[i]);
rowElem.parentNode.removeChild(rowElem);
new Ajax.Request(url, {
method: 'post',
onFailure: function(transport) {
log("Ajax error: can't delete contact");
refreshCurrentFolder();
},
onSuccess: function(transport) {
var row = $(transport.responseText.trim());
if (row)
row.parentNode.removeChild(row);
}
});
}
if (failCount > 0)
alert(labels["You cannot delete the selected contact(s)"]);
else
contactView.update();
contactView.update();
return false;
}
+18 -29
View File
@@ -221,9 +221,9 @@ function openMailComposeWindow(url, wId) {
parentWindow = window.opener;
var w = parentWindow.open(url, wId,
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
+ "location=0,directories=0,status=0,menubar=0"
+ ",copyhistory=0");
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
+ "location=0,directories=0,status=0,menubar=0"
+ ",copyhistory=0");
w.focus();
@@ -514,7 +514,7 @@ function acceptMultiSelect(node) {
function onRowClick(event) {
var node = getTarget(event);
var rowIndex = null;
if (node.tagName == 'TD') {
node = node.parentNode; // select TR
rowIndex = node.rowIndex - $(node).up('table').down('thead').getElementsByTagName('tr').length;
@@ -524,27 +524,29 @@ function onRowClick(event) {
var list = node.parentNode;
var items = list.childNodesWithTag("li");
for (var i = 0; i < items.length; i++) {
if (items[i] == node) {
rowIndex = i;
break;
if (items[i] == node) {
rowIndex = i;
break;
}
}
}
var initialSelection = $(node.parentNode).getSelectedNodes();
if (initialSelection.length > 0
&& initialSelection.indexOf(node) >= 0
&& !Event.isLeftClick(event))
&& (!isSafari() && !Event.isLeftClick(event) ||
isSafari() && event.ctrlKey == 1)) // Event.isLeftClick is not supported in Safari
// Ignore non primary-click (ie right-click) inside current selection
return true;
if ((event.shiftKey == 1 || event.ctrlKey == 1)
if ((event.shiftKey == 1 || event.metaKey == 1)
&& (lastClickedRow >= 0)
&& (acceptMultiSelect(node.parentNode)
|| acceptMultiSelect(node.parentNode.parentNode))) {
if (event.shiftKey)
if (event.shiftKey) {
$(node.parentNode).selectRange(lastClickedRow, rowIndex);
else if (isNodeSelected(node) == true) {
} else if (isNodeSelected(node)) {
$(node).deselect();
} else {
$(node).selectElement();
@@ -554,7 +556,7 @@ function onRowClick(event) {
// Single line selection
$(node.parentNode).deselectAll();
$(node).selectElement();
if (initialSelection != $(node.parentNode).getSelectedNodes()) {
// Selection has changed; fire mousedown event
var parentNode = node.parentNode;
@@ -564,14 +566,12 @@ function onRowClick(event) {
}
}
lastClickedRow = rowIndex;
return true;
}
/* popup menus */
// var acceptClick = false;
function popupMenu(event, menuId, target) {
document.menuTarget = target;
@@ -614,7 +614,7 @@ function popupMenu(event, menuId, target) {
$(document.body).observe("click", onBodyClickMenuHandler);
preventDefault(event);
Event.stop(event);
}
function getParentMenu(node) {
@@ -1131,7 +1131,6 @@ function getListIndexForFolder(items, owner, folderName) {
function listRowMouseDownHandler(event) {
preventDefault(event);
//Event.stop(event);
}
/* tabs */
@@ -1387,16 +1386,6 @@ function onLoadHandler(event) {
if (progressImage)
progressImage.parentNode.removeChild(progressImage);
$(document.body).observe("contextmenu", onBodyClickContextMenu);
/* $(document.body).observe("click", testclic); */
}
function testclic(event) {
log("test: " + event.target);
if (event.target) {
log("tag: " + event.target.tagName);
log("id: " + event.target.getAttribute("id"));
log("class: " + event.target.getAttribute("class"));
}
}
function onBodyClickContextMenu(event) {