Monotone-Parent: 717b1106bd82a838188f97c4b88f9caa35e59586

Monotone-Revision: 459d0175f983b6e31e8957fa80969a4b335469cb

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2008-10-03T23:12:11
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle
2008-10-03 23:12:11 +00:00
parent 53a1764c22
commit c8778a820d
9 changed files with 158 additions and 63 deletions
+21 -13
View File
@@ -69,23 +69,23 @@ function onContactKeydown(event) {
}
else if ($('attendeesMenu').getStyle('visibility') == 'visible') {
attendeesEditor.currentField = this;
if (event.keyCode == 38) { // Up arrow
if (event.keyCode == Event.KEY_UP) { // Up arrow
if (attendeesEditor.selectedIndex > 0) {
var attendees = $('attendeesMenu').select("li");
attendees[attendeesEditor.selectedIndex--].removeClassName("selected");
attendees[attendeesEditor.selectedIndex].addClassName("selected");
this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].firstChild.nodeValue.trim();
this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].readAttribute("address");
this.uid = attendees[attendeesEditor.selectedIndex].uid;
}
}
else if (event.keyCode == 40) { // Down arrow
else if (event.keyCode == Event.KEY_DOWN) { // Down arrow
var attendees = $('attendeesMenu').select("li");
if (attendees.size() - 1 > attendeesEditor.selectedIndex) {
if (attendeesEditor.selectedIndex >= 0)
attendees[attendeesEditor.selectedIndex].removeClassName("selected");
attendeesEditor.selectedIndex++;
attendees[attendeesEditor.selectedIndex].addClassName("selected");
this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].firstChild.nodeValue.trim();
this.value = this.confirmedValue = attendees[attendeesEditor.selectedIndex].readAttribute("address");
this.uid = attendees[attendeesEditor.selectedIndex].uid;
}
}
@@ -121,19 +121,27 @@ function performSearchCallback(http) {
var start = input.value.length;
var data = http.responseText.evalJSON(true);
if (data.length > 1) {
if (data.contacts.length > 1) {
$(list.childNodesWithTag("li")).each(function(item) {
item.remove();
});
// Populate popup menu
for (var i = 0; i < data.length; i++) {
var contact = data[i];
for (var i = 0; i < data.contacts.length; i++) {
var contact = data.contacts[i];
var completeEmail = contact["name"] + " <" + contact["email"] + ">";
var node = document.createElement("li");
var node = new Element('li', { 'address': completeEmail });
var matchPosition = completeEmail.toLowerCase().indexOf(data.searchText.toLowerCase());
var matchBefore = completeEmail.substring(0, matchPosition);
var matchText = completeEmail.substring(matchPosition, matchPosition + data.searchText.length);
var matchAfter = completeEmail.substring(matchPosition + data.searchText.length);
list.appendChild(node);
node.uid = contact["uid"];
node.appendChild(document.createTextNode(completeEmail));
node.appendChild(document.createTextNode(matchBefore));
node.appendChild(new Element('strong').update(matchText));
node.appendChild(document.createTextNode(matchAfter));
if (contact["contactInfo"])
node.appendChild(document.createTextNode(" (" + contact["contactInfo"] + ")"));
$(node).observe("mousedown", onAttendeeResultClick);
}
@@ -145,7 +153,7 @@ function performSearchCallback(http) {
var heightDiff = window.height() - offset[1];
var nodeHeight = node.getHeight();
if ((data.length * nodeHeight) > heightDiff)
if ((data.contacts.length * nodeHeight) > heightDiff)
// Limit the size of the popup to the window height, minus 12 pixels
height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px';
@@ -162,9 +170,9 @@ function performSearchCallback(http) {
if (document.currentPopupMenu)
hideMenu(document.currentPopupMenu);
if (data.length == 1) {
if (data.contacts.length == 1) {
// Single result
var contact = data[0];
var contact = data.contacts[0];
if (contact["uid"].length > 0)
input.uid = contact["uid"];
var completeEmail = contact["name"] + " <" + contact["email"] + ">";
@@ -192,7 +200,7 @@ function performSearchCallback(http) {
function onAttendeeResultClick(event) {
if (attendeesEditor.currentField) {
attendeesEditor.currentField.uid = this.uid;
attendeesEditor.currentField.value = this.firstChild.nodeValue.trim();
attendeesEditor.currentField.value = $(this).readAttribute("address");
attendeesEditor.currentField.confirmedValue = attendeesEditor.currentField.value;
attendeesEditor.currentField.blur(); // triggers checkAttendee function call
}
@@ -25,6 +25,8 @@ function addLineToTree(tree, parent, line) {
var parentNode = nodes[0];
var userInfos = parentNode.split(":");
var email = userInfos[1] + " &lt;" + userInfos[2] + "&gt;";
if (!userInfos[3].empty())
email += " (" + userInfos[3] + ")"; // extra contact info
tree.add(parent, 0, email, 0, '#', userInfos[0], 'person',
'', '',
ResourcesURL + '/abcard.gif',
+20 -12
View File
@@ -387,7 +387,7 @@ function onContactKeydown(event) {
if (MailEditor.selectedIndex > 0) {
var contacts = $('contactsMenu').select("li");
contacts[MailEditor.selectedIndex--].removeClassName("selected");
this.value = contacts[MailEditor.selectedIndex].firstChild.nodeValue.trim();
this.value = contacts[MailEditor.selectedIndex].readAttribute("address");
contacts[MailEditor.selectedIndex].addClassName("selected");
}
}
@@ -397,7 +397,7 @@ function onContactKeydown(event) {
if (MailEditor.selectedIndex >= 0)
contacts[MailEditor.selectedIndex].removeClassName("selected");
MailEditor.selectedIndex++;
this.value = contacts[MailEditor.selectedIndex].firstChild.nodeValue.trim();
this.value = contacts[MailEditor.selectedIndex].readAttribute("address");
contacts[MailEditor.selectedIndex].addClassName("selected");
}
}
@@ -431,20 +431,28 @@ function performSearchCallback(http) {
if (http.status == 200) {
var start = input.value.length;
var data = http.responseText.evalJSON(true);
if (data.length > 1) {
if (data.contacts.length > 1) {
list.select("li").each(function(item) {
item.remove();
});
// Populate popup menu
for (var i = 0; i < data.length; i++) {
var contact = data[i];
for (var i = 0; i < data.contacts.length; i++) {
var contact = data.contacts[i];
var completeEmail = contact["displayName"] + " <" + contact["mail"] + ">";
var node = document.createElement("li");
var node = new Element('li', { 'address': completeEmail });
var matchPosition = completeEmail.toLowerCase().indexOf(data.searchText.toLowerCase());
var matchBefore = completeEmail.substring(0, matchPosition);
var matchText = completeEmail.substring(matchPosition, matchPosition + data.searchText.length);
var matchAfter = completeEmail.substring(matchPosition + data.searchText.length);
list.appendChild(node);
node.uid = contact["c_uid"];
node.appendChild(document.createTextNode(completeEmail));
node.appendChild(document.createTextNode(matchBefore));
node.appendChild(new Element('strong').update(matchText));
node.appendChild(document.createTextNode(matchAfter));
if (contact["contactInfo"])
node.appendChild(document.createTextNode(" (" + contact["contactInfo"] + ")"));
$(node).observe("mousedown", onAddressResultClick);
}
@@ -456,7 +464,7 @@ function performSearchCallback(http) {
var heightDiff = window.height() - offset[1];
var nodeHeight = node.getHeight();
if ((data.length * nodeHeight) > heightDiff)
if ((data.contacts.length * nodeHeight) > heightDiff)
// Limit the size of the popup to the window height, minus 12 pixels
height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px';
@@ -473,9 +481,9 @@ function performSearchCallback(http) {
if (document.currentPopupMenu)
hideMenu(document.currentPopupMenu);
if (data.length == 1) {
if (data.contacts.length == 1) {
// Single result
var contact = data[0];
var contact = data.contacts[0];
if (contact["c_uid"].length > 0)
input.uid = contact["c_uid"];
var completeEmail = contact["displayName"] + " <" + contact["mail"] + ">";
@@ -504,7 +512,7 @@ function performSearchCallback(http) {
function onAddressResultClick(event) {
if (MailEditor.currentField) {
MailEditor.currentField.uid = this.uid;
MailEditor.currentField.value = this.firstChild.nodeValue.trim();
MailEditor.currentField.value = $(this).readAttribute("address");
MailEditor.currentField.confirmedValue = MailEditor.currentField.value;
}
}