Reindent
Monotone-Parent: 0c24951c6f23e1c5c5c97871b0a535b026ad55e4 Monotone-Revision: a59de74b19da8d53c1a14d3367e1483cf06fb02e Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2009-10-02T13:41:49 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
79e582d9e9
commit
d67529eed0
|
@ -15,93 +15,93 @@ var SOGoAutoCompletionInterface = {
|
|||
endEditable: null,
|
||||
|
||||
bind: function () {
|
||||
this.menu = $('contactsMenu');
|
||||
this.writeAttribute("autocomplete", "off");
|
||||
this.observe("keydown", this.onKeydown.bindAsEventListener(this));
|
||||
this.observe("blur", this.onBlur.bindAsEventListener(this));
|
||||
this.menu = $('contactsMenu');
|
||||
this.writeAttribute("autocomplete", "off");
|
||||
this.observe("keydown", this.onKeydown.bindAsEventListener(this));
|
||||
this.observe("blur", this.onBlur.bindAsEventListener(this));
|
||||
},
|
||||
|
||||
onKeydown: function (event) {
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
this.focussed = true;
|
||||
return;
|
||||
}
|
||||
if (event.keyCode == Event.KEY_TAB) {
|
||||
if (this.confirmedValue)
|
||||
this.value = this.confirmedValue;
|
||||
else
|
||||
this.uid = null;
|
||||
if (document.currentPopupMenu)
|
||||
hideMenu(document.currentPopupMenu);
|
||||
if (this.endEditable)
|
||||
this.endEditable ();
|
||||
if (this.onListAdded)
|
||||
this.onListAdded ();
|
||||
}
|
||||
else if (event.keyCode == 0
|
||||
|| event.keyCode == Event.KEY_BACKSPACE
|
||||
|| event.keyCode == 32 // Space
|
||||
|| event.keyCode > 47) {
|
||||
this.confirmedValue = null;
|
||||
this.selectedIndex = -1;
|
||||
if (this.delayedSearch)
|
||||
window.clearTimeout(this.delayedSearch);
|
||||
this.delayedSearch = this.performSearch.delay(this.delay, this);
|
||||
}
|
||||
else if (event.keyCode == Event.KEY_RETURN) {
|
||||
preventDefault(event);
|
||||
if (this.confirmedValue)
|
||||
this.value = this.confirmedValue;
|
||||
$(this).select();
|
||||
if (document.currentPopupMenu)
|
||||
hideMenu(document.currentPopupMenu);
|
||||
this.selectedIndex = -1;
|
||||
if (this.endEditable)
|
||||
this.endEditable ();
|
||||
if (this.onListAdded)
|
||||
this.onListAdded ();
|
||||
}
|
||||
else if (this.menu.getStyle('visibility') == 'visible') {
|
||||
if (event.keyCode == Event.KEY_UP) { // Up arrow
|
||||
if (this.selectedIndex > 0) {
|
||||
var contacts = this.menu.select("li");
|
||||
contacts[this.selectedIndex--].removeClassName("selected");
|
||||
this.value = contacts[this.selectedIndex].readAttribute("address");
|
||||
this.uid = contacts[this.selectedIndex].uid;
|
||||
contacts[this.selectedIndex].addClassName("selected");
|
||||
var e = contacts[this.selectedIndex];
|
||||
this.writeAttribute("card", e.readAttribute("card"));
|
||||
this.writeAttribute("mail", e.readAttribute("mail"));
|
||||
this.writeAttribute("uname", e.readAttribute("uname"));
|
||||
this.writeAttribute("container", e.readAttribute("container"));
|
||||
}
|
||||
}
|
||||
else if (event.keyCode == Event.KEY_DOWN) { // Down arrow
|
||||
var contacts = this.menu.select("li");
|
||||
if (contacts.size() - 1 > this.selectedIndex) {
|
||||
if (this.selectedIndex >= 0)
|
||||
contacts[this.selectedIndex].removeClassName("selected");
|
||||
this.selectedIndex++;
|
||||
this.value = contacts[this.selectedIndex].readAttribute("address");
|
||||
this.uid = contacts[this.selectedIndex].uid;
|
||||
contacts[this.selectedIndex].addClassName("selected");
|
||||
var e = contacts[this.selectedIndex];
|
||||
this.writeAttribute("card", e.readAttribute("card"));
|
||||
this.writeAttribute("mail", e.readAttribute("mail"));
|
||||
this.writeAttribute("uname", e.readAttribute("uname"));
|
||||
this.writeAttribute("container", e.readAttribute("container"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
this.focussed = true;
|
||||
return;
|
||||
}
|
||||
if (event.keyCode == Event.KEY_TAB) {
|
||||
if (this.confirmedValue)
|
||||
this.value = this.confirmedValue;
|
||||
else
|
||||
this.uid = null;
|
||||
if (document.currentPopupMenu)
|
||||
hideMenu(document.currentPopupMenu);
|
||||
if (this.endEditable)
|
||||
this.endEditable ();
|
||||
if (this.onListAdded)
|
||||
this.onListAdded ();
|
||||
}
|
||||
else if (event.keyCode == 0
|
||||
|| event.keyCode == Event.KEY_BACKSPACE
|
||||
|| event.keyCode == 32 // Space
|
||||
|| event.keyCode > 47) {
|
||||
this.confirmedValue = null;
|
||||
this.selectedIndex = -1;
|
||||
if (this.delayedSearch)
|
||||
window.clearTimeout(this.delayedSearch);
|
||||
this.delayedSearch = this.performSearch.delay(this.delay, this);
|
||||
}
|
||||
else if (event.keyCode == Event.KEY_RETURN) {
|
||||
preventDefault(event);
|
||||
if (this.confirmedValue)
|
||||
this.value = this.confirmedValue;
|
||||
$(this).select();
|
||||
if (document.currentPopupMenu)
|
||||
hideMenu(document.currentPopupMenu);
|
||||
this.selectedIndex = -1;
|
||||
if (this.endEditable)
|
||||
this.endEditable ();
|
||||
if (this.onListAdded)
|
||||
this.onListAdded ();
|
||||
}
|
||||
else if (this.menu.getStyle('visibility') == 'visible') {
|
||||
if (event.keyCode == Event.KEY_UP) { // Up arrow
|
||||
if (this.selectedIndex > 0) {
|
||||
var contacts = this.menu.select("li");
|
||||
contacts[this.selectedIndex--].removeClassName("selected");
|
||||
this.value = contacts[this.selectedIndex].readAttribute("address");
|
||||
this.uid = contacts[this.selectedIndex].uid;
|
||||
contacts[this.selectedIndex].addClassName("selected");
|
||||
var e = contacts[this.selectedIndex];
|
||||
this.writeAttribute("card", e.readAttribute("card"));
|
||||
this.writeAttribute("mail", e.readAttribute("mail"));
|
||||
this.writeAttribute("uname", e.readAttribute("uname"));
|
||||
this.writeAttribute("container", e.readAttribute("container"));
|
||||
}
|
||||
}
|
||||
else if (event.keyCode == Event.KEY_DOWN) { // Down arrow
|
||||
var contacts = this.menu.select("li");
|
||||
if (contacts.size() - 1 > this.selectedIndex) {
|
||||
if (this.selectedIndex >= 0)
|
||||
contacts[this.selectedIndex].removeClassName("selected");
|
||||
this.selectedIndex++;
|
||||
this.value = contacts[this.selectedIndex].readAttribute("address");
|
||||
this.uid = contacts[this.selectedIndex].uid;
|
||||
contacts[this.selectedIndex].addClassName("selected");
|
||||
var e = contacts[this.selectedIndex];
|
||||
this.writeAttribute("card", e.readAttribute("card"));
|
||||
this.writeAttribute("mail", e.readAttribute("mail"));
|
||||
this.writeAttribute("uname", e.readAttribute("uname"));
|
||||
this.writeAttribute("container", e.readAttribute("container"));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onBlur: function (event) {
|
||||
if (this.delayedSearch)
|
||||
window.clearTimeout(this.delayedSearch);
|
||||
window.clearTimeout(this.delayedSearch);
|
||||
if (this.confirmedValue)
|
||||
this.value = this.confirmedValue;
|
||||
this.value = this.confirmedValue;
|
||||
else
|
||||
this.uid = null;
|
||||
this.uid = null;
|
||||
},
|
||||
|
||||
performSearch: function (input) {
|
||||
|
@ -115,19 +115,19 @@ var SOGoAutoCompletionInterface = {
|
|||
var urlstr = (UserFolderURL + "Contacts/allContactSearch?search="
|
||||
+ encodeURIComponent(input.value));
|
||||
if (input.baseUrl)
|
||||
urlstr = input.baseUrl + encodeURIComponent(input.value);
|
||||
urlstr = input.baseUrl + encodeURIComponent(input.value);
|
||||
if (input.excludeGroups)
|
||||
urlstr += "&excludeGroups=1";
|
||||
urlstr += "&excludeGroups=1";
|
||||
if (input.excludeLists)
|
||||
urlstr += "&excludeLists=1";
|
||||
urlstr += "&excludeLists=1";
|
||||
if (input.animationParent)
|
||||
startAnimation(input.animationParent);
|
||||
startAnimation(input.animationParent);
|
||||
document.contactLookupAjaxRequest =
|
||||
triggerAjaxRequest(urlstr, input.performSearchCallback.bind(input), input);
|
||||
triggerAjaxRequest(urlstr, input.performSearchCallback.bind(input), input);
|
||||
}
|
||||
else {
|
||||
if (document.currentPopupMenu)
|
||||
hideMenu(document.currentPopupMenu);
|
||||
hideMenu(document.currentPopupMenu);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -143,16 +143,16 @@ var SOGoAutoCompletionInterface = {
|
|||
|
||||
if (data.contacts.length > 1) {
|
||||
list.select("li").each(function(item) {
|
||||
item.stopObserving("mousedown");
|
||||
item.remove();
|
||||
});
|
||||
item.stopObserving("mousedown");
|
||||
item.remove();
|
||||
});
|
||||
|
||||
// Populate popup menu
|
||||
for (var i = 0; i < data.contacts.length; i++) {
|
||||
var contact = data.contacts[i];
|
||||
var completeEmail = contact["c_cn"];
|
||||
if (contact["c_mail"])
|
||||
completeEmail += " <" + contact["c_mail"] + ">";
|
||||
completeEmail += " <" + contact["c_mail"] + ">";
|
||||
var node = new Element('li', { 'address': completeEmail });
|
||||
var matchPosition = completeEmail.toLowerCase().indexOf(data.searchText.toLowerCase());
|
||||
var matchBefore = completeEmail.substring(0, matchPosition);
|
||||
|
@ -173,7 +173,7 @@ var SOGoAutoCompletionInterface = {
|
|||
node.appendChild(new Element('strong').update(matchText));
|
||||
node.appendChild(document.createTextNode(matchAfter));
|
||||
if (contact["contactInfo"])
|
||||
node.appendChild(document.createTextNode(" (" + contact["contactInfo"] + ")"));
|
||||
node.appendChild(document.createTextNode(" (" + contact["contactInfo"] + ")"));
|
||||
$(node).observe("mousedown", this.onAddressResultClick.bindAsEventListener(this));
|
||||
}
|
||||
|
||||
|
@ -186,13 +186,13 @@ var SOGoAutoCompletionInterface = {
|
|||
var nodeHeight = node.getHeight();
|
||||
|
||||
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';
|
||||
// Limit the size of the popup to the window height, minus 12 pixels
|
||||
height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px';
|
||||
|
||||
this.menu.setStyle({ top: top + "px",
|
||||
left: offset[0] + "px",
|
||||
height: height,
|
||||
visibility: "visible" });
|
||||
left: offset[0] + "px",
|
||||
height: height,
|
||||
visibility: "visible" });
|
||||
this.menu.scrollTop = 0;
|
||||
|
||||
document.currentPopupMenu = this.menu;
|
||||
|
@ -201,7 +201,7 @@ var SOGoAutoCompletionInterface = {
|
|||
}
|
||||
else { // Only one result
|
||||
if (document.currentPopupMenu)
|
||||
hideMenu(document.currentPopupMenu);
|
||||
hideMenu(document.currentPopupMenu);
|
||||
|
||||
if (data.contacts.length == 1) {
|
||||
// Single result
|
||||
|
@ -219,10 +219,10 @@ var SOGoAutoCompletionInterface = {
|
|||
var completeEmail = contact["c_cn"] + " <" + contact["c_mail"] + ">";
|
||||
if (contact["c_cn"].substring(0, input.value.length).toUpperCase()
|
||||
== input.value.toUpperCase())
|
||||
input.value = completeEmail;
|
||||
input.value = completeEmail;
|
||||
else
|
||||
// The result matches email address, not user name
|
||||
input.value += ' >> ' + completeEmail;
|
||||
// The result matches email address, not user name
|
||||
input.value += ' >> ' + completeEmail;
|
||||
input.confirmedValue = completeEmail;
|
||||
|
||||
var end = input.value.length;
|
||||
|
@ -234,8 +234,8 @@ var SOGoAutoCompletionInterface = {
|
|||
}
|
||||
}
|
||||
else
|
||||
if (document.currentPopupMenu)
|
||||
hideMenu(document.currentPopupMenu);
|
||||
if (document.currentPopupMenu)
|
||||
hideMenu(document.currentPopupMenu);
|
||||
document.contactLookupAjaxRequest = null;
|
||||
}
|
||||
},
|
||||
|
@ -243,7 +243,7 @@ var SOGoAutoCompletionInterface = {
|
|||
onAddressResultClick: function(event) {
|
||||
var e = Event.element(event);
|
||||
if (e.tagName != 'LI')
|
||||
e = e.up('LI');
|
||||
e = e.up('LI');
|
||||
if (e) {
|
||||
var card = e.readAttribute("card");
|
||||
this.writeAttribute("card", card);
|
||||
|
@ -259,7 +259,7 @@ var SOGoAutoCompletionInterface = {
|
|||
this.value = e.readAttribute("address");
|
||||
this.confirmedValue = this.value;
|
||||
if (this.endEditable)
|
||||
this.endEditable ();
|
||||
this.endEditable ();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue