Bug 408613 Migrate SeaMonkey addressing preferences pane to new style and rewrite how the AB prefs UI works. r=IanN,sr=Neil
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 09 Sep 2008 11:20:01 +0100
changeset 296 9c411f661785160e87c1df366afc1fa7ccd4dc31
parent 295 3776ea557ca478d5a80e94ecd4fa034650176dec
child 297 dd785a9c110711b63325d8e14fd42b7dd66d773b
push idunknown
push userunknown
push dateunknown
reviewersIanN, Neil
bugs408613
Bug 408613 Migrate SeaMonkey addressing preferences pane to new style and rewrite how the AB prefs UI works. r=IanN,sr=Neil
mail/components/addrbook/jar.mn
mailnews/addrbook/prefs/resources/content/pref-addressing.js
mailnews/addrbook/prefs/resources/content/pref-addressing.xul
mailnews/addrbook/prefs/resources/content/pref-directory.js
mailnews/addrbook/resources/content/addressbook.xul
mailnews/base/prefs/resources/content/am-addressing.js
mailnews/base/prefs/resources/content/am-addressingOverlay.xul
mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
mailnews/jar.mn
--- a/mail/components/addrbook/jar.mn
+++ b/mail/components/addrbook/jar.mn
@@ -4,17 +4,16 @@ messenger.jar:
 *   content/messenger/addressbook/addressbook.xul               (content/addressbook.xul)
 *   content/messenger/addressbook/abCommon.js                   (content/abCommon.js)
 *   content/messenger/addressbook/abCardOverlay.js              (content/abCardOverlay.js)
 *   content/messenger/addressbook/abEditListDialog.xul          (content/abEditListDialog.xul)
 *   content/messenger/addressbook/abMailListDialog.xul          (content/abMailListDialog.xul)
 *   content/messenger/addressbook/abContactsPanel.xul           (content/abContactsPanel.xul)
 *   content/messenger/addressbook/abContactsPanel.js            (content/abContactsPanel.js)
     content/messenger/addressbook/addrbookWidgets.xml           (/mailnews/addrbook/resources/content/addrbookWidgets.xml)
-    content/messenger/addressbook/pref-directory.js             (/mailnews/addrbook/prefs/resources/content/pref-directory.js)
     content/messenger/addressbook/pref-directory-add.js         (/mailnews/addrbook/prefs/resources/content/pref-directory-add.js)
     content/messenger/addressbook/pref-directory-add.xul        (/mailnews/addrbook/prefs/resources/content/pref-directory-add.xul)
     content/messenger/addressbook/pref-editdirectories.js       (/mailnews/addrbook/prefs/resources/content/pref-editdirectories.js)
     content/messenger/addressbook/pref-editdirectories.xul      (/mailnews/addrbook/prefs/resources/content/pref-editdirectories.xul)
     content/messenger/addressbook/abAddressBookNameDialog.js    (/mailnews/addrbook/resources/content/abAddressBookNameDialog.js)
     content/messenger/addressbook/abAddressBookNameDialog.xul   (/mailnews/addrbook/resources/content/abAddressBookNameDialog.xul)
     content/messenger/addressbook/abNewCardDialog.xul           (/mailnews/addrbook/resources/content/abNewCardDialog.xul)
     content/messenger/addressbook/abEditCardDialog.xul          (/mailnews/addrbook/resources/content/abEditCardDialog.xul)
rename from mailnews/addrbook/prefs/resources/content/pref-directory.js
rename to mailnews/addrbook/prefs/resources/content/pref-addressing.js
--- a/mailnews/addrbook/prefs/resources/content/pref-directory.js
+++ b/mailnews/addrbook/prefs/resources/content/pref-addressing.js
@@ -1,219 +1,58 @@
-var gPrefInt = null;
-var gAvailDirectories = null;
-var gCurrentDirectoryServer = null;
-var gCurrentDirectoryServerId = null;
-var gRefresh = false;
-var gNewServer = null;
-var gNewServerString = null;
-var gUpdate = false;
-var gDeletedDirectories = new Array();
-var gLDAPPrefsService;
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Srilatha Moturi <srilatha@netscape.com>, original implementor
+ *   Mark Banner <bugzilla@standard8.plus.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
 
