diff --git a/mailnews/addrbook/resources/content/abCardViewOverlay.js b/mailnews/addrbook/resources/content/abCardViewOverlay.js index 4864467521c4..d2ba3d72003e 100644 --- a/mailnews/addrbook/resources/content/abCardViewOverlay.js +++ b/mailnews/addrbook/resources/content/abCardViewOverlay.js @@ -17,8 +17,10 @@ * Copyright (C) 1998-1999 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Original Author: * Paul Hangas + * + * Contributor(s): * Alec Flett * Seth Spitzer */ @@ -29,6 +31,8 @@ var gPrefs = Components.classes["@mozilla.org/preferences-service;1"]; gPrefs = gPrefs.getService(); gPrefs = gPrefs.QueryInterface(Components.interfaces.nsIPrefBranch); +var gMapItURLFormat = gPrefs.getCharPref("mail.addr_book.mapit_url.format"); + var gAddrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession); var zName; @@ -370,11 +374,10 @@ function MapIt(id) function CreateMapItURL(address1, address2, city, state, zip, country) { - var urlFormat = gPrefs.getCharPref("mail.addr_book.mapit_url.format"); - if (!urlFormat) + if (!gMapItURLFormat) return null; - urlFormat = urlFormat.replace("@A1", escape(address1)); + var urlFormat = gMapItURLFormat.replace("@A1", escape(address1)); urlFormat = urlFormat.replace("@A2", escape(address2)); urlFormat = urlFormat.replace("@CO", escape(country)); urlFormat = urlFormat.replace("@CI", escape(city)); diff --git a/mailnews/addrbook/resources/content/abCommon.js b/mailnews/addrbook/resources/content/abCommon.js index b8fc71b31f19..8415dca05c24 100644 --- a/mailnews/addrbook/resources/content/abCommon.js +++ b/mailnews/addrbook/resources/content/abCommon.js @@ -42,13 +42,16 @@ var gResultsOutliner = 0; var dirTree = 0; var gAbView = null; -const kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab"; -const kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab"; - var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService); var gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); var gHeaderParser = Components.classes["@mozilla.org/messenger/headerparser;1"].getService(Components.interfaces.nsIMsgHeaderParser); +const kDefaultSortColumn = "GeneratedName"; +const kDefaultAscending = "ascending"; +const kDefaultDescending = "descending"; +const kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab"; +const kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab"; + // Controller object for Results Pane var ResultsPaneController = { @@ -481,6 +484,22 @@ function SelectFirstCard() } } +function DirPaneClick(event) +{ + // we only care about left button events + if (event.button != 0) + return; + + var searchInput = document.getElementById("searchInput"); + // if there is a searchInput element, and it's not blank + // then we need to act like the user cleared the + // search text + if (searchInput && searchInput.value) { + searchInput.value = ""; + onEnterInSearchBar(); + } +} + function DirPaneDoubleClick() { if (dirTree && dirTree.selectedItems && (dirTree.selectedItems.length == 1)) @@ -525,6 +544,12 @@ function SetAbView(uri, sortColumn, sortDirection) { CloseAbView(); + if (!sortColumn) + sortColumn = kDefaultSortColumn; + + if (!sortDirection) + sortDirection = kDefaultAscending; + gAbView = Components.classes["@mozilla.org/addressbook/abview;1"].createInstance(Components.interfaces.nsIAbView); var actualSortColumn = gAbView.init(uri, GetAbViewListener(), sortColumn, sortDirection); @@ -534,10 +559,6 @@ function SetAbView(uri, sortColumn, sortDirection) return actualSortColumn; } -const kDefaultSortColumn = "GeneratedName"; -const kDefaultAscending = "ascending"; -const kDefaultDescending = "descending"; - function GetAbView() { return gAbView; @@ -564,12 +585,6 @@ function ChangeDirectoryByDOMNode(dirNode) var sortColumn = dirNode.getAttribute("sortColumn"); var sortDirection = dirNode.getAttribute("sortDirection"); - if (!sortColumn) - sortColumn = kDefaultSortColumn; - - if (!sortDirection) - sortDirection = kDefaultAscending; - var actualSortColumn = SetAbView(uri, sortColumn, sortDirection); UpdateSortIndicators(actualSortColumn, sortDirection); @@ -577,7 +592,7 @@ function ChangeDirectoryByDOMNode(dirNode) // only select the first card if there is a first card if (gAbView && gAbView.getCardFromRow(0)) { SelectFirstCard(); - } + } else { // the selection changes if we were switching directories. ResultsPaneSelectionChanged() @@ -795,3 +810,4 @@ function GetParentDirectoryFromMailingListURI(abURI) return null; } + diff --git a/mailnews/addrbook/resources/content/abDirTreeOverlay.xul b/mailnews/addrbook/resources/content/abDirTreeOverlay.xul index c5d8f9e6a759..d7831f7beda3 100644 --- a/mailnews/addrbook/resources/content/abDirTreeOverlay.xul +++ b/mailnews/addrbook/resources/content/abDirTreeOverlay.xul @@ -40,6 +40,7 @@ Contributors: datasources="rdf:addressdirectory" containment="http://home.netscape.com/NC-rdf#child" onselect="DirPaneSelectionChange(); document.commandDispatcher.updateCommands('tree-select');" + onclick="DirPaneClick(event);" ondblclick="DirPaneDoubleClick();" onblur="goOnEvent(this,'blur')" ondragover="nsDragAndDrop.dragOver(event, abDirTreeObserver);" diff --git a/mailnews/addrbook/resources/content/addressbook.js b/mailnews/addrbook/resources/content/addressbook.js index ff5bbb8ff5f9..188db848cb0f 100644 --- a/mailnews/addrbook/resources/content/addressbook.js +++ b/mailnews/addrbook/resources/content/addressbook.js @@ -41,8 +41,10 @@ var cvPrefs = 0; var addressbook = 0; var gAddressBookBundle; - -var gTotalCardsElement = null; +var gSearchTimer = null; +var gStatusText = null; +var gQueryURIFormat = null; +var gSearchInput; // Constants that correspond to choices // in Address Book->View -->Show Name as @@ -87,7 +89,7 @@ var gAddressBookAbViewListener = { ResultsPaneSelectionChanged(); }, onCountChanged: function(total) { - SetTotalCardStatus(gAbView.directory.dirName, total); + SetStatusText(total); } }; @@ -125,6 +127,8 @@ function RemovePrefObservers() function OnLoadAddressBook() { gAddressBookBundle = document.getElementById("bundle_addressBook"); + gSearchInput = document.getElementById("searchInput"); + verifyAccounts(null); // this will do migration, if we need to. top.addressbook = Components.classes["@mozilla.org/addressbook;1"].createInstance(Components.interfaces.nsIAddressBook); @@ -244,11 +248,11 @@ function AbNewAddressBook() function AbCreateNewAddressBook(name) { - var prefsAttr = new Array; - var prefsValue = new Array; - prefsAttr[0] = "description"; - prefsValue[0] = name; - top.addressbook.newAddressBook(dirTree.database, 1, prefsAttr, prefsValue); + var prefsAttr = new Array; + var prefsValue = new Array; + prefsAttr[0] = "description"; + prefsValue[0] = name; + top.addressbook.newAddressBook(dirTree.database, 1, prefsAttr, prefsValue); } function AbPrintCard() @@ -403,36 +407,84 @@ function AbDeleteDirectory() SelectFirstAddressBook(); } -function GetTotalCardCountElement() +function SetStatusText(total) { - if (gTotalCardsElement) - return gTotalCardsElement; + if (!gStatusText) + gStatusText = document.getElementById('statusText'); - var totalCardCountElement = document.getElementById('statusText'); - gTotalCardsElement = totalCardCountElement; - return gTotalCardsElement; -} + try { + var statusText; -function SetTotalCardStatus(name, total) -{ - var totalElement = GetTotalCardCountElement(); - if (totalElement) - { - try - { - var numTotal = gAddressBookBundle.getFormattedString("totalCardStatus", [name, total]); - totalElement.setAttribute("label", numTotal); - } - catch(ex) - { - dump("Fail to set total cards in status\n"); - } + if (gSearchInput.value) + statusText = gAddressBookBundle.getFormattedString("matchesFound", [total]); + else + statusText = gAddressBookBundle.getFormattedString("totalCardStatus", [gAbView.directory.dirName, total]); + + gStatusText.setAttribute("label", statusText); + } + catch(ex) { + dump("failed to set status text: " + ex + "\n"); } - else - dump("Can't find status bar\n"); } function AbResultsPaneDoubleClick(card) { AbEditCard(card); } + +function onAdvancedAbSearch() +{ + dump("XXX onAdvancedAbSearch\n"); +} + +function onEnterInSearchBar() +{ + ClearCardViewPane(); + + var selectedItems = dirTree.selectedItems; + if (selectedItems.length != 1) + return; + + if (!gQueryURIFormat) { + gQueryURIFormat = gPrefs.getCharPref("mail.addr_book.quicksearchquery.format"); + } + + var selectedNode = selectedItems[0]; + var sortColumn = selectedNode.getAttribute("sortColumn"); + var sortDirection = selectedNode.getAttribute("sortDirection"); + var searchURI = selectedNode.getAttribute("id"); + + /* + XXX todo, handle the case where the LDAP url + already has a query, like + moz-abldapdirectory://nsdirectory.netscape.com:389/ou=People,dc=netscape,dc=com?(or(Department,=,Applications)) + */ + if (gSearchInput.value != "") { + // replace all instances of @V with the escaped version + // of what the user typed in the quick search text input + searchURI += gQueryURIFormat.replace(/@V/g, escape(gSearchInput.value)); + } + + SetAbView(searchURI, sortColumn, sortDirection); + + // XXX todo + // this works for synchronous searches of local addressbooks, + // but not for LDAP searches + SelectFirstCard(); +} + +function onAbSearchInput(event) +{ + if (gSearchTimer) { + clearTimeout(gSearchTimer); + gSearchTimer = null; + } + + if (event && event.keyCode == 13) { + onEnterInSearchBar(); + } + else { + gSearchTimer = setTimeout("onEnterInSearchBar();", 800); + } +} + diff --git a/mailnews/addrbook/resources/content/addressbook.xul b/mailnews/addrbook/resources/content/addressbook.xul index 0cf7f96c19ad..c70028b69080 100644 --- a/mailnews/addrbook/resources/content/addressbook.xul +++ b/mailnews/addrbook/resources/content/addressbook.xul @@ -114,156 +114,173 @@ Contributor(s): - - - + + + - - + + - - - - - - - - + + + + + + + + - + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + accesskey="&displayNameCmd.accesskey;" + oncommand="SetNameColumn('displayNameCmd')"/> + + - + + id="cmd_SortByGeneratedName" + accesskey="&GeneratedName.accesskey;" + oncommand="SortResultPane('GeneratedName');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByPrimaryEmail" + accesskey="&PrimaryEmail.accesskey;" + oncommand="SortResultPane('PrimaryEmail');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByCompany" + accesskey="&Company.accesskey;" + oncommand="SortResultPane('Company');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByNickName" + accesskey="&NickName.accesskey;" + oncommand="SortResultPane('NickName');" name="sortas" type="radio" checked="true"/> + id="cmd_SortBySecondEmail" + accesskey="&SecondEmail.accesskey;" + oncommand="SortResultPane('SecondEmail');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByDepartment" + accesskey="&Department.accesskey;" + oncommand="SortResultPane('Department');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByJobTitle" + accesskey="&JobTitle.accesskey;" + oncommand="SortResultPane('JobTitle');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByCellularNumber" + accesskey="&CellularNumber.accesskey;" + oncommand="SortResultPane('CellularNumber');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByPagerNumber" + accesskey="&PagerNumber.accesskey;" + oncommand="SortResultPane('PagerNumber');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByFaxNumber" + accesskey="&FaxNumber.accesskey;" + oncommand="SortResultPane('FaxNumber');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByHomePhone" + accesskey="&HomePhone.accesskey;" + oncommand="SortResultPane('HomePhone');" name="sortas" type="radio" checked="true"/> + id="cmd_SortByWorkPhone" + accesskey="&WorkPhone.accesskey;" + oncommand="SortResultPane('WorkPhone');" name="sortas" type="radio" checked="true"/> - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - - - + diff --git a/mailnews/addrbook/resources/locale/en-US/abMainWindow.dtd b/mailnews/addrbook/resources/locale/en-US/abMainWindow.dtd index 1f521da1eebf..bb40a0702cb5 100644 --- a/mailnews/addrbook/resources/locale/en-US/abMainWindow.dtd +++ b/mailnews/addrbook/resources/locale/en-US/abMainWindow.dtd @@ -57,10 +57,10 @@ Rights Reserved. - - + - + + @@ -72,6 +72,7 @@ Rights Reserved. + diff --git a/mailnews/addrbook/resources/locale/en-US/addressBook.properties b/mailnews/addrbook/resources/locale/en-US/addressBook.properties index b3dd281d1d73..aa6dccd6376e 100644 --- a/mailnews/addrbook/resources/locale/en-US/addressBook.properties +++ b/mailnews/addrbook/resources/locale/en-US/addressBook.properties @@ -66,8 +66,11 @@ ldap_2.servers.pab.description=Personal Address Book ldap_2.servers.history.description=Collected Addresses # status bar stuff -## LOCALIZATION NOTE (totalCardStatus): %1$S is address book name, %2$S is card count +## LOCALIZATION NOTE (totalCardStatus): +## %1$S is address book name, %2$S is card count totalCardStatus=Total Cards in %1$S: %2$S +## LOCALIZATION NOTE (matchesFound): do not localize %S +matchesFound=%S matches found #LDAP directory stuff # diff --git a/mailnews/addrbook/src/nsAbMDBDirectory.cpp b/mailnews/addrbook/src/nsAbMDBDirectory.cpp index fbad14a71db5..be4cbc068f63 100644 --- a/mailnews/addrbook/src/nsAbMDBDirectory.cpp +++ b/mailnews/addrbook/src/nsAbMDBDirectory.cpp @@ -85,7 +85,8 @@ nsAbMDBDirectory::~nsAbMDBDirectory(void) if (mSubDirectories) { PRUint32 count; - nsresult rv = mSubDirectories->Count(&count); + nsresult rv; + rv = mSubDirectories->Count(&count); NS_ASSERTION(NS_SUCCEEDED(rv), "Count failed"); PRInt32 i; for (i = count - 1; i >= 0; i--) @@ -315,7 +316,8 @@ NS_IMETHODIMP nsAbMDBDirectory::RemoveElementsFromAddressList() if (m_AddressList) { PRUint32 count; - nsresult rv = m_AddressList->Count(&count); + nsresult rv; + rv = m_AddressList->Count(&count); NS_ASSERTION(NS_SUCCEEDED(rv), "Count failed"); PRInt32 i; for (i = count - 1; i >= 0; i--) diff --git a/mailnews/addrbook/src/nsAbView.cpp b/mailnews/addrbook/src/nsAbView.cpp index 3161c7d627a3..67f09012c594 100644 --- a/mailnews/addrbook/src/nsAbView.cpp +++ b/mailnews/addrbook/src/nsAbView.cpp @@ -79,7 +79,8 @@ nsAbView::nsAbView() nsAbView::~nsAbView() { if (mDirectory) { - nsresult rv = Close(); + nsresult rv; + rv = Close(); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to close view"); } } diff --git a/mailnews/base/resources/content/commandglue.js b/mailnews/base/resources/content/commandglue.js index 223e12040b36..6ee7a344dbdd 100644 --- a/mailnews/base/resources/content/commandglue.js +++ b/mailnews/base/resources/content/commandglue.js @@ -700,7 +700,8 @@ function FolderPaneSelectionChange() { gDBView.isSearchView = false; //reset the search input on folder switch var searchInput = document.getElementById("searchInput"); - if (searchInput) searchInput.value = ""; + if (searchInput) + searchInput.value = ""; } ChangeFolderByURI(folderResource.Value, viewType, viewFlags, sortType, sortOrder); } diff --git a/mailnews/base/resources/content/mailWindowOverlay.xul b/mailnews/base/resources/content/mailWindowOverlay.xul index b9a522646030..46011d7a11e6 100644 --- a/mailnews/base/resources/content/mailWindowOverlay.xul +++ b/mailnews/base/resources/content/mailWindowOverlay.xul @@ -1475,7 +1475,7 @@ Rights Reserved.