Bug 449260 Replace rdf-driven addressbook popup menus with xbl based one. r=philor,sr=Neil
This commit is contained in:
Родитель
eecfd94dca
Коммит
df5d5e3888
|
@ -96,6 +96,9 @@ function searchOnLoad()
|
|||
|
||||
if (window.arguments && window.arguments[0])
|
||||
SelectDirectory(window.arguments[0].directory);
|
||||
else
|
||||
SelectDirectory(document.getElementById("abPopup-menupopup")
|
||||
.firstChild.value);
|
||||
|
||||
// initialize globals, see abCommon.js, InitCommonJS()
|
||||
abList = document.getElementById("abPopup");
|
||||
|
@ -367,11 +370,3 @@ function UpdateCardView()
|
|||
else
|
||||
gPropertiesButton.setAttribute("disabled","true");
|
||||
}
|
||||
|
||||
function onChooseDirectory(event)
|
||||
{
|
||||
var directoryURI = event.id;
|
||||
if (directoryURI) {
|
||||
SelectDirectory(directoryURI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
|
||||
<window id="searchAddressBookWindow"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
onload="searchOnLoad();"
|
||||
onunload="searchOnUnload();"
|
||||
onclose="onSearchStop();"
|
||||
|
@ -88,21 +87,8 @@
|
|||
<vbox>
|
||||
<hbox align="center">
|
||||
<label value="&abSearchHeading.label;" accesskey="&abSearchHeading.accesskey;" control="abPopup"/>
|
||||
<menulist id="abPopup">
|
||||
<menupopup id="abPopup-menupopup" ref="moz-abdirectory://"
|
||||
datasources="rdf:addressdirectory"
|
||||
sortActive="true"
|
||||
sortDirection="ascending"
|
||||
sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort"
|
||||
oncommand="onChooseDirectory(event.target);">
|
||||
<template>
|
||||
<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 id="abPopup" oncommand="SelectDirectory(this.value);">
|
||||
<menupopup id="abPopup-menupopup" class="addrbooksPopup"/>
|
||||
</menulist>
|
||||
<spacer flex="10"/>
|
||||
<button id="search-button" oncommand="onSearchButton(event);" default="true"/>
|
||||
|
|
|
@ -262,3 +262,7 @@ tabmail
|
|||
menupopup[type="folder"] {
|
||||
-moz-binding: url("chrome://messenger/content/folderWidgets.xml#folder-menupopup");
|
||||
}
|
||||
|
||||
.addrbooksPopup {
|
||||
-moz-binding: url("chrome://messenger/content/addressbook/addrbookWidgets.xml#addrbooks-menupopup");
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ function NewCardOKButton()
|
|||
var popup = document.getElementById('abPopup');
|
||||
if ( popup )
|
||||
{
|
||||
var uri = popup.getAttribute('value');
|
||||
var uri = popup.value;
|
||||
|
||||
// FIX ME - hack to avoid crashing if no ab selected because of blank option bug from template
|
||||
// should be able to just remove this if we are not seeing blank lines in the ab popup
|
||||
|
|
|
@ -90,7 +90,7 @@ var DirPaneController =
|
|||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
var selectedDir = GetSelectedDirectory();
|
||||
if (command == "cmd_delete")
|
||||
if (command == "cmd_delete" && selectedDir)
|
||||
goSetMenuValue(command, GetDirectoryFromURI(selectedDir).isMailList ?
|
||||
"valueList" : "valueAddressBook");
|
||||
|
||||
|
@ -610,7 +610,7 @@ function DirPaneHasFocus()
|
|||
function GetSelectedDirectory()
|
||||
{
|
||||
if (abList)
|
||||
return abList.selectedItem.id;
|
||||
return abList.value;
|
||||
else {
|
||||
if (dirTree.currentIndex < 0)
|
||||
return null;
|
||||
|
|
|
@ -74,62 +74,12 @@ function addSelectedAddresses(recipientType)
|
|||
}
|
||||
}
|
||||
|
||||
var gAddressBookPanelAbListener = {
|
||||
onItemAdded: function(parentDir, item) {
|
||||
// will not be called
|
||||
},
|
||||
onItemRemoved: function(parentDir, item) {
|
||||
// will only be called when an addressbook is deleted
|
||||
try {
|
||||
var directory = item.QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
// check if the item being removed is the directory
|
||||
// that we are showing in the addressbook sidebar
|
||||
// if so, select the person addressbook (it can't be removed)
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
if (directory.URI == abPopup.value) {
|
||||
abPopup.value = kPersonalAddressbookURI;
|
||||
LoadPreviouslySelectedAB();
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
},
|
||||
onItemPropertyChanged: function(item, property, oldValue, newValue) {
|
||||
try {
|
||||
var directory = item.QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
// check if the item being changed is the directory
|
||||
// that we are showing in the addressbook sidebar
|
||||
if (directory == GetAbView().directory) {
|
||||
LoadPreviouslySelectedAB();
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// XXX todo
|
||||
// can we combine some common code? see OnLoadNewMailList()
|
||||
// set popup with address book names
|
||||
function LoadPreviouslySelectedAB()
|
||||
{
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
var value = abPopup.value || kPersonalAddressbookURI;
|
||||
abPopup.selectedItem = null;
|
||||
abPopup.value = value;
|
||||
ChangeDirectoryByURI(abPopup.selectedItem.id);
|
||||
}
|
||||
|
||||
function AddressBookMenuListChange()
|
||||
{
|
||||
if (gSearchInput.value && !gSearchInput.showingSearchCriteria)
|
||||
onEnterInSearchBar();
|
||||
else
|
||||
{
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
ChangeDirectoryByURI(abPopup.selectedItem.id);
|
||||
}
|
||||
ChangeDirectoryByURI(document.getElementById('addressbookList').value);
|
||||
}
|
||||
|
||||
function AbPanelOnComposerClose()
|
||||
|
@ -149,16 +99,17 @@ function AbPanelLoad()
|
|||
|
||||
document.title = parent.document.getElementById("sidebar-title").value;
|
||||
|
||||
LoadPreviouslySelectedAB();
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
|
||||
// Add a listener, so we can switch directories if the current directory is
|
||||
// deleted, and change the name if the selected directory's name is modified.
|
||||
// This listener only cares when a directory is removed or modified.
|
||||
Components.classes["@mozilla.org/abmanager;1"]
|
||||
.getService(Components.interfaces.nsIAbManager)
|
||||
.addAddressBookListener(gAddressBookPanelAbListener,
|
||||
nsIAbListener.directoryRemoved |
|
||||
nsIAbListener.itemChanged);
|
||||
// Reselect the persisted address book if possible, if not just select the
|
||||
// first in the list.
|
||||
var temp = abPopup.value;
|
||||
abPopup.selectedItem = null;
|
||||
abPopup.value = temp;
|
||||
if (!abPopup.selectedItem)
|
||||
abPopup.selectedIndex = 0;
|
||||
|
||||
ChangeDirectoryByURI(abPopup.value);
|
||||
|
||||
parent.addEventListener("compose-window-close", AbPanelOnComposerClose, true);
|
||||
parent.addEventListener("compose-window-reopen", AbPanelOnComposerReOpen, true);
|
||||
|
@ -167,10 +118,6 @@ function AbPanelLoad()
|
|||
|
||||
function AbPanelUnload()
|
||||
{
|
||||
Components.classes["@mozilla.org/abmanager;1"]
|
||||
.getService(Components.interfaces.nsIAbManager)
|
||||
.removeAddressBookListener(gAddressBookPanelAbListener);
|
||||
|
||||
parent.removeEventListener("compose-window-close", AbPanelOnComposerClose, true);
|
||||
parent.removeEventListener("compose-window-reopen", AbPanelOnComposerReOpen, true);
|
||||
|
||||
|
@ -179,12 +126,12 @@ function AbPanelUnload()
|
|||
|
||||
function AbPanelNewCard()
|
||||
{
|
||||
goNewCardDialog(abList.selectedItem.getAttribute('id'));
|
||||
goNewCardDialog(abList.value);
|
||||
}
|
||||
|
||||
function AbPanelNewList()
|
||||
{
|
||||
goNewListDialog(abList.selectedItem.getAttribute('id'));
|
||||
goNewListDialog(abList.value);
|
||||
}
|
||||
|
||||
function ResultsPaneSelectionChanged()
|
||||
|
|
|
@ -57,8 +57,6 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="AbPanelLoad();"
|
||||
onunload="AbPanelUnload();"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
selectedaddresses="true">
|
||||
|
||||
<stringbundleset id="stringbundleset">
|
||||
|
@ -88,20 +86,7 @@
|
|||
<menulist id="addressbookList"
|
||||
oncommand="AddressBookMenuListChange();" flex="1"
|
||||
persist="value">
|
||||
<menupopup id="addressbookList-menupopup"
|
||||
datasources="rdf:addressdirectory"
|
||||
ref="moz-abdirectory://"
|
||||
sortActive="true"
|
||||
sortDirection="ascending"
|
||||
sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort">
|
||||
<template>
|
||||
<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>
|
||||
<menupopup id="addressbookList-menupopup" class="addrbooksPopup"/>
|
||||
</menulist>
|
||||
</hbox>
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/addressbook/abMailListDialog.dtd">
|
||||
|
||||
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
id="ablistWindow"
|
||||
title="&mailListWindow.title;"
|
||||
onload="OnLoadEditList();"
|
||||
|
|
|
@ -42,8 +42,6 @@
|
|||
<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/addressbook/abMailListDialog.dtd">
|
||||
|
||||
<dialog 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#"
|
||||
id="ablistWindow"
|
||||
title="&mailListWindow.title;"
|
||||
ondialogaccept="return MailListOKButton();"
|
||||
|
@ -63,21 +61,8 @@
|
|||
<hbox align="center">
|
||||
<label control="abPopup" value="&addToAddressBook.label;" accesskey="&addToAddressBook.accesskey;"/>
|
||||
<menulist id="abPopup">
|
||||
<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:SupportsMailingLists="true">
|
||||
<menuitem uri="..."
|
||||
label="rdf:http://home.netscape.com/NC-rdf#DirName"
|
||||
value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
|
||||
</rule>
|
||||
</template>
|
||||
</menupopup>
|
||||
<menupopup id="abPopup-menupopup" class="addrbooksPopup" writeable="true"
|
||||
supportsmaillists="true"/>
|
||||
</menulist>
|
||||
</hbox>
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ messenger.jar:
|
|||
* 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)
|
||||
|
|
|
@ -375,7 +375,7 @@ function NewCardOKButton()
|
|||
var popup = document.getElementById('abPopup');
|
||||
if ( popup )
|
||||
{
|
||||
var uri = popup.getAttribute('value');
|
||||
var uri = popup.value;
|
||||
|
||||
// FIX ME - hack to avoid crashing if no ab selected because of blank option bug from template
|
||||
// should be able to just remove this if we are not seeing blank lines in the ab popup
|
||||
|
|
|
@ -622,7 +622,7 @@ function DirPaneHasFocus()
|
|||
function GetSelectedDirectory()
|
||||
{
|
||||
if (abList)
|
||||
return abList.selectedItem.id;
|
||||
return abList.value;
|
||||
else {
|
||||
if (dirTree.currentIndex < 0)
|
||||
return null;
|
||||
|
|
|
@ -43,8 +43,6 @@
|
|||
<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/addressbook/abMailListDialog.dtd">
|
||||
|
||||
<dialog 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#"
|
||||
id="ablistWindow"
|
||||
title="&mailListWindow.title;"
|
||||
ondialogaccept="return MailListOKButton();"
|
||||
|
@ -57,21 +55,8 @@
|
|||
<hbox align="center" valign="center">
|
||||
<label control="abPopup" value="&addToAddressBook.label;" accesskey="&addToAddressBook.accesskey;"/>
|
||||
<menulist id="abPopup">
|
||||
<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:SupportsMailingLists="true">
|
||||
<menuitem uri="..."
|
||||
label="rdf:http://home.netscape.com/NC-rdf#DirName"
|
||||
value="rdf:http://home.netscape.com/NC-rdf#DirUri"/>
|
||||
</rule>
|
||||
</template>
|
||||
</menupopup>
|
||||
<menupopup id="abPopup-menupopup" class="addrbooksPopup" writeable="true"
|
||||
supportsmaillists="true"/>
|
||||
</menulist>
|
||||
</hbox>
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@
|
|||
<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/addressbook/abNewCardDialog.dtd">
|
||||
|
||||
<dialog 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#"
|
||||
id="abcardWindow"
|
||||
onload="OnLoadNewCard()"
|
||||
ondialogaccept="return NewCardOKButton();">
|
||||
|
@ -56,21 +54,7 @@
|
|||
<label id="abPopupLabel" control="abPopup" value="&chooseAddressBook.label;" accesskey="&chooseAddressBook.accesskey;"/>
|
||||
|
||||
<menulist id="abPopup">
|
||||
<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>
|
||||
<menupopup id="abPopup-menupopup" class="addrbooksPopup" writeable="true"/>
|
||||
</menulist>
|
||||
|
||||
</hbox>
|
||||
|
|
|
@ -116,7 +116,15 @@ function OnLoadSelectAddress()
|
|||
gSearchInput = document.getElementById("searchInput");
|
||||
SearchInputChanged();
|
||||
|
||||
SelectFirstAddressBookMenulist();
|
||||
// Reselect the persisted address book if possible, if not just select the
|
||||
// first in the list.
|
||||
var temp = abPopup.value;
|
||||
abPopup.selectedItem = null;
|
||||
abPopup.value = temp;
|
||||
if (!abPopup.selectedItem)
|
||||
abPopup.selectedIndex = 0;
|
||||
|
||||
ChangeDirectoryByURI(abList.value);
|
||||
|
||||
DialogBucketPaneSelectionChanged();
|
||||
|
||||
|
@ -397,7 +405,7 @@ function onEnterInSearchBar()
|
|||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
}
|
||||
|
||||
var searchURI = selectedNode.getAttribute("id");
|
||||
var searchURI = selectedNode.value;
|
||||
|
||||
if (gSearchInput.value != "") {
|
||||
searchURI += gQueryURIFormat.replace(/@V/g, encodeURIComponent(gSearchInput.value));
|
||||
|
@ -408,19 +416,13 @@ function onEnterInSearchBar()
|
|||
SelectFirstCard();
|
||||
}
|
||||
|
||||
function SelectFirstAddressBookMenulist()
|
||||
{
|
||||
ChangeDirectoryByURI(abList.selectedItem.id);
|
||||
return;
|
||||
}
|
||||
|
||||
function DirPaneSelectionChangeMenulist()
|
||||
{
|
||||
if (abList && abList.selectedItem) {
|
||||
if (gSearchInput.value && (gSearchInput.value != ""))
|
||||
onEnterInSearchBar();
|
||||
else
|
||||
ChangeDirectoryByURI(abList.selectedItem.id);
|
||||
ChangeDirectoryByURI(abList.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,7 @@
|
|||
]>
|
||||
|
||||
<window id="selectAddressesWindow"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
title="&selectAddressWindow.title;"
|
||||
class="dialog"
|
||||
style="width: 50em; height: 35em;"
|
||||
|
@ -79,22 +77,8 @@
|
|||
<hbox id="topBox" align="center">
|
||||
<label value="&lookIn.label;" accesskey="&lookIn.accesskey;" control="addressbookList"/>
|
||||
<menulist id="addressbookList"
|
||||
ref="moz-abdirectory://"
|
||||
datasources="rdf:addressdirectory"
|
||||
containment="http://home.netscape.com/NC-rdf#child"
|
||||
sortActive="true"
|
||||
sortDirection="ascending"
|
||||
sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort"
|
||||
oncommand="DirPaneSelectionChangeMenulist(); document.commandDispatcher.updateCommands('addrbook-select');">
|
||||
<template>
|
||||
<rule nc:IsMailList="false">
|
||||
<menupopup>
|
||||
<menuitem label="rdf:http://home.netscape.com/NC-rdf#DirName" uri="..."
|
||||
IsMailList="rdf:http://home.netscape.com/NC-rdf#IsMailList"
|
||||
IsRemote="rdf:http://home.netscape.com/NC-rdf#IsRemote"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup id="addressbookList-menupopup" class="addrbooksPopup"/>
|
||||
</menulist>
|
||||
<label value="&for.label;" accesskey="&for.accesskey;" control="searchInput"/>
|
||||
<textbox id="searchInput" flex="1"
|
||||
|
|
|
@ -0,0 +1,211 @@
|
|||
<?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 Address Book code
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mozilla Messaging
|
||||
Portions created by the Initial Developer are Copyright (C) 2008
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark Banner <bugzilla@standard8.plus.com>
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms of
|
||||
either of 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 ***** -->
|
||||
|
||||
<bindings id="addrbookBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
<binding id="addrbooks-menupopup"
|
||||
extends="chrome://global/content/bindings/popup.xml#popup">
|
||||
<implementation implements="nsIAbListener">
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this._build();
|
||||
|
||||
const nsIAbListener = Components.interfaces.nsIAbListener;
|
||||
// Add a listener so we can update correctly if the list should change
|
||||
Components.classes["@mozilla.org/abmanager;1"]
|
||||
.getService(Components.interfaces.nsIAbManager)
|
||||
.addAddressBookListener(this,
|
||||
nsIAbListener.itemAdded |
|
||||
nsIAbListener.directoryRemoved |
|
||||
nsIAbListener.itemChanged);
|
||||
]]>
|
||||
</constructor>
|
||||
<destructor>
|
||||
<![CDATA[
|
||||
Components.classes["@mozilla.org/abmanager;1"]
|
||||
.getService(Components.interfaces.nsIAbManager)
|
||||
.removeAddressBookListener(this);
|
||||
|
||||
this._teardown();
|
||||
]]>
|
||||
</destructor>
|
||||
|
||||
<!-- nsIAbListener methods -->
|
||||
<method name="onItemAdded">
|
||||
<parameter name="aParentDir"/>
|
||||
<parameter name="aItem"/>
|
||||
<body><![CDATA[
|
||||
if (aItem instanceof Components.interfaces.nsIAbDirectory) {
|
||||
// Save the currently selected item
|
||||
var selectedItem = this.parentNode.value;
|
||||
this.parentNode.value = null;
|
||||
|
||||
// Re-use _teardown and _build so that we can use its sort function
|
||||
this._teardown();
|
||||
this._build();
|
||||
|
||||
// Now reset the value of the parent to re-connect it with the
|
||||
// appropriate DOM Node.
|
||||
this.parentNode.value = selectedItem;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="onItemRemoved">
|
||||
<parameter name="aParentDir"/>
|
||||
<parameter name="aItem"/>
|
||||
<body><![CDATA[
|
||||
if (aItem instanceof Components.interfaces.nsIAbDirectory) {
|
||||
// Find the item in the list to remove
|
||||
var nodes = this.getElementsByAttribute("value", aItem.URI);
|
||||
|
||||
// We should only ever have at most one node with the URI.
|
||||
if (nodes.length > 0)
|
||||
this.removeChild(nodes[0]);
|
||||
|
||||
// Update the parent item
|
||||
if (this.parentNode.value == aItem.URI) {
|
||||
this.firstChild.doCommand();
|
||||
}
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="onItemPropertyChanged">
|
||||
<parameter name="aItem"/>
|
||||
<parameter name="aProperty"/>
|
||||
<parameter name="aOldValue"/>
|
||||
<parameter name="aNewValue"/>
|
||||
<body><![CDATA[
|
||||
if (aItem instanceof Components.interfaces.nsIAbDirectory) {
|
||||
// Find the item in the list to rename.
|
||||
var nodes = this.getElementsByAttribute("value", aItem.URI);
|
||||
|
||||
// We should only ever have at most one node with the URI.
|
||||
if (nodes.length > 0)
|
||||
nodes[0].label = aItem.dirName;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
// Private methods
|
||||
<method name="_teardown">
|
||||
<body><![CDATA[
|
||||
// Empty out anything in the list.
|
||||
while (this.hasChildNodes())
|
||||
this.removeChild(this.lastChild);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="_build">
|
||||
<body><![CDATA[
|
||||
// Init the address book list.
|
||||
var addressBooks = Components.classes["@mozilla.org/abmanager;1"]
|
||||
.getService(Components.interfaces.nsIAbManager)
|
||||
.directories;
|
||||
var holdingArray = [];
|
||||
|
||||
var remoteOnly = this.getAttribute("remoteonly");
|
||||
var localOnly = this.getAttribute("localonly");
|
||||
var writeable = this.getAttribute("writeable");
|
||||
var sml = this.getAttribute("supportsmaillists");
|
||||
|
||||
const nsIAbDirectory = Components.interfaces.nsIAbDirectory;
|
||||
|
||||
while (addressBooks && addressBooks.hasMoreElements()) {
|
||||
var ab = addressBooks.getNext();
|
||||
if (ab instanceof nsIAbDirectory &&
|
||||
(!remoteOnly || ab.isRemote) &&
|
||||
(!localOnly || !ab.isRemote) &&
|
||||
(!sml || ab.supportsMailingLists) &&
|
||||
(!writeable || (ab.operations & nsIAbDirectory.opWrite) ==
|
||||
nsIAbDirectory.opWrite))
|
||||
holdingArray.push(ab);
|
||||
}
|
||||
|
||||
const kPersonalAddressbookURI = "moz-abmdbdirectory://abook.mab";
|
||||
const kCollectedAddressbookURI = "moz-abmdbdirectory://history.mab";
|
||||
|
||||
holdingArray.sort(function (a, b) {
|
||||
// Personal at the top.
|
||||
if (a.URI == kPersonalAddressbookURI)
|
||||
return -1;
|
||||
|
||||
if (b.URI == kPersonalAddressbookURI)
|
||||
return 1;
|
||||
|
||||
// Collected at the bottom.
|
||||
if (a.URI == kCollectedAddressbookURI)
|
||||
return 1;
|
||||
|
||||
if (b.URI == kCollectedAddressbookURI)
|
||||
return -1;
|
||||
|
||||
// Sort books of the same type by name.
|
||||
if (a.dirType == b.dirType)
|
||||
return a.dirName.localeCompare(b.dirName);
|
||||
|
||||
// If one of the dirTypes is 2 and the other is something else,
|
||||
// then the other will go below the one of type 2.
|
||||
if (a.dirType == 2)
|
||||
return -1;
|
||||
|
||||
if (b.dirType == 2)
|
||||
return 1;
|
||||
|
||||
// Sort anything else by the dir type.
|
||||
return a.dirType - b.dirType;
|
||||
});
|
||||
|
||||
var menupopup = this;
|
||||
|
||||
holdingArray.forEach(function (ab) {
|
||||
var item = document.createElement('menuitem');
|
||||
item.setAttribute("label", ab.dirName);
|
||||
item.setAttribute("value", ab.URI);
|
||||
|
||||
menupopup.appendChild(item);
|
||||
});
|
||||
]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
|
@ -42,69 +42,23 @@ function GetAbViewListener()
|
|||
return null;
|
||||
}
|
||||
|
||||
var gAddressBookPanelAbListener = {
|
||||
onItemAdded: function(parentDir, item) {
|
||||
// will not be called
|
||||
},
|
||||
onItemRemoved: function(parentDir, item) {
|
||||
// will only be called when an addressbook is deleted
|
||||
try {
|
||||
var directory = item.QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
// check if the item being removed is the directory
|
||||
// that we are showing in the addressbook sidebar
|
||||
// if so, select the person addressbook (it can't be removed)
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
if (directory.URI == abPopup.value) {
|
||||
abPopup.value = kPersonalAddressbookURI;
|
||||
LoadPreviouslySelectedAB();
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
},
|
||||
onItemPropertyChanged: function(item, property, oldValue, newValue) {
|
||||
try {
|
||||
var directory = item.QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
// check if the item being changed is the directory
|
||||
// that we are showing in the addressbook sidebar
|
||||
if (directory == GetAbView().directory) {
|
||||
LoadPreviouslySelectedAB();
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// XXX todo
|
||||
// can we combine some common code? see OnLoadNewMailList()
|
||||
// set popup with address book names
|
||||
function LoadPreviouslySelectedAB()
|
||||
{
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
var value = abPopup.value || kPersonalAddressbookURI;
|
||||
abPopup.selectedItem = null;
|
||||
abPopup.value = value;
|
||||
ChangeDirectoryByURI(abPopup.selectedItem.id);
|
||||
}
|
||||
|
||||
function AbPanelLoad()
|
||||
{
|
||||
InitCommonJS();
|
||||
|
||||
UpgradeAddressBookResultsPaneUI("mailnews.ui.addressbook_panel_results.version");
|
||||
|
||||
LoadPreviouslySelectedAB();
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
|
||||
// Add a listener, so we can switch directories if the current directory is
|
||||
// deleted, and change the name if the selected directory's name is modified.
|
||||
// This listener only cares when a directory is removed or modified.
|
||||
Components.classes["@mozilla.org/abmanager;1"]
|
||||
.getService(Components.interfaces.nsIAbManager)
|
||||
.addAddressBookListener(gAddressBookPanelAbListener,
|
||||
nsIAbListener.directoryRemoved |
|
||||
nsIAbListener.itemChanged);
|
||||
// Reselect the persisted address book if possible, if not just select the
|
||||
// first in the list.
|
||||
var temp = abPopup.value;
|
||||
abPopup.selectedItem = null;
|
||||
abPopup.value = temp;
|
||||
if (!abPopup.selectedItem)
|
||||
abPopup.selectedIndex = 0;
|
||||
|
||||
ChangeDirectoryByURI(abPopup.value);
|
||||
|
||||
gSearchInput = document.getElementById("searchInput");
|
||||
|
||||
|
@ -125,10 +79,6 @@ function AbPanelUnload()
|
|||
if (gMsgCompose)
|
||||
parent.removeEventListener("compose-window-close", onAbClearSearch, true);
|
||||
|
||||
Components.classes["@mozilla.org/abmanager;1"]
|
||||
.getService(Components.interfaces.nsIAbManager)
|
||||
.removeAddressBookListener(gAddressBookPanelAbListener);
|
||||
|
||||
CloseAbView();
|
||||
}
|
||||
|
||||
|
@ -151,12 +101,12 @@ function AbPanelAdd(addrtype)
|
|||
|
||||
function AbPanelNewCard()
|
||||
{
|
||||
goNewCardDialog(abList.selectedItem.getAttribute('id'));
|
||||
goNewCardDialog(abList.value);
|
||||
}
|
||||
|
||||
function AbPanelNewList()
|
||||
{
|
||||
goNewListDialog(abList.selectedItem.getAttribute('id'));
|
||||
goNewListDialog(abList.value);
|
||||
}
|
||||
|
||||
function ResultsPaneSelectionChanged()
|
||||
|
|
|
@ -55,8 +55,6 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="AbPanelLoad();"
|
||||
onunload="AbPanelUnload();"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
title="&selectAddressWindow.title;"
|
||||
selectedaddresses="true">
|
||||
|
||||
|
@ -95,20 +93,7 @@
|
|||
<menulist id="addressbookList"
|
||||
oncommand="DirPaneSelectionChangeMenulist();" flex="1"
|
||||
persist="value">
|
||||
<menupopup id="addressbookList-menupopup"
|
||||
datasources="rdf:addressdirectory"
|
||||
ref="moz-abdirectory://"
|
||||
sortActive="true"
|
||||
sortDirection="ascending"
|
||||
sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort">
|
||||
<template>
|
||||
<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>
|
||||
<menupopup id="addressbookList-menupopup" class="addrbooksPopup"/>
|
||||
</menulist>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
|
|
|
@ -91,6 +91,10 @@ menupopup[type="folder"] {
|
|||
-moz-binding: url("chrome://messenger/content/folderWidgets.xml#folder-menupopup");
|
||||
}
|
||||
|
||||
.addrbooksPopup {
|
||||
-moz-binding: url("chrome://messenger/content/addressbook/addrbookWidgets.xml#addrbooks-menupopup");
|
||||
}
|
||||
|
||||
searchattribute {
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#searchattribute");
|
||||
}
|
||||
|
|
|
@ -98,6 +98,9 @@ function searchOnLoad()
|
|||
|
||||
if (window.arguments && window.arguments[0])
|
||||
SelectDirectory(window.arguments[0].directory);
|
||||
else
|
||||
SelectDirectory(document.getElementById("abPopup-menupopup")
|
||||
.firstChild.value);
|
||||
|
||||
// initialize globals, see abCommon.js, InitCommonJS()
|
||||
abList = document.getElementById("abPopup");
|
||||
|
@ -363,11 +366,3 @@ function UpdateCardView()
|
|||
else
|
||||
gPropertiesButton.setAttribute("disabled","true");
|
||||
}
|
||||
|
||||
function onChooseDirectory(event)
|
||||
{
|
||||
var directoryURI = event.id;
|
||||
if (directoryURI) {
|
||||
SelectDirectory(directoryURI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,21 +89,8 @@
|
|||
<vbox>
|
||||
<hbox align="center">
|
||||
<label value="&abSearchHeading.label;" accesskey="&abSearchHeading.accesskey;" control="abPopup"/>
|
||||
<menulist id="abPopup">
|
||||
<menupopup id="abPopup-menupopup" ref="moz-abdirectory://"
|
||||
datasources="rdf:addressdirectory"
|
||||
sortActive="true"
|
||||
sortDirection="ascending"
|
||||
sortResource="http://home.netscape.com/NC-rdf#DirTreeNameSort"
|
||||
oncommand="onChooseDirectory(event.target);">
|
||||
<template>
|
||||
<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 id="abPopup" oncommand="SelectDirectory(this.value);">
|
||||
<menupopup id="abPopup-menupopup" class="addrbooksPopup"/>
|
||||
</menulist>
|
||||
<spacer flex="10"/>
|
||||
<button id="search-button" oncommand="onSearchButton(event);" default="true"/>
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
version="8"
|
||||
version="9"
|
||||
logging="yes"
|
||||
name="SpamAssassinYes"
|
||||
enabled="yes"
|
||||
type="1"
|
||||
type="17"
|
||||
action="JunkScore"
|
||||
actionValue="100"
|
||||
condition="OR (\"X-Spam-Status\",begins with,Yes) OR (\"X-Spam-Flag\",begins with,YES) OR (subject,begins with,***SPAM***)"
|
||||
condition="OR (\"x-spam-status\",begins with,Yes) OR (\"x-spam-flag\",begins with,YES) OR (subject,begins with,***SPAM***)"
|
||||
name="SpamAssassinNo"
|
||||
enabled="yes"
|
||||
type="1"
|
||||
type="17"
|
||||
action="JunkScore"
|
||||
actionValue="0"
|
||||
condition="OR (\"X-Spam-Status\",begins with,No)"
|
||||
condition="OR (\"x-spam-status\",begins with,No)"
|
||||
|
|
|
@ -38,6 +38,7 @@ messenger.jar:
|
|||
content/messenger/addressbook/abResultsPane.js (addrbook/resources/content/abResultsPane.js)
|
||||
content/messenger/addressbook/abSelectAddressesDialog.js (addrbook/resources/content/abSelectAddressesDialog.js)
|
||||
content/messenger/addressbook/abSelectAddressesDialog.xul (addrbook/resources/content/abSelectAddressesDialog.xul)
|
||||
content/messenger/addressbook/addrbookWidgets.xml (addrbook/resources/content/addrbookWidgets.xml)
|
||||
content/messenger/addressbook/addressbook.js (addrbook/resources/content/addressbook.js)
|
||||
content/messenger/addressbook/addressbook.xul (addrbook/resources/content/addressbook.xul)
|
||||
content/messenger/addressbook/abDragDrop.js (addrbook/resources/content/abDragDrop.js)
|
||||
|
|
Загрузка…
Ссылка в новой задаче