-function initLDAPPrefsService()
+function Startup()
 {
-  if (gLDAPPrefsService)
-    return;
-
-  const LDAP_PREF_CONTRACT="@mozilla.org/ldapprefs-service;1";
-  if (LDAP_PREF_CONTRACT in Components.classes)
-  {
-    gLDAPPrefsService = Components.classes[LDAP_PREF_CONTRACT].getService(Components.interfaces.nsILDAPPrefsService);
-  }
+  enableAutocomplete();
 }
 
 function onEditDirectories()
 {
   window.openDialog("chrome://messenger/content/addressbook/pref-editdirectories.xul",
                     "editDirectories", "chrome,modal=yes,resizable=no", null);
-  if (gRefresh)
-  {
-    var popup = document.getElementById("directoriesListPopup"); 
-    if (popup) 
-    { 
-       while (popup.hasChildNodes())
-         popup.removeChild(popup.lastChild);
-    } 
-    gAvailDirectories = null;
-    LoadDirectories(popup);
-    gRefresh = false;
-  }
 }
 
 function enableAutocomplete()
 {
-  var autocompleteLDAP = document.getElementById("autocompleteLDAP");  
-  var directoriesList =  document.getElementById("directoriesList"); 
-  var directoriesListPopup = document.getElementById("directoriesListPopup");
-  var editButton = document.getElementById("editButton");
-//  var autocompleteSkipDirectory = document.getElementById("autocompleteSkipDirectory");
-
-  if (autocompleteLDAP.checked) {
-    // If the default directory preference is locked 
-    // disable the list popup
-    if (gPrefInt.prefIsLocked("ldap_2.autoComplete.directoryServer")) {
-      directoriesList.setAttribute("disabled", true);
-      directoriesListPopup.setAttribute("disabled", true);
-    }
-    else {
-      directoriesList.removeAttribute("disabled");
-      directoriesListPopup.removeAttribute("disabled");
-    } 
-    editButton.removeAttribute("disabled");
-//    autocompleteSkipDirectory.removeAttribute("disabled");
-  }
-  else {
-    directoriesList.setAttribute("disabled", true);
-    directoriesListPopup.setAttribute("disabled", true);
-    editButton.setAttribute("disabled", true);
-//    autocompleteSkipDirectory.setAttribute("disabled", true);
-  }
-  // if we do not have any directories disable the dropdown list box
-  if (!gAvailDirectories || (gAvailDirectories.length < 1))
-    directoriesList.setAttribute("disabled", true);
-  LoadDirectories(directoriesListPopup);
-}
-
-function setupDirectoriesList()
-{
-  var override = document.getElementById("identity.overrideGlobalPref").getAttribute("value");
-  var autocomplete = document.getElementById("ldapAutocomplete");
-  // useGlobalFlag is set when user changes the selectedItem on the radio button and switches
-  // to a different pane and switches back in Mail/news AccountSettings
-  var useGlobalFlag = document.getElementById("overrideGlobalPref").getAttribute("value");
-  // directoryServerFlag is set when user changes the server to None and switches
-  // to a different pane and switches back in Mail/news AccountSettings
-  var directoryServerFlag = document.getElementById("directoryServer").getAttribute("value");
-
-  if(override == "true" && !useGlobalFlag)
-    autocomplete.selectedItem = document.getElementById("directories");
-  else
-    autocomplete.selectedItem = document.getElementById("useGlobalPref");
-
-  var directoriesList = document.getElementById("directoriesList");
-  var directoryServer = 
-        document.getElementById("identity.directoryServer").getAttribute('value');
-  if (directoryServerFlag) {
-    document.getElementById("identity.directoryServer").setAttribute("value", "");
-    directoryServer = "";
-  }
-  directoriesList.value = directoryServer;
-}
-
-function createDirectoriesList()
-{
-  var directoriesListPopup = document.getElementById("directoriesListPopup");
-
-  if (directoriesListPopup) {
-    LoadDirectories(directoriesListPopup);
-  }
-}
+  var acLDAPValue = document.getElementById("ldap_2.autoComplete.useDirectory")
+                            .value;
 
