diff --git a/mailnews/addrbook/resources/content/abCommon.js b/mailnews/addrbook/resources/content/abCommon.js index 162563d1bb5..1af6d04bbcd 100644 --- a/mailnews/addrbook/resources/content/abCommon.js +++ b/mailnews/addrbook/resources/content/abCommon.js @@ -40,6 +40,7 @@ var gResultsOutliner = 0; var dirTree = 0; +var abList = 0; var gAbView = null; var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); @@ -226,6 +227,7 @@ function AbEditSelectedDirectory() function InitCommonJS() { dirTree = document.getElementById("dirTree"); + abList = document.getElementById("addressbookList"); gResultsOutliner = document.getElementById("abResultsOutliner"); } diff --git a/mailnews/addrbook/resources/content/abDirTreeOverlay.xul b/mailnews/addrbook/resources/content/abDirTreeOverlay.xul index d7831f7beda..b3a3ec53e36 100644 --- a/mailnews/addrbook/resources/content/abDirTreeOverlay.xul +++ b/mailnews/addrbook/resources/content/abDirTreeOverlay.xul @@ -39,7 +39,7 @@ Contributors: ref="moz-abdirectory://" datasources="rdf:addressdirectory" containment="http://home.netscape.com/NC-rdf#child" - onselect="DirPaneSelectionChange(); document.commandDispatcher.updateCommands('tree-select');" + onselect="DirPaneSelectionChange(); document.commandDispatcher.updateCommands('addrbook-select');" onclick="DirPaneClick(event);" ondblclick="DirPaneDoubleClick();" onblur="goOnEvent(this,'blur')" diff --git a/mailnews/addrbook/resources/content/abSelectAddressesDialog.js b/mailnews/addrbook/resources/content/abSelectAddressesDialog.js index 4c09e1e26a0..373dd0018a9 100644 --- a/mailnews/addrbook/resources/content/abSelectAddressesDialog.js +++ b/mailnews/addrbook/resources/content/abSelectAddressesDialog.js @@ -30,6 +30,10 @@ var editCardCallback = 0; var gAddressBookBundle; +var gSearchInput; +var gSearchTimer = null; +var gQueryURIFormat = null; + // localization strings var prefixTo; var prefixCc; @@ -90,9 +94,20 @@ function OnLoadSelectAddress() AddAddressFromComposeWindow(bccAddress, prefixBcc); } - SelectFirstAddressBook(); + gSearchInput = document.getElementById("searchInput"); + SearchInputChanged(); + + SelectFirstAddressBookMenulist(); DialogBucketPaneSelectionChanged(); + + var workPhoneCol = document.getElementById("WorkPhone"); + workPhoneCol.setAttribute("hidden", "true"); + + var companyCol = document.getElementById("Company"); + companyCol.setAttribute("hidden", "true"); + + document.documentElement.addEventListener("keypress", OnReturnHit, true); } function OnUnloadSelectAddress() @@ -358,3 +373,86 @@ function DropOnBucketPane(event) AddAddressIntoBucket(prefixTo + address, address); } } + +function OnReturnHit(event) +{ + if (event.keyCode == 13 && (document.commandDispatcher.focusedElement == gSearchInput.inputField)) + event.preventBubble(); +} + +function onEnterInSearchBar() +{ + var selectedNode = abList.selectedItem; + + if (!selectedNode) + return; + + if (!gQueryURIFormat) { + gQueryURIFormat = gPrefs.getCharPref("mail.addr_book.quicksearchquery.format"); + } + + var sortColumn = selectedNode.getAttribute("sortColumn"); + var sortDirection = selectedNode.getAttribute("sortDirection"); + var searchURI = selectedNode.getAttribute("id"); + + if (gSearchInput.value != "") { + searchURI += gQueryURIFormat.replace(/@V/g, escape(gSearchInput.value)); + } + + SetAbView(searchURI, sortColumn, sortDirection); + + SelectFirstCard(); +} + +function onAbSearchInputMenulist(event) +{ + SearchInputChanged(); + + if (gSearchTimer) { + clearTimeout(gSearchTimer); + gSearchTimer = null; + } + + if (event && event.keyCode == 13) { + onEnterInSearchBar(); + } + else { + gSearchTimer = setTimeout("onEnterInSearchBar();", 800); + } +} + +function onAbSearchReset(event) +{ + gSearchInput.value = ""; + ChangeDirectoryByDOMNode(abList.selectedItem); + + SearchInputChanged(); + + onReset(event); +} + +function SearchInputChanged() { + var clearButton = document.getElementById("clear"); + if (clearButton) { + if (gSearchInput.value && (gSearchInput.value != "")) + clearButton.removeAttribute("disabled"); + else + clearButton.setAttribute("disabled", "true"); + } +} + +function SelectFirstAddressBookMenulist() +{ + ChangeDirectoryByDOMNode(abList.selectedItem); + return; +} + +function DirPaneSelectionChangeMenulist() +{ + if (abList && abList.selectedItem) { + if (gSearchInput.value && (gSearchInput.value != "")) + onEnterInSearchBar(); + else + ChangeDirectoryByDOMNode(abList.selectedItem); + } +} diff --git a/mailnews/addrbook/resources/content/abSelectAddressesDialog.xul b/mailnews/addrbook/resources/content/abSelectAddressesDialog.xul index e1fa1747782..0f88c3891f0 100644 --- a/mailnews/addrbook/resources/content/abSelectAddressesDialog.xul +++ b/mailnews/addrbook/resources/content/abSelectAddressesDialog.xul @@ -40,6 +40,7 @@ Contributor(s): - - - - - - - - - - - - - - - - - - - - - - - - -