From 8f2c9ebf324da3346b0ccb7b4bb931c75cfaf7b4 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 19 Feb 2009 22:22:34 +0000 Subject: [PATCH] Improved auto-completion in webmail module Monotone-Parent: 72263a3947a24816b683ce7865dc0f738b476aee Monotone-Revision: 28e932f280315e68f641452599d35da2b2a167d3 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2009-02-19T22:22:34 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/UIxMailEditor.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/UI/WebServerResources/UIxMailEditor.js b/UI/WebServerResources/UIxMailEditor.js index 6ecd24b68..4a17350c5 100644 --- a/UI/WebServerResources/UIxMailEditor.js +++ b/UI/WebServerResources/UIxMailEditor.js @@ -362,14 +362,9 @@ function onContactKeydown(event) { this.confirmedValue = null; MailEditor.selectedIndex = -1; MailEditor.currentField = this; - if (this.value.length > 1) { - if (MailEditor.delayedSearch) window.clearTimeout(MailEditor.delayedSearch); - MailEditor.delayedSearch = window.setTimeout("performSearch()", MailEditor.delay); - } - else if (this.value.length <= 1) { - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - } + if (MailEditor.delayedSearch) + window.clearTimeout(MailEditor.delayedSearch); + MailEditor.delayedSearch = window.setTimeout("performSearch()", MailEditor.delay); } else if (event.keyCode == Event.KEY_RETURN) { preventDefault(event); @@ -402,6 +397,12 @@ function onContactKeydown(event) { } } +function onContactBlur(event) { + if (MailEditor.delayedSearch) + window.clearTimeout(MailEditor.delayedSearch); + MailEditor.currentField = null; +} + function performSearch() { // Perform address completion if (MailEditor.currentField) { @@ -410,12 +411,16 @@ function performSearch() { document.contactLookupAjaxRequest.aborted = true; document.contactLookupAjaxRequest.abort(); } - if (MailEditor.currentField.value.trim().length > 1) { + if (MailEditor.currentField.value.trim().length > 2) { var urlstr = (UserFolderURL + "Contacts/allContactSearch?search=" + encodeURIComponent(MailEditor.currentField.value)); document.contactLookupAjaxRequest = triggerAjaxRequest(urlstr, performSearchCallback, MailEditor.currentField); } + else { + if (document.currentPopupMenu) + hideMenu(document.currentPopupMenu); + } } } @@ -521,6 +526,7 @@ function initTabIndex(addressList, subjectField, msgArea) { input.writeAttribute("tabindex", i++); input.writeAttribute("autocomplete", "off"); input.observe("keydown", onContactKeydown); // bind listener for address completion + input.observe("blur", onContactBlur); } }); subjectField.writeAttribute("tabindex", i++);