-function LoadDirectories(popup)
-{
-  var prefCount = {value:0};
-  var description = "";
-  var item;
-  var j=0;
-  var arrayOfDirectories;
-  var position;
-  var dirType;
-  if (!gPrefInt) { 
-    try {
-      gPrefInt = Components.classes["@mozilla.org/preferences-service;1"]
-                           .getService(Components.interfaces.nsIPrefBranch);
-    }
-    catch (ex) {
-      gPrefInt = null;
-    }
-  }
-  if (!gAvailDirectories) {
-    try {
-      initLDAPPrefsService();
-      if (gLDAPPrefsService)
-        arrayOfDirectories = gLDAPPrefsService.getServerList(gPrefInt, prefCount);
-    }
-    catch (ex) {
-    }
-  if (arrayOfDirectories) {
-    gAvailDirectories = new Array();
-    for (var i = 0; i < prefCount.value; i++)
-    {
-      if ((arrayOfDirectories[i] != "ldap_2.servers.pab") && 
-        (arrayOfDirectories[i] != "ldap_2.servers.history")) {
-        try{
-          position = gPrefInt.getIntPref(arrayOfDirectories[i]+".position");
-        }
-        catch(ex){
-          position = 1;
-        }
-        try{
-          dirType = gPrefInt.getIntPref(arrayOfDirectories[i]+".dirType");
-        }
-        catch(ex){
-          dirType = 1;
-        }
-        if ((position != 0) && (dirType == 1)) {
-          try{
-            description = gPrefInt.getComplexValue(arrayOfDirectories[i]+".description",
-                                                   Components.interfaces.nsISupportsString).data;
-          }
-          catch(ex){
-            description="";
-          }
-          if (description != "") {
-            if (popup) {
-              item=document.createElement("menuitem");
-              item.setAttribute("label", description);
-              item.setAttribute("value", arrayOfDirectories[i]);
-              popup.appendChild(item);
-            }
-            gAvailDirectories[j++] = {value:arrayOfDirectories[i], label:description};
-          }
-        }
-      }
-    }
-    if (popup)
-    {
-      // we are in mail/news Account settings
-      item = document.createElement("menuitem");
-      var addressBookBundle = document.getElementById("bundle_addressBook");
-      var directoryName = addressBookBundle.getString("directoriesListItemNone");
-      item.setAttribute("label", directoryName);
-      item.setAttribute("value", "");
-      popup.appendChild(item);
-
-      // Now check what we are displaying is valid.
-      var directoriesList = document.getElementById("directoriesList");
-      var value = directoriesList.value;
-      directoriesList.selectedItem = null;
-      directoriesList.value = value;
-      if (!directoriesList.selectedItem) {
-        directoriesList.value = "";
-        // If we have no other directories, also disable the popup.
-        if (gAvailDirectories.length == 0)
-          directoriesList.disabled = true;
-      }
-      // Only enable autocomplete if the pref isn't locked.
-      else if (!gPrefInt.prefIsLocked("ldap_2.autoComplete.directoryServer"))
-        directoriesList.disabled = false;
-    }
-  }
-  }
+  EnableElementById("directoriesList", acLDAPValue, false);
+  EnableElementById("editButton", acLDAPValue, false);
 }
-
-function LoadDirectoriesList(listbox)
-{
-  LoadDirectories();
-  if (listbox && gAvailDirectories)
-  {
-    for (var i=0; i<gAvailDirectories.length; i++)
-    {
-      var item = document.createElement('listitem');
-
-      item.setAttribute('label', gAvailDirectories[i].label);
-      item.setAttribute('string', gAvailDirectories[i].value);
-
-      listbox.appendChild(item);
-    }
-  }
-}
--- a/mailnews/addrbook/prefs/resources/content/pref-addressing.xul
+++ b/mailnews/addrbook/prefs/resources/content/pref-addressing.xul
@@ -1,111 +1,125 @@
 <?xml version="1.0"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+   -
