mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
remove obsolete UI version prefs.
Thanks to stephen walker for the patch.
This commit is contained in:
parent
fb9db912e3
commit
2eb7c6fbb4
@ -451,36 +451,6 @@ pref("mailnews.show_send_progress", true); //Will show a progress dialog when sa
|
||||
pref("mail.server.default.retainBy", 1);
|
||||
pref("mailnews.ui.junk.firstuse", true);
|
||||
|
||||
// for manual upgrades of certain UI features.
|
||||
// 1 -> 2 is for the folder pane tree landing, to hide the
|
||||
// unread and total columns, see msgMail3PaneWindow.js
|
||||
pref("mail.ui.folderpane.version", 1);
|
||||
|
||||
// for manual upgrades of certain UI features.
|
||||
// 1 -> 2 is for the thread pane tree landing, to hide the
|
||||
// labels column, see msgMail3PaneWindow.js
|
||||
// 2 -> 3 is for the junk status column
|
||||
pref("mailnews.ui.threadpane.version", 1);
|
||||
// for manual upgrades of certain UI features.
|
||||
// 1 -> 2 is for the ab results pane tree landing
|
||||
// to hide the non default columns in the addressbook dialog
|
||||
// see abCommon.js and addressbook.js
|
||||
pref("mailnews.ui.addressbook_results.version", 1);
|
||||
// for manual upgrades of certain UI features.
|
||||
// 1 -> 2 is for the ab results pane tree landing
|
||||
// to hide the non default columns in the addressbook sidebar panel
|
||||
// see abCommon.js and addressbook-panel.js
|
||||
pref("mailnews.ui.addressbook_panel_results.version", 1);
|
||||
// for manual upgrades of certain UI features.
|
||||
// 1 -> 2 is for the ab results pane tree landing
|
||||
// to hide the non default columns in the select addresses dialog
|
||||
// see abCommon.js and abSelectAddressesDialog.js
|
||||
pref("mailnews.ui.select_addresses_results.version", 1);
|
||||
// for manual upgrades of certain UI features.
|
||||
// 1 -> 2 is for the ab results pane
|
||||
// to hide the non default columns in the advanced directory search dialog
|
||||
// see abCommon.js and ABSearchDialog.js
|
||||
pref("mailnews.ui.advanced_directory_search_results.version", 1);
|
||||
//If set to a number greater than 0, msg compose windows will be recycled in order to open them quickly
|
||||
pref("mail.compose.max_recycled_windows", 1);
|
||||
|
||||
|
371
mail/base/content/ABSearchDialog.js
Normal file
371
mail/base/content/ABSearchDialog.js
Normal file
@ -0,0 +1,371 @@
|
||||
# ***** 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 addressbook.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Seth Spitzer <sspitzer@netscape.com>
|
||||
# Portions created by the Initial Developer are Copyright (C) 2002
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# 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 searchSessionContractID = "@mozilla.org/messenger/searchSession;1";
|
||||
var gSearchSession;
|
||||
|
||||
var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
|
||||
var nsIMsgSearchTerm = Components.interfaces.nsIMsgSearchTerm;
|
||||
var nsMsgSearchOp = Components.interfaces.nsMsgSearchOp;
|
||||
var nsMsgSearchAttrib = Components.interfaces.nsMsgSearchAttrib;
|
||||
var nsIAbDirectory = Components.interfaces.nsIAbDirectory;
|
||||
|
||||
var gStatusText;
|
||||
var gSearchBundle;
|
||||
var gAddressBookBundle;
|
||||
|
||||
var gSearchStopButton;
|
||||
var gPropertiesButton;
|
||||
var gComposeButton;
|
||||
var gSearchPhoneticName = "false";
|
||||
|
||||
var gRDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
|
||||
|
||||
var gSearchAbViewListener = {
|
||||
onSelectionChanged: function() {
|
||||
},
|
||||
onCountChanged: function(total) {
|
||||
var statusText = gAddressBookBundle.getFormattedString("matchesFound", [total]);
|
||||
gStatusText.setAttribute("label", statusText);
|
||||
}
|
||||
};
|
||||
|
||||
function searchOnLoad()
|
||||
{
|
||||
initializeSearchWidgets();
|
||||
initializeSearchWindowWidgets();
|
||||
|
||||
gSearchBundle = document.getElementById("bundle_search");
|
||||
gAddressBookBundle = document.getElementById("bundle_addressBook");
|
||||
gSearchSession = Components.classes[searchSessionContractID].createInstance(Components.interfaces.nsIMsgSearchSession);
|
||||
|
||||
// initialize a flag for phonetic name search
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
||||
gSearchPhoneticName =
|
||||
prefBranch.getComplexValue("mail.addr_book.show_phonetic_fields",
|
||||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
|
||||
if (window.arguments && window.arguments[0])
|
||||
SelectDirectory(window.arguments[0].directory);
|
||||
|
||||
// initialize globals, see abCommon.js, InitCommonJS()
|
||||
abList = document.getElementById("abPopup");
|
||||
gAbResultsTree = document.getElementById("abResultsTree");
|
||||
|
||||
onMore(null);
|
||||
}
|
||||
|
||||
function searchOnUnload()
|
||||
{
|
||||
CloseAbView();
|
||||
}
|
||||
|
||||
function initializeSearchWindowWidgets()
|
||||
{
|
||||
gSearchStopButton = document.getElementById("search-button");
|
||||
gPropertiesButton = document.getElementById("propertiesButton");
|
||||
gComposeButton = document.getElementById("composeButton");
|
||||
gStatusText = document.getElementById('statusText');
|
||||
}
|
||||
|
||||
function onSearchStop()
|
||||
{
|
||||
}
|
||||
|
||||
function onAbSearchReset(event)
|
||||
{
|
||||
gPropertiesButton.setAttribute("disabled","true");
|
||||
gComposeButton.setAttribute("disabled","true");
|
||||
|
||||
CloseAbView();
|
||||
|
||||
onReset(event);
|
||||
gStatusText.setAttribute("label", "");
|
||||
}
|
||||
|
||||
function SelectDirectory(aURI)
|
||||
{
|
||||
var selectedAB = aURI;
|
||||
|
||||
if (!selectedAB)
|
||||
selectedAB = kPersonalAddressbookURI;
|
||||
|
||||
// set popup with address book names
|
||||
var abPopup = document.getElementById('abPopup');
|
||||
if ( abPopup )
|
||||
{
|
||||
var menupopup = document.getElementById('abPopup-menupopup');
|
||||
|
||||
if ( selectedAB && menupopup && menupopup.childNodes )
|
||||
{
|
||||
for ( var index = menupopup.childNodes.length - 1; index >= 0; index-- )
|
||||
{
|
||||
if ( menupopup.childNodes[index].getAttribute('value') == selectedAB )
|
||||
{
|
||||
abPopup.label = menupopup.childNodes[index].getAttribute('label');
|
||||
abPopup.value = menupopup.childNodes[index].getAttribute('value');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setSearchScope(GetScopeForDirectoryURI(selectedAB));
|
||||
}
|
||||
|
||||
function GetScopeForDirectoryURI(aURI)
|
||||
{
|
||||
var directory = gRDF.GetResource(aURI).QueryInterface(nsIAbDirectory);
|
||||
var booleanAnd = gSearchBooleanRadiogroup.selectedItem.value == "and";
|
||||
|
||||
if (directory.isRemote) {
|
||||
if (booleanAnd)
|
||||
return nsMsgSearchScope.LDAPAnd;
|
||||
else
|
||||
return nsMsgSearchScope.LDAP;
|
||||
}
|
||||
else {
|
||||
if (booleanAnd)
|
||||
return nsMsgSearchScope.LocalABAnd;
|
||||
else
|
||||
return nsMsgSearchScope.LocalAB;
|
||||
}
|
||||
}
|
||||
|
||||
function onEnterInSearchTerm()
|
||||
{
|
||||
// on enter
|
||||
// if not searching, start the search
|
||||
// if searching, stop and then start again
|
||||
if (gSearchStopButton.getAttribute("label") == gSearchBundle.getString("labelForSearchButton")) {
|
||||
onSearch();
|
||||
}
|
||||
else {
|
||||
onSearchStop();
|
||||
onSearch();
|
||||
}
|
||||
}
|
||||
|
||||
function onSearch()
|
||||
{
|
||||
gStatusText.setAttribute("label", "");
|
||||
gPropertiesButton.setAttribute("disabled","true");
|
||||
gComposeButton.setAttribute("disabled","true");
|
||||
|
||||
gSearchSession.clearScopes();
|
||||
|
||||
var currentAbURI = document.getElementById('abPopup').getAttribute('value');
|
||||
|
||||
gSearchSession.addDirectoryScopeTerm(GetScopeForDirectoryURI(currentAbURI));
|
||||
saveSearchTerms(gSearchSession.searchTerms, gSearchSession);
|
||||
|
||||
var searchUri = currentAbURI + "?(";
|
||||
|
||||
var count = gSearchSession.searchTerms.Count();
|
||||
|
||||
for (var i=0; i<count; i++) {
|
||||
var searchTerm = gSearchSession.searchTerms.GetElementAt(i).QueryInterface(nsIMsgSearchTerm);
|
||||
|
||||
// get the "and" / "or" value from the first term
|
||||
if (i == 0) {
|
||||
if (searchTerm.booleanAnd)
|
||||
searchUri += "and";
|
||||
else
|
||||
searchUri += "or";
|
||||
}
|
||||
|
||||
var attrs;
|
||||
|
||||
switch (searchTerm.attrib) {
|
||||
case nsMsgSearchAttrib.Name:
|
||||
if (gSearchPhoneticName == "false")
|
||||
attrs = ["DisplayName","FirstName","LastName","NickName","_AimScreenName"];
|
||||
else
|
||||
attrs = ["DisplayName","FirstName","LastName","NickName","_AimScreenName","PhoneticFirstName","PhoneticLastName"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.DisplayName:
|
||||
attrs = ["DisplayName"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Email:
|
||||
attrs = ["PrimaryEmail"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.PhoneNumber:
|
||||
attrs = ["HomePhone","WorkPhone","FaxNumber","PagerNumber","CellularNumber"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Organization:
|
||||
attrs = ["Company"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Department:
|
||||
attrs = ["Department"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.City:
|
||||
attrs = ["WorkCity"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Street:
|
||||
attrs = ["WorkAddress"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Nickname:
|
||||
attrs = ["NickName"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.WorkPhone:
|
||||
attrs = ["WorkPhone"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.HomePhone:
|
||||
attrs = ["HomePhone"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Fax:
|
||||
attrs = ["FaxNumber"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Pager:
|
||||
attrs = ["PagerNumber"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Mobile:
|
||||
attrs = ["CellularNumber"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.Title:
|
||||
attrs = ["JobTitle"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.AdditionalEmail:
|
||||
attrs = ["SecondEmail"];
|
||||
break;
|
||||
case nsMsgSearchAttrib.ScreenName:
|
||||
attrs = ["_AimScreenName"];
|
||||
break;
|
||||
default:
|
||||
dump("XXX " + searchTerm.attrib + " not a supported search attr!\n");
|
||||
attrs = ["DisplayName"];
|
||||
break;
|
||||
}
|
||||
|
||||
var opStr;
|
||||
|
||||
switch (searchTerm.op) {
|
||||
case nsMsgSearchOp.Contains:
|
||||
opStr = "c";
|
||||
break;
|
||||
case nsMsgSearchOp.DoesntContain:
|
||||
opStr = "!c";
|
||||
break;
|
||||
case nsMsgSearchOp.Is:
|
||||
opStr = "=";
|
||||
break;
|
||||
case nsMsgSearchOp.Isnt:
|
||||
opStr = "!=";
|
||||
break;
|
||||
case nsMsgSearchOp.BeginsWith:
|
||||
opStr = "bw";
|
||||
break;
|
||||
case nsMsgSearchOp.EndsWith:
|
||||
opStr = "ew";
|
||||
break;
|
||||
case nsMsgSearchOp.SoundsLike:
|
||||
opStr = "~=";
|
||||
break;
|
||||
default:
|
||||
opStr = "c";
|
||||
break;
|
||||
}
|
||||
|
||||
// currently, we can't do "and" and "or" searches at the same time
|
||||
// (it's either all "and"s or all "or"s)
|
||||
var max_attrs = attrs.length;
|
||||
|
||||
for (var j=0;j<max_attrs;j++) {
|
||||
// append the term(s) to the searchUri
|
||||
searchUri += "(" + attrs[j] + "," + opStr + "," + escape(searchTerm.value.str) + ")";
|
||||
}
|
||||
}
|
||||
|
||||
searchUri += ")";
|
||||
SetAbView(searchUri, null, null);
|
||||
}
|
||||
|
||||
// used to toggle functionality for Search/Stop button.
|
||||
function onSearchButton(event)
|
||||
{
|
||||
if (event.target.label == gSearchBundle.getString("labelForSearchButton"))
|
||||
onSearch();
|
||||
else
|
||||
onSearchStop();
|
||||
}
|
||||
|
||||
function GetAbViewListener()
|
||||
{
|
||||
return gSearchAbViewListener;
|
||||
}
|
||||
|
||||
function onProperties()
|
||||
{
|
||||
AbEditSelectedCard();
|
||||
}
|
||||
|
||||
function onCompose()
|
||||
{
|
||||
AbNewMessage();
|
||||
}
|
||||
|
||||
function AbResultsPaneDoubleClick(card)
|
||||
{
|
||||
AbEditCard(card);
|
||||
}
|
||||
|
||||
function UpdateCardView()
|
||||
{
|
||||
var numSelected = GetNumSelectedCards();
|
||||
|
||||
if (!numSelected) {
|
||||
gPropertiesButton.setAttribute("disabled","true");
|
||||
gComposeButton.setAttribute("disabled","true");
|
||||
return;
|
||||
}
|
||||
|
||||
gComposeButton.removeAttribute("disabled");
|
||||
|
||||
if (numSelected == 1)
|
||||
gPropertiesButton.removeAttribute("disabled");
|
||||
else
|
||||
gPropertiesButton.setAttribute("disabled","true");
|
||||
}
|
||||
|
||||
function onChooseDirectory(event)
|
||||
{
|
||||
var directoryURI = event.id;
|
||||
if (directoryURI) {
|
||||
SelectDirectory(directoryURI);
|
||||
}
|
||||
}
|
@ -844,7 +844,6 @@ function AddToSession()
|
||||
function InitPanes()
|
||||
{
|
||||
OnLoadFolderPane();
|
||||
OnLoadThreadPane();
|
||||
SetupCommandUpdateHandlers();
|
||||
}
|
||||
|
||||
@ -870,28 +869,8 @@ function OnFolderUnreadColAttrModified(event)
|
||||
}
|
||||
}
|
||||
|
||||
// builds prior to 8-14-2001 did not have the unread and total columns
|
||||
// in the folder pane. so if a user ran an old build, and then
|
||||
// upgraded, they get the new columns, and this causes problems
|
||||
// because it looks like all the folder names are gone (see bug #96979)
|
||||
// to work around this, we hide those columns once, using the
|
||||
// "mail.ui.folderpane.version" pref.
|
||||
function UpgradeFolderPaneUI()
|
||||
{
|
||||
var folderPaneUIVersion = pref.getIntPref("mail.ui.folderpane.version");
|
||||
|
||||
if (folderPaneUIVersion == 1) {
|
||||
pref.setIntPref("mail.ui.folderpane.version", 2);
|
||||
} // we fall through to the == 2 case so we'll upgrade v 1 profiles correctly
|
||||
if (folderPaneUIVersion <= 2) {
|
||||
pref.setIntPref("mail.ui.folderpane.version", 3);
|
||||
}
|
||||
}
|
||||
|
||||
function OnLoadFolderPane()
|
||||
{
|
||||
UpgradeFolderPaneUI();
|
||||
|
||||
//Add folderDataSource and accountManagerDataSource to folderPane
|
||||
accountManagerDataSource = accountManagerDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource);
|
||||
@ -908,48 +887,6 @@ function OnLoadFolderPane()
|
||||
folderTree.addEventListener("mousedown",TreeOnMouseDown,true);
|
||||
}
|
||||
|
||||
// builds prior to 12-08-2001 did not have the labels column
|
||||
// in the thread pane. so if a user ran an old build, and then
|
||||
// upgraded, they get the new column, and this causes problems.
|
||||
// We're trying to avoid a similar problem to bug #96979.
|
||||
// to work around this, we hide the column once, using the
|
||||
// "mailnews.ui.threadpane.version" pref.
|
||||
function UpgradeThreadPaneUI()
|
||||
{
|
||||
var labelCol;
|
||||
var threadPaneUIVersion;
|
||||
|
||||
try {
|
||||
threadPaneUIVersion = pref.getIntPref("mailnews.ui.threadpane.version");
|
||||
if (threadPaneUIVersion < 3) {
|
||||
var subjectCol = document.getElementById("subjectCol");
|
||||
var junkCol = document.getElementById("junkStatusCol");
|
||||
var threadTree = document.getElementById("threadTree");
|
||||
|
||||
var beforeCol = subjectCol.boxObject.nextSibling.boxObject.nextSibling;
|
||||
if (beforeCol)
|
||||
threadTree._reorderColumn(junkCol, beforeCol, true);
|
||||
else // subjectCol was the last column, put it after
|
||||
threadTree._reorderColumn(junkCol, subjectCol, false);
|
||||
|
||||
if (threadPaneUIVersion == 1) {
|
||||
labelCol = document.getElementById("labelCol");
|
||||
labelCol.setAttribute("hidden", "true");
|
||||
}
|
||||
|
||||
pref.setIntPref("mailnews.ui.threadpane.version", 3);
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
dump("UpgradeThreadPane: ex = " + ex + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
function OnLoadThreadPane()
|
||||
{
|
||||
UpgradeThreadPaneUI();
|
||||
}
|
||||
|
||||
function GetFolderDatasource()
|
||||
{
|
||||
var folderTree = GetFolderTree();
|
||||
|
@ -15,6 +15,7 @@ messenger.jar:
|
||||
*+ content/messenger/widgetglue.js (content/widgetglue.js)
|
||||
*+ content/messenger/SearchDialog.xul (content/SearchDialog.xul)
|
||||
*+ content/messenger/ABSearchDialog.xul (content/ABSearchDialog.xul)
|
||||
*+ content/messenger/ABSearchDialog.js (content/ABSearchDialog.js)
|
||||
*+ content/messenger/subscribe.xul (content/subscribe.xul)
|
||||
*+ content/messenger/aboutDialog.xul (content/aboutDialog.xul)
|
||||
*+ content/messenger/junkMail.xul (content/junkMail.xul)
|
||||
|
966
mail/components/addrbook/content/abCommon.js
Normal file
966
mail/components/addrbook/content/abCommon.js
Normal file
@ -0,0 +1,966 @@
|
||||
# ***** 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 Addressbook.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corp.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1999-2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Original Author:
|
||||
# Paul Hangas <hangas@netscape.com>
|
||||
#
|
||||
# Contributor(s):
|
||||
# Seth Spitzer <sspitzer@netscape.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 dirTree = 0;
|
||||
var abList = 0;
|
||||
var gAbResultsTree = null;
|
||||
var gAbView = null;
|
||||
|
||||
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";
|
||||
|
||||
// List/card selections in the results pane.
|
||||
const kNothingSelected = 0;
|
||||
const kListsAndCards = 1;
|
||||
const kMultipleListsOnly = 2;
|
||||
const kSingleListOnly = 3;
|
||||
const kCardsOnly = 4;
|
||||
|
||||
// Controller object for Results Pane
|
||||
var ResultsPaneController =
|
||||
{
|
||||
supportsCommand: function(command)
|
||||
{
|
||||
switch (command) {
|
||||
case "cmd_selectAll":
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
case "button_edit":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
isCommandEnabled: function(command)
|
||||
{
|
||||
switch (command) {
|
||||
case "cmd_selectAll":
|
||||
return true;
|
||||
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
var numSelected;
|
||||
var enabled = false;
|
||||
if (gAbView && gAbView.selection) {
|
||||
if (gAbView.directory)
|
||||
enabled = gAbView.directory.operations & gAbView.directory.opWrite;
|
||||
numSelected = gAbView.selection.count;
|
||||
}
|
||||
else
|
||||
numSelected = 0;
|
||||
|
||||
// fix me, don't update on isCommandEnabled
|
||||
if (command == "cmd_delete") {
|
||||
if (numSelected < 2)
|
||||
goSetMenuValue(command, "valueCard");
|
||||
else
|
||||
goSetMenuValue(command, "valueCards");
|
||||
}
|
||||
return (enabled && (numSelected > 0));
|
||||
case "button_edit":
|
||||
return (GetSelectedCardIndex() != -1);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function(command)
|
||||
{
|
||||
switch (command) {
|
||||
case "cmd_selectAll":
|
||||
if (gAbView)
|
||||
gAbView.selectAll();
|
||||
break;
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
AbDelete();
|
||||
break;
|
||||
case "button_edit":
|
||||
AbEditSelectedCard();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function(event)
|
||||
{
|
||||
// on blur events set the menu item texts back to the normal values
|
||||
if (event == "blur")
|
||||
goSetMenuValue("cmd_delete", "valueDefault");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Controller object for Dir Pane
|
||||
var DirPaneController =
|
||||
{
|
||||
supportsCommand: function(command)
|
||||
{
|
||||
switch (command) {
|
||||
case "cmd_selectAll":
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
case "button_edit":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
isCommandEnabled: function(command)
|
||||
{
|
||||
var selectedDir;
|
||||
|
||||
switch (command) {
|
||||
case "cmd_selectAll":
|
||||
// the dirTree pane
|
||||
// only handles single selection
|
||||
// so we forward select all to the results pane
|
||||
// but if there is no gAbView
|
||||
// don't bother sending to the results pane
|
||||
return (gAbView != null);
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
if (command == "cmd_delete")
|
||||
goSetMenuValue(command, "valueAddressBook");
|
||||
selectedDir = GetSelectedDirectory();
|
||||
if (selectedDir) {
|
||||
// If the selected directory is an ldap directory
|
||||
// and if the prefs for this directory are locked
|
||||
// disable the delete button.
|
||||
var ldapUrlPrefix = "moz-abldapdirectory://";
|
||||
if ((selectedDir.indexOf(ldapUrlPrefix, 0)) == 0)
|
||||
{
|
||||
var prefName = selectedDir.substr(ldapUrlPrefix.length, selectedDir.length);
|
||||
var disable = false;
|
||||
try {
|
||||
disable = gPrefs.getBoolPref(prefName + ".disable_delete");
|
||||
}
|
||||
catch(ex){
|
||||
// if this preference is not set its ok.
|
||||
}
|
||||
if (disable)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
case "button_edit":
|
||||
return (GetSelectedDirectory() != null);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function(command)
|
||||
{
|
||||
switch (command) {
|
||||
case "cmd_selectAll":
|
||||
SendCommandToResultsPane(command);
|
||||
break;
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
if (dirTree)
|
||||
AbDeleteDirectory();
|
||||
break;
|
||||
case "button_edit":
|
||||
AbEditSelectedDirectory();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
onEvent: function(event)
|
||||
{
|
||||
// on blur events set the menu item texts back to the normal values
|
||||
if (event == "blur")
|
||||
goSetMenuValue("cmd_delete", "valueDefault");
|
||||
}
|
||||
};
|
||||
|
||||
function SendCommandToResultsPane(command)
|
||||
{
|
||||
ResultsPaneController.doCommand(command);
|
||||
|
||||
// if we are sending the command so the results pane
|
||||
// we should focus the results pane
|
||||
gAbResultsTree.focus();
|
||||
}
|
||||
|
||||
function AbEditSelectedDirectory()
|
||||
{
|
||||
if (dirTree.treeBoxObject.selection.count == 1) {
|
||||
var selecteduri = GetSelectedDirectory();
|
||||
var directory = GetDirectoryFromURI(selecteduri);
|
||||
if (directory.isMailList) {
|
||||
var dirUri = GetParentDirectoryFromMailingListURI(selecteduri);
|
||||
goEditListDialog(dirUri, null, selecteduri, UpdateCardView);
|
||||
}
|
||||
else {
|
||||
var properties = directory.directoryProperties;
|
||||
if (properties.dirType == kLDAPDirectory) {
|
||||
var ldapUrlPrefix = "moz-abldapdirectory://";
|
||||
var args = { selectedDirectory: directory.dirName,
|
||||
selectedDirectoryString: null};
|
||||
args.selectedDirectoryString = selecteduri.substr(ldapUrlPrefix.length, selecteduri.length);
|
||||
window.openDialog("chrome://messenger/content/addressbook/pref-directory-add.xul",
|
||||
"editDirectory", "chrome,modal=yes,resizable=no,centerscreen", args);
|
||||
}
|
||||
else {
|
||||
AbRenameAddressBook();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetParentRow(aTree, aRow)
|
||||
{
|
||||
var row = aRow;
|
||||
var level = aTree.view.getLevel(row);
|
||||
var parentLevel = level;
|
||||
while (parentLevel >= level) {
|
||||
row--;
|
||||
if (row == -1)
|
||||
return row;
|
||||
parentLevel = aTree.view.getLevel(row);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
function InitCommonJS()
|
||||
{
|
||||
dirTree = document.getElementById("dirTree");
|
||||
abList = document.getElementById("addressbookList");
|
||||
gAbResultsTree = document.getElementById("abResultsTree");
|
||||
}
|
||||
|
||||
function SetupAbCommandUpdateHandlers()
|
||||
{
|
||||
// dir pane
|
||||
if (dirTree)
|
||||
dirTree.controllers.appendController(DirPaneController);
|
||||
|
||||
// results pane
|
||||
if (gAbResultsTree)
|
||||
gAbResultsTree.controllers.appendController(ResultsPaneController);
|
||||
}
|
||||
|
||||
function GetSelectedCardTypes()
|
||||
{
|
||||
var cards = GetSelectedAbCards();
|
||||
if (!cards)
|
||||
return kNothingSelected; // no view
|
||||
|
||||
var count = cards.length;
|
||||
if (!count)
|
||||
return kNothingSelected; // nothing selected
|
||||
|
||||
var mailingListCnt = 0;
|
||||
var cardCnt = 0;
|
||||
for (var i = 0; i < count; i++) {
|
||||
if (cards[i].isMailList)
|
||||
mailingListCnt++;
|
||||
else
|
||||
cardCnt++;
|
||||
}
|
||||
if (mailingListCnt && cardCnt)
|
||||
return kListsAndCards; // lists and cards selected
|
||||
else if (mailingListCnt && !cardCnt) {
|
||||
if (mailingListCnt > 1)
|
||||
return kMultipleListsOnly; // only multiple mailing lists selected
|
||||
else
|
||||
return kSingleListOnly; // only single mailing list
|
||||
}
|
||||
else if (!mailingListCnt && cardCnt)
|
||||
return kCardsOnly; // only card(s) selected
|
||||
}
|
||||
|
||||
function AbDelete()
|
||||
{
|
||||
var types = GetSelectedCardTypes();
|
||||
if (types == kNothingSelected)
|
||||
return;
|
||||
|
||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
|
||||
// If at least one mailing list is selected then prompt users for deletion.
|
||||
if (types != kCardsOnly)
|
||||
{
|
||||
var confirmDeleteMessage;
|
||||
if (types == kListsAndCards)
|
||||
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteListsAndCards");
|
||||
else if (types == kMultipleListsOnly)
|
||||
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteMailingLists");
|
||||
else
|
||||
confirmDeleteMessage = gAddressBookBundle.getString("confirmDeleteMailingList");
|
||||
if (!promptService.confirm(window, null, confirmDeleteMessage))
|
||||
return;
|
||||
}
|
||||
|
||||
gAbView.deleteSelectedCards();
|
||||
}
|
||||
|
||||
function AbNewCard(abListItem)
|
||||
{
|
||||
goNewCardDialog(GetSelectedDirectory());
|
||||
}
|
||||
|
||||
// NOTE, will return -1 if more than one card selected, or no cards selected.
|
||||
function GetSelectedCardIndex()
|
||||
{
|
||||
if (!gAbView)
|
||||
return -1;
|
||||
|
||||
var treeSelection = gAbView.selection;
|
||||
if (treeSelection.getRangeCount() == 1) {
|
||||
var start = new Object;
|
||||
var end = new Object;
|
||||
treeSelection.getRangeAt(0,start,end);
|
||||
if (start.value == end.value)
|
||||
return start.value;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// NOTE, returns the card if exactly one card is selected, null otherwise
|
||||
function GetSelectedCard()
|
||||
{
|
||||
var index = GetSelectedCardIndex();
|
||||
if (index == -1)
|
||||
return null;
|
||||
else
|
||||
return gAbView.getCardFromRow(index);
|
||||
}
|
||||
|
||||
function AbEditSelectedCard()
|
||||
{
|
||||
AbEditCard(GetSelectedCard());
|
||||
}
|
||||
|
||||
function AbEditCard(card)
|
||||
{
|
||||
if (!card)
|
||||
return;
|
||||
|
||||
// Not allowing AOL special groups to be edited.
|
||||
if (card.isASpecialGroup)
|
||||
return;
|
||||
|
||||
if (card.isMailList) {
|
||||
goEditListDialog(GetSelectedDirectory(), card, card.mailListURI, UpdateCardView);
|
||||
}
|
||||
else {
|
||||
goEditCardDialog(GetSelectedDirectory(), card, UpdateCardView);
|
||||
}
|
||||
}
|
||||
|
||||
function AbNewMessage()
|
||||
{
|
||||
var msgComposeType = Components.interfaces.nsIMsgCompType;
|
||||
var msgComposFormat = Components.interfaces.nsIMsgCompFormat;
|
||||
var msgComposeService = Components.classes["@mozilla.org/messengercompose;1"].getService();
|
||||
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
|
||||
|
||||
var params = Components.classes["@mozilla.org/messengercompose/composeparams;1"].createInstance(Components.interfaces.nsIMsgComposeParams);
|
||||
if (params)
|
||||
{
|
||||
params.type = msgComposeType.New;
|
||||
params.format = msgComposFormat.Default;
|
||||
var composeFields = Components.classes["@mozilla.org/messengercompose/composefields;1"].createInstance(Components.interfaces.nsIMsgCompFields);
|
||||
if (composeFields)
|
||||
{
|
||||
if (DirPaneHasFocus())
|
||||
composeFields.to = GetSelectedAddressesFromDirTree();
|
||||
else
|
||||
composeFields.to = GetSelectedAddresses();
|
||||
params.composeFields = composeFields;
|
||||
msgComposeService.OpenComposeWindowWithParams(null, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetOneOrMoreCardsSelected()
|
||||
{
|
||||
if (!gAbView)
|
||||
return false;
|
||||
|
||||
return (gAbView.selection.getRangeCount() > 0);
|
||||
}
|
||||
|
||||
// XXX todo
|
||||
// could this be moved into utilityOverlay.js?
|
||||
function goToggleSplitter( id, elementID )
|
||||
{
|
||||
var splitter = document.getElementById( id );
|
||||
var element = document.getElementById( elementID );
|
||||
if ( splitter )
|
||||
{
|
||||
var attribValue = splitter.getAttribute("state") ;
|
||||
|
||||
if ( attribValue == "collapsed" )
|
||||
{
|
||||
splitter.setAttribute("state", "open" );
|
||||
if ( element )
|
||||
element.setAttribute("checked","true")
|
||||
}
|
||||
else
|
||||
{
|
||||
splitter.setAttribute("state", "collapsed");
|
||||
if ( element )
|
||||
element.setAttribute("checked","false")
|
||||
}
|
||||
document.persist(id, 'state');
|
||||
document.persist(elementID, 'checked');
|
||||
}
|
||||
}
|
||||
|
||||
// Generate a list of cards from the selected mailing list
|
||||
// and get a comma separated list of card addresses. If the
|
||||
// item selected in the directory pane is not a mailing list,
|
||||
// an empty string is returned.
|
||||
function GetSelectedAddressesFromDirTree()
|
||||
{
|
||||
var addresses = "";
|
||||
|
||||
if (dirTree.currentIndex >= 0) {
|
||||
var selectedResource = dirTree.builderView.getResourceAtIndex(dirTree.currentIndex);
|
||||
var mailingListUri = selectedResource.Value;
|
||||
var directory = GetDirectoryFromURI(mailingListUri);
|
||||
if (directory.isMailList) {
|
||||
var listCardsCount = directory.addressLists.Count();
|
||||
var cards = new Array(listCardsCount);
|
||||
for ( var i = 0; i < listCardsCount; i++ ) {
|
||||
var card = directory.addressLists.GetElementAt(i);
|
||||
card = card.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
cards[i] = card;
|
||||
}
|
||||
addresses = GetAddressesForCards(cards);
|
||||
}
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
function GetSelectedAddresses()
|
||||
{
|
||||
var selectedCards = GetSelectedAbCards();
|
||||
return GetAddressesForCards(selectedCards);
|
||||
}
|
||||
|
||||
// Generate a comma separated list of addresses from a given
|
||||
// set of cards.
|
||||
function GetAddressesForCards(cards)
|
||||
{
|
||||
var addresses = "";
|
||||
|
||||
if (!cards)
|
||||
return addresses;
|
||||
|
||||
var count = cards.length;
|
||||
if (count > 0)
|
||||
addresses += GenerateAddressFromCard(cards[0]);
|
||||
|
||||
for (var i = 1; i < count; i++) {
|
||||
var generatedAddress = GenerateAddressFromCard(cards[i]);
|
||||
|
||||
if (generatedAddress)
|
||||
addresses += "," + generatedAddress;
|
||||
}
|
||||
return addresses;
|
||||
}
|
||||
|
||||
function GetNumSelectedCards()
|
||||
{
|
||||
try {
|
||||
var treeSelection = gAbView.selection;
|
||||
return treeSelection.count;
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
|
||||
// if something went wrong, return 0 for the count.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// XXX todo
|
||||
// an optimization might be to make this return
|
||||
// the selected ranges, which would be faster
|
||||
// when the user does large selections, but for now, let's keep it simple.
|
||||
function GetSelectedRows()
|
||||
{
|
||||
var selectedRows = "";
|
||||
|
||||
if (!gAbView)
|
||||
return selectedRows;
|
||||
|
||||
var i,j;
|
||||
var rangeCount = gAbView.selection.getRangeCount();
|
||||
var current = 0;
|
||||
|
||||
for (i=0; i < rangeCount; i++) {
|
||||
var start = new Object;
|
||||
var end = new Object;
|
||||
gAbView.selection.getRangeAt(i,start,end);
|
||||
for (j=start.value;j<=end.value;j++) {
|
||||
if (selectedRows)
|
||||
selectedRows += ",";
|
||||
selectedRows += j;
|
||||
}
|
||||
}
|
||||
return selectedRows;
|
||||
}
|
||||
|
||||
function GetSelectedAbCards()
|
||||
{
|
||||
var abView = gAbView;
|
||||
|
||||
// if sidebar is open, and addressbook panel is open and focused,
|
||||
// then use the ab view from sidebar (gCurFrame is from sidebarOverlay.js)
|
||||
const abPanelUrl = "chrome://messenger/content/addressbook/addressbook-panel.xul";
|
||||
if (document.getElementById("sidebar-box")) {
|
||||
if (gCurFrame &&
|
||||
gCurFrame.getAttribute("src") == abPanelUrl &&
|
||||
document.commandDispatcher.focusedWindow == gCurFrame.contentDocument.defaultView)
|
||||
{
|
||||
abView = gCurFrame.contentDocument.defaultView.gAbView;
|
||||
}
|
||||
}
|
||||
|
||||
if (!abView)
|
||||
return null;
|
||||
|
||||
var cards = new Array(abView.selection.count);
|
||||
var i,j;
|
||||
var count = abView.selection.getRangeCount();
|
||||
|
||||
var current = 0;
|
||||
|
||||
for (i=0; i < count; i++) {
|
||||
var start = new Object;
|
||||
var end = new Object;
|
||||
abView.selection.getRangeAt(i,start,end);
|
||||
for (j=start.value;j<=end.value;j++) {
|
||||
cards[current] = abView.getCardFromRow(j);
|
||||
current++;
|
||||
}
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
||||
function SelectFirstAddressBook()
|
||||
{
|
||||
dirTree.view.selection.select(0);
|
||||
|
||||
ChangeDirectoryByURI(GetSelectedDirectory());
|
||||
gAbResultsTree.focus();
|
||||
}
|
||||
|
||||
function SelectFirstCard()
|
||||
{
|
||||
if (gAbView && gAbView.selection) {
|
||||
gAbView.selection.select(0);
|
||||
}
|
||||
}
|
||||
|
||||
function DirPaneClick(event)
|
||||
{
|
||||
// we only care about left button events
|
||||
if (event.button != 0)
|
||||
return;
|
||||
|
||||
// if the user clicks on the header / trecol, do nothing
|
||||
if (event.originalTarget.localName == "treecol")
|
||||
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(event)
|
||||
{
|
||||
// if the user clicks on the header / trecol, do nothing
|
||||
if (event.originalTarget.localName == "treecol")
|
||||
return;
|
||||
|
||||
if (dirTree && dirTree.treeBoxObject.selection && dirTree.treeBoxObject.selection.count == 1)
|
||||
AbEditSelectedDirectory();
|
||||
}
|
||||
|
||||
function DirPaneSelectionChange()
|
||||
{
|
||||
if (dirTree && dirTree.treeBoxObject.selection && dirTree.treeBoxObject.selection.count == 1)
|
||||
ChangeDirectoryByURI(GetSelectedDirectory());
|
||||
}
|
||||
|
||||
function GetAbResultsBoxObject()
|
||||
{
|
||||
if (!gAbResultsTree)
|
||||
gAbResultsTree = document.getElementById('abResultsTree');
|
||||
|
||||
return gAbResultsTree.treeBoxObject;
|
||||
}
|
||||
|
||||
function CloseAbView()
|
||||
{
|
||||
var boxObject = GetAbResultsBoxObject();
|
||||
boxObject.view = null;
|
||||
|
||||
if (gAbView) {
|
||||
gAbView.close();
|
||||
gAbView = null;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
var boxObject = GetAbResultsBoxObject();
|
||||
boxObject.view = gAbView.QueryInterface(Components.interfaces.nsITreeView);
|
||||
|
||||
UpdateSortIndicators(sortColumn, sortDirection);
|
||||
|
||||
return actualSortColumn;
|
||||
}
|
||||
|
||||
function GetAbView()
|
||||
{
|
||||
return gAbView;
|
||||
}
|
||||
|
||||
// this will return the complete search uri if a quick search is currently being
|
||||
// done. to get the uri of the directory only, use GetSelectedDirectory().
|
||||
function GetAbViewURI()
|
||||
{
|
||||
if (gAbView)
|
||||
return gAbView.URI;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
function ChangeDirectoryByURI(uri)
|
||||
{
|
||||
if (!uri)
|
||||
uri = kPersonalAddressbookURI;
|
||||
|
||||
if (gAbView && GetAbViewURI() == uri)
|
||||
return;
|
||||
|
||||
var sortColumn = gAbResultsTree.getAttribute("sortCol");
|
||||
var sortDirection = document.getElementById(sortColumn).getAttribute("sortDirection");
|
||||
|
||||
var actualSortColumn = SetAbView(uri, sortColumn, sortDirection);
|
||||
|
||||
UpdateSortIndicators(actualSortColumn, sortDirection);
|
||||
|
||||
// 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()
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function AbSortAscending()
|
||||
{
|
||||
var sortColumn = gAbResultsTree.getAttribute("sortCol");
|
||||
SortAndUpdateIndicators(sortColumn, kDefaultAscending);
|
||||
}
|
||||
|
||||
function AbSortDescending()
|
||||
{
|
||||
var sortColumn = gAbResultsTree.getAttribute("sortCol");
|
||||
SortAndUpdateIndicators(sortColumn, kDefaultDescending);
|
||||
}
|
||||
|
||||
function SortResultPane(sortColumn)
|
||||
{
|
||||
var sortDirection = kDefaultAscending;
|
||||
|
||||
if (gAbView) {
|
||||
sortDirection = gAbView.sortDirection;
|
||||
}
|
||||
|
||||
SortAndUpdateIndicators(sortColumn, sortDirection);
|
||||
}
|
||||
|
||||
function SortAndUpdateIndicators(sortColumn, sortDirection)
|
||||
{
|
||||
// XXX todo remove once #116341 is fixed
|
||||
if (!sortColumn)
|
||||
return;
|
||||
|
||||
UpdateSortIndicators(sortColumn, sortDirection);
|
||||
|
||||
if (gAbView)
|
||||
gAbView.sortBy(sortColumn, sortDirection);
|
||||
}
|
||||
|
||||
function UpdateSortIndicators(colID, sortDirection)
|
||||
{
|
||||
var sortedColumn;
|
||||
// set the sort indicator on the column we are sorted by
|
||||
if (colID) {
|
||||
sortedColumn = document.getElementById(colID);
|
||||
if (sortedColumn) {
|
||||
sortedColumn.setAttribute("sortDirection",sortDirection);
|
||||
gAbResultsTree.setAttribute("sortCol", colID);
|
||||
}
|
||||
}
|
||||
|
||||
// remove the sort indicator from all the columns
|
||||
// except the one we are sorted by
|
||||
var currCol = gAbResultsTree.firstChild.firstChild;
|
||||
while (currCol) {
|
||||
if (currCol != sortedColumn && currCol.localName == "treecol")
|
||||
currCol.removeAttribute("sortDirection");
|
||||
currCol = currCol.nextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
function InvalidateResultsPane()
|
||||
{
|
||||
if (gAbResultsTree)
|
||||
gAbResultsTree.treeBoxObject.invalidate();
|
||||
}
|
||||
|
||||
function AbNewList(abListItem)
|
||||
{
|
||||
goNewListDialog(GetSelectedDirectory());
|
||||
}
|
||||
|
||||
function goNewListDialog(selectedAB)
|
||||
{
|
||||
window.openDialog("chrome://messenger/content/addressbook/abMailListDialog.xul",
|
||||
"",
|
||||
"chrome,resizable=no,titlebar,modal,centerscreen",
|
||||
{selectedAB:selectedAB});
|
||||
}
|
||||
|
||||
function goEditListDialog(abURI, abCard, listURI, okCallback)
|
||||
{
|
||||
window.openDialog("chrome://messenger/content/addressbook/abEditListDialog.xul",
|
||||
"",
|
||||
"chrome,resizable=no,titlebar,modal,centerscreen",
|
||||
{abURI:abURI, abCard:abCard, listURI:listURI, okCallback:okCallback});
|
||||
}
|
||||
|
||||
function goNewCardDialog(selectedAB)
|
||||
{
|
||||
window.openDialog("chrome://messenger/content/addressbook/abNewCardDialog.xul",
|
||||
"",
|
||||
"chrome,resizable=no,titlebar,modal,centerscreen",
|
||||
{selectedAB:selectedAB});
|
||||
}
|
||||
|
||||
function goEditCardDialog(abURI, card, okCallback)
|
||||
{
|
||||
window.openDialog("chrome://messenger/content/addressbook/abEditCardDialog.xul",
|
||||
"",
|
||||
"chrome,resizable=no,modal,titlebar,centerscreen",
|
||||
{abURI:abURI, card:card, okCallback:okCallback});
|
||||
}
|
||||
|
||||
|
||||
function setSortByMenuItemCheckState(id, value)
|
||||
{
|
||||
var menuitem = document.getElementById(id);
|
||||
if (menuitem) {
|
||||
menuitem.setAttribute("checked", value);
|
||||
}
|
||||
}
|
||||
|
||||
function InitViewSortByMenu()
|
||||
{
|
||||
var sortColumn = kDefaultSortColumn;
|
||||
var sortDirection = kDefaultAscending;
|
||||
|
||||
if (gAbView) {
|
||||
sortColumn = gAbView.sortColumn;
|
||||
sortDirection = gAbView.sortDirection;
|
||||
}
|
||||
|
||||
// this approach is necessary to support generic columns that get overlayed.
|
||||
var elements = document.getElementsByAttribute("name","sortas");
|
||||
for (var i=0; i<elements.length; i++) {
|
||||
var cmd = elements[i].getAttribute("id");
|
||||
var columnForCmd = cmd.split("cmd_SortBy")[1];
|
||||
setSortByMenuItemCheckState(cmd, (sortColumn == columnForCmd));
|
||||
}
|
||||
|
||||
setSortByMenuItemCheckState("sortAscending", (sortDirection == kDefaultAscending));
|
||||
setSortByMenuItemCheckState("sortDescending", (sortDirection == kDefaultDescending));
|
||||
}
|
||||
|
||||
function GenerateAddressFromCard(card)
|
||||
{
|
||||
if (!card)
|
||||
return "";
|
||||
|
||||
var email;
|
||||
|
||||
if (card.isMailList)
|
||||
{
|
||||
var directory = GetDirectoryFromURI(card.mailListURI);
|
||||
if(directory.description)
|
||||
email = directory.description;
|
||||
else
|
||||
email = card.displayName;
|
||||
}
|
||||
else
|
||||
email = card.primaryEmail;
|
||||
|
||||
return gHeaderParser.makeFullAddressWString(card.displayName, email);
|
||||
}
|
||||
|
||||
function GetDirectoryFromURI(uri)
|
||||
{
|
||||
var directory = rdf.GetResource(uri).QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
return directory;
|
||||
}
|
||||
|
||||
// returns null if abURI is not a mailing list URI
|
||||
function GetParentDirectoryFromMailingListURI(abURI)
|
||||
{
|
||||
var abURIArr = abURI.split("/");
|
||||
/*
|
||||
turn turn "moz-abmdbdirectory://abook.mab/MailList6"
|
||||
into ["moz-abmdbdirectory:","","abook.mab","MailList6"]
|
||||
then, turn ["moz-abmdbdirectory:","","abook.mab","MailList6"]
|
||||
into "moz-abmdbdirectory://abook.mab"
|
||||
*/
|
||||
if (abURIArr.length == 4 && abURIArr[0] == "moz-abmdbdirectory:" && abURIArr[3] != "") {
|
||||
return abURIArr[0] + "/" + abURIArr[1] + "/" + abURIArr[2];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function DirPaneHasFocus()
|
||||
{
|
||||
// returns true if diectory pane has the focus. Returns false, otherwise.
|
||||
return (top.document.commandDispatcher.focusedElement == dirTree)
|
||||
}
|
||||
|
||||
function GetSelectedDirectory()
|
||||
{
|
||||
if (abList)
|
||||
return abList.selectedItem.id;
|
||||
else {
|
||||
if (dirTree.currentIndex < 0)
|
||||
return null;
|
||||
var selected = dirTree.builderView.getResourceAtIndex(dirTree.currentIndex)
|
||||
return selected.Value;
|
||||
}
|
||||
}
|
||||
|
||||
function onAbSearchKeyPress(event)
|
||||
{
|
||||
// 13 == return
|
||||
if (event && event.keyCode == 13)
|
||||
onAbSearchInput(true);
|
||||
}
|
||||
|
||||
function onAbSearchInput(returnKeyHit)
|
||||
{
|
||||
SearchInputChanged();
|
||||
|
||||
if (gSearchTimer) {
|
||||
clearTimeout(gSearchTimer);
|
||||
gSearchTimer = null;
|
||||
}
|
||||
|
||||
if (returnKeyHit) {
|
||||
gSearchInput.select();
|
||||
onEnterInSearchBar();
|
||||
}
|
||||
else {
|
||||
gSearchTimer = setTimeout("onEnterInSearchBar();", 800);
|
||||
}
|
||||
}
|
||||
|
||||
function SearchInputChanged()
|
||||
{
|
||||
var clearButton = document.getElementById("clear");
|
||||
if (clearButton) {
|
||||
if (gSearchInput.value && (gSearchInput.value != ""))
|
||||
clearButton.removeAttribute("disabled");
|
||||
else
|
||||
clearButton.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
function onAbClearSearch()
|
||||
{
|
||||
if (gSearchInput)
|
||||
gSearchInput.value =""; //on input does not get fired for some reason
|
||||
onAbSearchInput(true);
|
||||
}
|
||||
|
||||
function AbSwapFirstNameLastName()
|
||||
{
|
||||
if (gAbView)
|
||||
gAbView.swapFirstNameLastName();
|
||||
}
|
@ -121,9 +121,7 @@ function LoadPreviouslySelectedAB()
|
||||
|
||||
function AbPanelLoad()
|
||||
{
|
||||
InitCommonJS();
|
||||
|
||||
UpgradeAddressBookResultsPaneUI("mailnews.ui.addressbook_panel_results.version");
|
||||
InitCommonJS();
|
||||
|
||||
LoadPreviouslySelectedAB();
|
||||
|
||||
|
@ -149,8 +149,6 @@ function delayedOnLoadAddressBook()
|
||||
|
||||
InitCommonJS();
|
||||
|
||||
UpgradeAddressBookResultsPaneUI("mailnews.ui.addressbook_results.version");
|
||||
|
||||
GetCurrentPrefs();
|
||||
|
||||
AddPrefObservers();
|
||||
|
@ -8,6 +8,7 @@ messenger.jar:
|
||||
*+ content/messenger/addressbook/abCardViewOverlay.js (content/abCardViewOverlay.js)
|
||||
*+ content/messenger/addressbook/addressbook.js (content/addressbook.js)
|
||||
*+ 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/abAddressBookNameDialog.js (content/abAddressBookNameDialog.js)
|
||||
*+ content/messenger/addressbook/abAddressBookNameDialog.xul (content/abAddressBookNameDialog.xul)
|
||||
|
Loading…
Reference in New Issue
Block a user