diff options
author | Matt A. Tobin <email@mattatobin.com> | 2019-11-03 00:17:46 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2019-11-03 00:17:46 -0400 |
commit | 302bf1b523012e11b60425d6eee1221ebc2724eb (patch) | |
tree | b191a895f8716efcbe42f454f37597a545a6f421 /mailnews/addrbook/content/abAddressBookNameDialog.js | |
parent | 21b3f6247403c06f85e1f45d219f87549862198f (diff) | |
download | UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.gz UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.lz UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.xz UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.zip |
Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1
Diffstat (limited to 'mailnews/addrbook/content/abAddressBookNameDialog.js')
-rw-r--r-- | mailnews/addrbook/content/abAddressBookNameDialog.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/mailnews/addrbook/content/abAddressBookNameDialog.js b/mailnews/addrbook/content/abAddressBookNameDialog.js new file mode 100644 index 000000000..a62659cc3 --- /dev/null +++ b/mailnews/addrbook/content/abAddressBookNameDialog.js @@ -0,0 +1,72 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +Components.utils.import("resource:///modules/mailServices.js"); + +var gOkButton; +var gNameInput; +var gDirectory = null; + +var kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab"; +var kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab"; +var kAllDirectoryRoot = "moz-abdirectory://"; +var kPABDirectory = 2; // defined in nsDirPrefs.h + +function abNameOnLoad() +{ + // Get the document elements. + gOkButton = document.documentElement.getButton('accept'); + gNameInput = document.getElementById('name'); + + // look in arguments[0] for parameters to see if we have a directory or not + if ("arguments" in window && window.arguments[0] && + "selectedDirectory" in window.arguments[0]) { + gDirectory = window.arguments[0].selectedDirectory; + gNameInput.value = gDirectory.dirName; + } + + // Work out the window title (if we have a directory specified, then it's a + // rename). + var bundle = document.getElementById("bundle_addressBook"); + + if (gDirectory) { + let oldListName = gDirectory.dirName; + document.title = bundle.getFormattedString("addressBookTitleEdit", [oldListName]); + } else { + document.title = bundle.getString("addressBookTitleNew"); + } + + if (gDirectory && + (gDirectory.URI == kCollectedAddressbookURI || + gDirectory.URI == kPersonalAddressbookURI || + gDirectory.URI == kAllDirectoryRoot + "?")) { + // Address book name is not editable, therefore disable the field and + // only have an ok button that doesn't do anything. + gNameInput.readOnly = true; + document.documentElement.buttons = "accept"; + document.documentElement.removeAttribute("ondialogaccept"); + } else { + gNameInput.focus(); + abNameDoOkEnabling(); + } +} + +function abNameOKButton() +{ + var newName = gNameInput.value.trim(); + + // Either create a new directory or update an existing one depending on what + // we were given when we started. + if (gDirectory) + gDirectory.dirName = newName; + else + MailServices.ab.newAddressBook(newName, "", kPABDirectory); + + return true; +} + +function abNameDoOkEnabling() +{ + gOkButton.disabled = gNameInput.value.trim() == ""; +} |