+   - The contents of this file are subject to the Mozilla Public License Version
+   - 1.1 (the "License"); you may not use this file except in compliance with
+   - the License. You may obtain a copy of the License at
+   - http://www.mozilla.org/MPL/
+   -
+   - Software distributed under the License is distributed on an "AS IS" basis,
+   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+   - for the specific language governing rights and limitations under the
+   - License.
+   -
+   - The Original Code is Mozilla Communicator client code.
+   -
+   - The Initial Developer of the Original Code is
+   - Netscape Communications Corporation.
+   - Portions created by the Initial Developer are Copyright (C) 1999
+   - the Initial Developer. All Rights Reserved.
+   -
+   - Contributor(s):
+   -   <chuang@netscape.com>
+   -   Mark Banner <bugzilla@standard8.plus.com>
+   -
+   - Alternatively, the contents of this file may be used under the terms of
+   - either the GNU General Public License Version 2 or later (the "GPL"), or
+   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+   - in which case the provisions of the GPL or the LGPL are applicable instead
+   - of those above. If you wish to allow use of your version of this file only
+   - under the terms of either the GPL or the LGPL, and not to allow others to
+   - use your version of this file under the terms of the MPL, indicate your
+   - decision by deleting the provisions above and replace them with the notice
+   - and other provisions required by the LGPL or the GPL. If you do not delete
+   - the provisions above, a recipient may use your version of this file under
+   - the terms of any one of the MPL, the GPL or the LGPL.
+   -
+   - ***** END LICENSE BLOCK ***** -->
 
 <?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
-
-<!DOCTYPE page SYSTEM "chrome://messenger/locale/addressbook/pref-addressing.dtd">
+<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
 
-<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-      xmlns:nc="http://home.netscape.com/NC-rdf#"
-      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-      onload="onLoad();"
-      headertitle="&pref.addressing.title;">
-
-  <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
+<!DOCTYPE overlay SYSTEM "chrome://messenger/locale/addressbook/pref-addressing.dtd">
 
-  <script type="application/x-javascript" src="chrome://messenger/content/addressbook/pref-directory.js"/>
-  <script type="application/x-javascript">
-  <![CDATA[
-    var _elementIDs = ["emailCollectionOutgoing",
-                       "highlightNonMatches",
-                       "addressingAutocomplete",
-                       "autocompleteLDAP",
-                       "localDirectoriesList",
-                       "directoriesList"];
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <prefpane id="addressing_pane" label="&pref.addressing.title;"
+            script="chrome://messenger/content/addressbook/pref-addressing.js">
 
-  function onLoad()
-  {
-    createDirectoriesList();
-    parent.initPanel('chrome://messenger/content/addressbook/pref-addressing.xul');   
-  }
+    <stringbundle id="bundle_addressBook"
+                  src="chrome://messenger/locale/addressbook/addressBook.properties"/>
 
-  function Startup() 
-  {
-    enableAutocomplete();
-  }
-  ]]>
-  </script>  
+    <preferences id="addressing_preferences">
+      <preference id="mail.collect_email_address_outgoing"
+                  name="mail.collect_email_address_outgoing"
+                  type="bool"/>
+      <preference id="mail.collect_addressbook"
+                  name="mail.collect_addressbook"
+                  type="string"/>
+      <preference id="mail.autoComplete.highlightNonMatches"
+                  name="mail.autoComplete.highlightNonMatches"
+                  type="bool"/>
+      <preference id="mail.enable_autocomplete"
+                  name="mail.enable_autocomplete"
+                  type="bool"/>
+      <preference id="ldap_2.autoComplete.useDirectory"
+                  name="ldap_2.autoComplete.useDirectory"
+                  onchange="enableAutocomplete();" type="bool"/>
+      <preference id="ldap_2.autoComplete.directoryServer"
+                  name="ldap_2.autoComplete.directoryServer"
+                  type="string"/>
+      <preference id="pref.ldap.disable_button.edit_directories"
+                  name="pref.ldap.disable_button.edit_directories"
+                  type="bool"/>
+    </preferences>
 
-  <groupbox>
-    <caption label="&emailCollectiontitle.label;"/>
-  <description>&emailCollectiontext.label;</description>
-    <hbox align="center">
-      <checkbox id="emailCollectionOutgoing" 
-        label="&emailCollectionPicker.label;"
-        accesskey="&emailCollectionPicker.accesskey;"
-        prefstring="mail.collect_email_address_outgoing"/>
-   <menulist id="localDirectoriesList" flex="1"
-             aria-labelledby="emailCollectionOutgoing"
-             preftype="string" 
-             prefstring="mail.collect_addressbook">
-     <menupopup id="abPopup-menupopup" ref="moz-abdirectory://" 
-                 datasources="rdf:addressdirectory"
-                 sortActive="true"
-                 sortDirection="ascending"
-                 sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort">
-        <template>
-        <rule nc:IsWriteable="false"/>
-        <rule nc:IsMailList="false">
-          <menuitem uri="..."
-                    label="rdf:http://home.netscape.com/NC-rdf#DirName"
-                    value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
-        </rule>
-        </template>
-      </menupopup>
-    </menulist>
-    </hbox>
-  </groupbox>
-	
+    <groupbox>
+      <caption label="&emailCollectiontitle.label;"/>
+      <description>&emailCollectiontext.label;</description>
+      <hbox align="center">
+        <checkbox id="emailCollectionOutgoing"
+                  label="&emailCollectionPicker.label;"
+                  accesskey="&emailCollectionPicker.accesskey;"
+                  preference="mail.collect_email_address_outgoing"/>
+        <menulist id="localDirectoriesList" flex="1"
+                  aria-labelledby="emailCollectionOutgoing"
+                  preference="mail.collect_addressbook">
+          <menupopup id="localDirectoriesPopup" class="addrbooksPopup"
+                     localonly="true" writeable="true"/>
+        </menulist>
+      </hbox>
+    </groupbox>
     <groupbox id="addressAutocompletion">
       <caption label="&addressingTitle.label;"/>
-    <hbox align="center">
-      <checkbox id="highlightNonMatches" label="&highlightNonMatches.label;"
-                prefstring="mail.autoComplete.highlightNonMatches"
-                accesskey="&highlightNonMatches.accesskey;"/>
-    </hbox>
+      <hbox align="center">
+        <checkbox id="highlightNonMatches" label="&highlightNonMatches.label;"
+                  preference="mail.autoComplete.highlightNonMatches"
+                  accesskey="&highlightNonMatches.accesskey;"/>
+      </hbox>
 
-    <separator class="thin"/>
+      <separator class="thin"/>
 
       <description>&autocompleteText.label;</description>
       <hbox align="center">
         <checkbox id="addressingAutocomplete" label="&addressingEnable.label;"
-                  prefstring="mail.enable_autocomplete"
+                  preference="mail.enable_autocomplete"
                   accesskey="&addressingEnable.accesskey;"/>
       </hbox>
       <hbox align="center">
-        <checkbox id="autocompleteLDAP" label="&directories.label;" 
-                  prefstring="ldap_2.autoComplete.useDirectory" 
-                  oncommand="enableAutocomplete();"
+        <checkbox id="autocompleteLDAP" label="&directories.label;"
+                  preference="ldap_2.autoComplete.useDirectory"
                   accesskey="&directories.accesskey;"/>
-       <menulist id="directoriesList" flex="1"
-                 aria-labelledby="autocompleteLDAP"
-                 preftype="string" 
-                 prefstring="ldap_2.autoComplete.directoryServer">
-          <menupopup id="directoriesListPopup" 
-            onpopupshowing="createDirectoriesList();">
-          </menupopup>
-       </menulist>
-       <button id="editButton" label="&editDirectories.label;" 
-               prefstring="pref.ldap.disable_button.edit_directories" 
-               oncommand="onEditDirectories();"
-               accesskey="&editDirectories.accesskey;"/>
-     </hbox>
-<!--
-     <description>&matchText.label;</description>
-     <hbox align="center">
-       <checkbox id="autocompleteSkipDirectory"
-                 label="&skipDirectory.label;" 
-                 prefstring="ldap_2.autoComplete.skipDirectoryIfLocalMatchFound"/>    
-     </hbox>
--->
-   </groupbox>
-</page>
+        <menulist id="directoriesList" flex="1"
+                  aria-labelledby="autocompleteLDAP"
+                  preference="ldap_2.autoComplete.directoryServer">
+          <menupopup id="directoriesListPopup" class="addrbooksPopup"
+                     remoteonly="true" value="dirPrefId"/>
+        </menulist>
+        <button id="editButton" label="&editDirectories.label;"
+                oncommand="onEditDirectories();"
+                accesskey="&editDirectories.accesskey;"
+                preference="pref.ldap.disable_button.edit_directories"/>
+      </hbox>
+    </groupbox>
+  </prefpane>
+</overlay>
--- a/mailnews/addrbook/resources/content/addressbook.xul
+++ b/mailnews/addrbook/resources/content/addressbook.xul
@@ -241,17 +241,18 @@
             <menuitem label="&swapFirstNameLastNameCmd.label;"
                       accesskey="&swapFirstNameLastNameCmd.accesskey;"
                       hidden="&hideSwapFnLnUI;"
                       command="cmd_swapFirstNameLastName"/>
             <menuitem label="&propertiesCmd.label;"
                       accesskey="&propertiesCmd.accesskey;"
                       key="key_properties"
                       command="cmd_properties"/>
-            <menuitem id="menu_preferences" oncommand="goPreferences('mailnews', 'chrome://messenger/content/addressbook/pref-addressing.xul', 'mailaddressbookpref')"/>
+            <menuitem id="menu_preferences"
+                      oncommand="goPreferences('addressing_pane')"/>
           </menupopup>
         </menu>
         <menu id="menu_View">
             <menupopup id="menu_View_Popup">
                 <menu id="menu_Toolbars">
                     <menupopup id="view_toolbars_popup">
                         <menuitem id="menu_showAbToolbar"
                                   label="&showAbToolbarCmd.label;"
--- a/mailnews/base/prefs/resources/content/am-addressing.js
+++ b/mailnews/base/prefs/resources/content/am-addressing.js
@@ -1,29 +1,99 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Srilatha Moturi <srilatha@netscape.com>, original implementor
+ *   Mark Banner <bugzilla@standard8.plus.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
 var gIdentity = null;
 var gPrefInt = null;
 
 function onLoad()
 {
-  createDirectoriesList();
   parent.onPanelLoaded('am-addressing.xul');
 }
 
 function onInit(aPageId, aServerId) 
 {
   onInitCompositionAndAddressing();
 }
 
 function onInitCompositionAndAddressing()
 {
   setupDirectoriesList();
   enabling();
   quoteEnabling();
 }
 
+function onEditDirectories()
+{
+  window.openDialog("chrome://messenger/content/addressbook/pref-editdirectories.xul",
+                    "editDirectories", "chrome,modal=yes,resizable=no", null);
+}
+
+function setupDirectoriesList()
+{
+  var override = document.getElementById("identity.overrideGlobalPref").getAttribute("value");
+  var autocomplete = document.getElementById("ldapAutocomplete");
+  // useGlobalFlag is set when user changes the selectedItem on the radio button and switches
+  // to a different pane and switches back in Mail/news AccountSettings
+  var useGlobalFlag = document.getElementById("overrideGlobalPref").getAttribute("value");
+  // directoryServerFlag is set when user changes the server to None and switches
+  // to a different pane and switches back in Mail/news AccountSettings
+  var directoryServerFlag = document.getElementById("directoryServer").getAttribute("value");
+
+  if(override == "true" && !useGlobalFlag)
+    autocomplete.selectedItem = document.getElementById("directories");
+  else
+    autocomplete.selectedItem = document.getElementById("useGlobalPref");
+
+  var directoriesList = document.getElementById("directoriesList");
+  var directoryServer =
+        document.getElementById("identity.directoryServer").getAttribute('value');
+  if (directoryServerFlag) {
+    document.getElementById("identity.directoryServer").setAttribute("value", "");
+    directoryServer = "";
+  }
+  directoriesList.value = directoryServer;
+}
+
 function onPreInit(account, accountValues)
 {
   gIdentity = account.defaultIdentity;
 }
 
 function enabling()
 {
   var autocomplete = document.getElementById("ldapAutocomplete");
@@ -63,33 +133,31 @@ function enabling()
   {
     document.getElementById("useGlobalPref").removeAttribute("disabled");
     document.getElementById("directories").removeAttribute("disabled");
   }
   if (gIdentity && gPrefInt.prefIsLocked("mail.identity." + gIdentity.key + ".directoryServer")) {
     document.getElementById("directoriesList").setAttribute("disabled", "true");
     document.getElementById("directoriesListPopup").setAttribute("disabled", "true");
   }
-
-  LoadDirectories(directoriesListPopup);
 }
 
 function onSave()
 {
   onSaveCompositionAndAddressing();
 }
 
 function onSaveCompositionAndAddressing()
 {
   var override = document.getElementById("identity.overrideGlobalPref");
   var autocomplete = document.getElementById("ldapAutocomplete");
   var directoryServer = document.getElementById("identity.directoryServer");
   var directoriesList = 
       document.getElementById("directoriesList").getAttribute('value');
-  
+
   // When switching between panes, 
   // if we save the value of an element as null
   // we will be forced to get the value from preferences when we get back.
   // We are saving the value as "" for the radio button and also for
   // the directory server if the selected directory is "None"
   // So, we need the two elements overrideGlobalPref and directoryServer
   // to save the state when the directory is 
   // set to none and the first radio button is selected.
--- a/mailnews/base/prefs/resources/content/am-addressingOverlay.xul
+++ b/mailnews/base/prefs/resources/content/am-addressingOverlay.xul
@@ -31,24 +31,24 @@
    - use your version of this file under the terms of the MPL, indicate your
    - decision by deleting the provisions above and replace them with the notice
    - and other provisions required by the LGPL or the GPL. If you do not delete
    - the provisions above, a recipient may use your version of this file under
    - the terms of any one of the MPL, the GPL or the LGPL.
    -
    - ***** END LICENSE BLOCK ***** -->
    
+<?xml-stylesheet href="chrome://messenger/content/messenger.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
 
 <!DOCTYPE overlay SYSTEM "chrome://messenger/locale/am-addressing.dtd">
 
 <overlay xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">                                                       
 
-  <script type="application/x-javascript" src="chrome://messenger/content/addressbook/pref-directory.js"/>
   <script type="application/x-javascript" src="chrome://messenger/content/am-addressing.js"/>
 
   <vbox flex="1" id="compositionAndAddressing">
     <stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
     <label hidden="true" wsm_persist="true" id="identity.directoryServer"
           pref="true" preftype="string" prefattribute="value"
           prefstring="mail.identity.%identitykey%.directoryServer"/>
     <label hidden="true" wsm_persist="true" id="identity.overrideGlobalPref"
@@ -121,18 +121,21 @@
       <label control="ldapAutocomplete">&addressingText.label;</label>
       <radiogroup class="indent" id="ldapAutocomplete" wsm_persist="true" oncommand="enabling();">
         <observes element="identity.overrideGlobalPref" attribute="disabled"/>
         <radio id="useGlobalPref" value="0" label="&useGlobal.label;"
                accesskey="&useGlobal.accesskey;"/>
         <radio id="directories" value="1" label="&directories.label;"
                accesskey="&directories.accesskey;"/>
         <hbox class="indent">
-          <menulist id="directoriesList" wsm_persist="true" style="min-width: 16em;" aria-labelledby="directories">
-            <menupopup onpopupshowing="createDirectoriesList();" id="directoriesListPopup"/>
+          <menulist id="directoriesList" wsm_persist="true"
+                    style="min-width: 16em;" aria-labelledby="directories">
+            <menupopup id="directoriesListPopup" class="addrbooksPopup"
+                       remoteonly="true" value="dirPrefId"/>
           </menulist>
           <button id="editButton" label="&editDirectories.label;"
-                  accesskey="&editDirectories.accesskey;" oncommand="onEditDirectories();"/>
+                  accesskey="&editDirectories.accesskey;"
+                  oncommand="onEditDirectories();"/>
         </hbox>
       </radiogroup>      
     </groupbox>
   </vbox>
 </overlay>
--- a/mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
+++ b/mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
@@ -81,16 +81,21 @@
                   prefpane="composing_messages_pane"
                   url="chrome://messenger/content/messengercompose/pref-composing_messages.xul"
                   helpTopic="mail_prefs_messages"/> 
         <treeitem id="formattingItem"
                   label="&format.label;"
                   prefpane="formatting_pane"
                   url="chrome://messenger/content/messengercompose/pref-formatting.xul"
                   helpTopic="mail_prefs_formatting"/>
+        <treeitem id="addressItem"
+                  label="&address.label;"
+                  prefpane="addressing_pane"
+                  url="chrome://messenger/content/addressbook/pref-addressing.xul"
+                  helpTopic="mail_prefs_addressing"/>
         <treeitem id="junkItem"
                   label="&junk.label;"
                   prefpane="junk_pane"
                   url="chrome://messenger/content/pref-junk.xul"
                   helpTopic="mail-prefs-junk"/>
         <treeitem id="tagsItem"
                   label="&tags.label;"
                   prefpane="tags_pane"
@@ -138,19 +143,19 @@
             <treecell label="(Migrated: &composingMessages.label;)"/>
           </treerow>
         </treeitem>
         <treeitem>
           <treerow>
             <treecell label="(Migrated: &format.label;)"/> 
           </treerow>
         </treeitem>
-        <treeitem id="mailaddressbookpref">
+        <treeitem>
           <treerow>
-            <treecell url="chrome://messenger/content/addressbook/pref-addressing.xul" label="&address.label;"/> 
+            <treecell label="(Migrated: &address.label;)"/>
           </treerow>
         </treeitem>
         <treeitem>
           <treerow>
             <treecell label="(Migrated: &junk.label;)"/>
           </treerow>
         </treeitem>
         <treeitem id="mailtagspref">
--- a/mailnews/jar.mn
+++ b/mailnews/jar.mn
@@ -13,18 +13,18 @@ messenger.jar:
 % overlay chrome://navigator/content/navigatorOverlay.xul                      chrome://messenger/content/mailOverlay.xul
 % overlay chrome://messenger/content/messenger.xul                             chrome://messenger/content/mailMessengerOverlay.xul
 % overlay chrome://messenger/content/messengercompose/messengercompose.xul     chrome://messenger/content/mailMessengerComposeOverlay.xul
 % overlay chrome://messenger/content/addressbook/addressbook.xul               chrome://messenger/content/mailABOverlay.xul
 % overlay chrome://messenger/content/addressbook/abSelectAddressesDialog.xul   chrome://messenger/content/mailOverlay.xul
 % overlay chrome://editor/content/editor.xul                                   chrome://messenger/content/mailEditorOverlay.xul
 % overlay chrome://editor/content/EdImageOverlay.xul                           chrome://messenger/content/messengercompose/mailComposeEditorOverlay.xul
 % overlay chrome://editor/content/EdLinkProps.xul                              chrome://messenger/content/messengercompose/mailComposeEditorOverlay.xul
+    content/messenger/addressbook/pref-addressing.js                           (addrbook/prefs/resources/content/pref-addressing.js)
     content/messenger/addressbook/pref-addressing.xul                          (addrbook/prefs/resources/content/pref-addressing.xul)
-    content/messenger/addressbook/pref-directory.js                            (addrbook/prefs/resources/content/pref-directory.js)
     content/messenger/addressbook/pref-directory-add.js                        (addrbook/prefs/resources/content/pref-directory-add.js)
     content/messenger/addressbook/pref-directory-add.xul                       (addrbook/prefs/resources/content/pref-directory-add.xul)
     content/messenger/addressbook/pref-editdirectories.js                      (addrbook/prefs/resources/content/pref-editdirectories.js)
     content/messenger/addressbook/pref-editdirectories.xul                     (addrbook/prefs/resources/content/pref-editdirectories.xul)
     content/messenger/addressbook/abAddressBookNameDialog.js                   (addrbook/resources/content/abAddressBookNameDialog.js)
     content/messenger/addressbook/abAddressBookNameDialog.xul                  (addrbook/resources/content/abAddressBookNameDialog.xul)
     content/messenger/addressbook/abCardOverlay.js                             (addrbook/resources/content/abCardOverlay.js)
     content/messenger/addressbook/abCardOverlay.xul                            (addrbook/resources/content/abCardOverlay.xul)