Bug 336491 Clean up abCommon.js. r/sr=bienvenu

This commit is contained in:
bugzilla%standard8.demon.co.uk 2006-05-04 18:28:07 +00:00
Родитель 00f6fe6ef1
Коммит b771bdd2cd
5 изменённых файлов: 46 добавлений и 66 удалений

Просмотреть файл

@ -43,6 +43,7 @@ var dirTree = 0;
var abList = 0;
var gAbResultsTree = null;
var gAbView = null;
var gCurDirectory;
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);
@ -264,8 +265,7 @@ function AbEditSelectedDirectory()
goEditListDialog(dirUri, null, selecteduri, UpdateCardView);
}
else {
var properties = directory.directoryProperties;
if (properties.dirType == kLDAPDirectory) {
if (directory instanceof Components.interfaces.nsIAbLDAPDirectory) {
var ldapUrlPrefix = "moz-abldapdirectory://";
var args = { selectedDirectory: directory.dirName,
selectedDirectoryString: null};
@ -340,6 +340,9 @@ function GetSelectedCardTypes()
}
else if (!mailingListCnt && cardCnt)
return kCardsOnly; // only card(s) selected
// Fallback just in case.
return kNothingSelected;
}
function AbDelete()
@ -366,7 +369,7 @@ function AbDelete()
gAbView.deleteSelectedCards();
}
function AbNewCard(abListItem)
function AbNewCard()
{
goNewCardDialog(GetSelectedDirectory());
}
@ -485,8 +488,7 @@ function GetSelectedAddressesFromDirTree()
if (dirTree.currentIndex >= 0) {
var selectedResource = dirTree.builderView.getResourceAtIndex(dirTree.currentIndex);
var mailingListUri = selectedResource.Value;
var directory = GetDirectoryFromURI(mailingListUri);
var directory = GetDirectoryFromURI(selectedResource.Value);
if (directory.isMailList) {
var listCardsCount = directory.addressLists.Count();
var cards = new Array(listCardsCount);
@ -501,8 +503,7 @@ function GetSelectedAddressesFromDirTree()
function GetSelectedAddresses()
{
var selectedCards = GetSelectedAbCards();
return GetAddressesForCards(selectedCards);
return GetAddressesForCards(GetSelectedAbCards());
}
// Generate a comma separated list of addresses from a given
@ -530,8 +531,7 @@ function GetAddressesForCards(cards)
function GetNumSelectedCards()
{
try {
var treeSelection = gAbView.selection;
return treeSelection.count;
return gAbView.selection.count;
}
catch (ex) {
}
@ -607,9 +607,9 @@ function SelectFirstAddressBook()
{
dirTree.view.selection.select(0);
ChangeDirectoryByURI(GetSelectedDirectory());
gAbResultsTree.focus();
}
ChangeDirectoryByURI(GetSelectedDirectory());
gAbResultsTree.focus();
}
function SelectFirstCard()
{
@ -682,10 +682,10 @@ function SetAbView(uri, searchView, sortColumn, sortDirection)
// make sure sortColumn and sortDirection have non null values before calling gAbView.init
if (!sortColumn)
sortColumn = kDefaultSortColumn;
sortColumn = kDefaultSortColumn;
if (!sortDirection)
sortDirection = kDefaultAscending;
if (!sortDirection)
sortDirection = kDefaultAscending;
if (gAbView && gCurDirectory == GetSelectedDirectory())
{
@ -694,12 +694,12 @@ function SetAbView(uri, searchView, sortColumn, sortDirection)
}
else
{
CloseAbView();
CloseAbView();
gCurDirectory = GetSelectedDirectory();
gAbView = Components.classes["@mozilla.org/addressbook/abview;1"].createInstance(Components.interfaces.nsIAbView);
gCurDirectory = GetSelectedDirectory();
gAbView = Components.classes["@mozilla.org/addressbook/abview;1"].createInstance(Components.interfaces.nsIAbView);
actualSortColumn = gAbView.init(uri, searchView, GetAbViewListener(), sortColumn, sortDirection);
actualSortColumn = gAbView.init(uri, searchView, GetAbViewListener(), sortColumn, sortDirection);
}
var boxObject = GetAbResultsBoxObject();
@ -715,19 +715,12 @@ 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()
{
return gAbView && gAbView.URI;
}
function ChangeDirectoryByURI(uri)
{
if (!uri)
uri = kPersonalAddressbookURI;
if (gAbView && GetAbViewURI() == uri)
if (gAbView && gAbView.URI == uri)
return;
var sortColumn = gAbResultsTree.getAttribute("sortCol");
@ -811,7 +804,7 @@ function InvalidateResultsPane()
gAbResultsTree.treeBoxObject.invalidate();
}
function AbNewList(abListItem)
function AbNewList()
{
goNewListDialog(GetSelectedDirectory());
}
@ -899,8 +892,7 @@ function GenerateAddressFromCard(card)
function GetDirectoryFromURI(uri)
{
var directory = rdf.GetResource(uri).QueryInterface(Components.interfaces.nsIAbDirectory);
return directory;
return rdf.GetResource(uri).QueryInterface(Components.interfaces.nsIAbDirectory);
}
// returns null if abURI is not a mailing list URI

Просмотреть файл

@ -135,10 +135,10 @@
<!-- File Menu -->
#ifdef XP_MACOSX
<key id="key_newMessage" key="&newMessageCmd.key;" modifiers="accel,shift" oncommand="AbNewMessage()"/>
<key id="key_newCard" key="&newCard.key;" modifiers="accel,shift" oncommand="AbNewCard('dirTree')"/>
<key id="key_newCard" key="&newCard.key;" modifiers="accel,shift" oncommand="AbNewCard();"/>
#else
<key id="key_newMessage" key="&newMessageCmd.key;" modifiers="accel" oncommand="AbNewMessage()"/>
<key id="key_newCard" key="&newCard.key;" modifiers="accel" oncommand="AbNewCard('dirTree')"/>
<key id="key_newCard" key="&newCard.key;" modifiers="accel" oncommand="AbNewCard();"/>
#endif
<key id="key_printCard" key="&printCardViewCmd.key;" command="cmd_printcard" modifiers="accel"/>
@ -185,11 +185,11 @@
<menuitem id="dirTreeContext-newcard"
label="&newcardButton.label;"
accesskey="&newcardButton.accesskey;"
oncommand="AbNewCard('dirTree')"/>
oncommand="AbNewCard();"/>
<menuitem id="dirTreeContext-newlist"
label="&newlistButton.label;"
accesskey="&newlistButton.accesskey;"
oncommand="AbNewList('dirTree')"/>
oncommand="AbNewList();"/>
<menuseparator/>
<menuitem id="dirTreeContext-delete"
label="&deleteButton.label;"
@ -242,8 +242,8 @@
<menupopup id="menu_FilePopup" onpopupshowing="onFileMenuInit();">
<menu id="menu_New" label="&newMenu.label;" accesskey="&newMenu.accesskey;">
<menupopup id="menu_NewPopup">
<menuitem label="&newCard.label;" accesskey="&newCard.accesskey;" key="key_newCard" oncommand="AbNewCard('dirTree')"/>
<menuitem label="&newListCmd.label;" accesskey="&newListCmd.accesskey;" oncommand="AbNewList('dirTree')"/>
<menuitem label="&newCard.label;" accesskey="&newCard.accesskey;" key="key_newCard" oncommand="AbNewCard();"/>
<menuitem label="&newListCmd.label;" accesskey="&newListCmd.accesskey;" oncommand="AbNewList();"/>
<menuitem label="&newAddressBookCmd.label;" accesskey="&newAddressBookCmd.accesskey;" oncommand="AbNewAddressBook()"/>
<menuitem label="&newLDAPDirectoryCmd.label;" id="addLDAP" accesskey="&newLDAPDirectoryCmd.accesskey;" oncommand="AbNewLDAPDirectory()"/>
<menuseparator/>
@ -518,8 +518,8 @@
</toolbar>
<toolbarpalette id="AddressBookToolbarPalette">
<toolbarbutton class="toolbarbutton-1" id="button-newcard" label="&newcardButton.label;" tooltiptext="&newcardButton.tooltip;" oncommand="AbNewCard('dirTree');"/>
<toolbarbutton class="toolbarbutton-1" id="button-newlist" label="&newlistButton.label;" tooltiptext="&newlistButton.tooltip;" oncommand="AbNewList('dirTree');"/>
<toolbarbutton class="toolbarbutton-1" id="button-newcard" label="&newcardButton.label;" tooltiptext="&newcardButton.tooltip;" oncommand="AbNewCard();"/>
<toolbarbutton class="toolbarbutton-1" id="button-newlist" label="&newlistButton.label;" tooltiptext="&newlistButton.tooltip;" oncommand="AbNewList();"/>
<toolbarbutton class="toolbarbutton-1" id="button-editcard" label="&editButton.label;" tooltiptext="&editButton.tooltip;" oncommand="goDoCommand('button_edit');"/>
<toolbarbutton class="toolbarbutton-1" id="button-newmessage" label="&newmsgButton.label;" tooltiptext="&newmsgButton.tooltip;" oncommand="AbNewMessage();"/>
<toolbarbutton class="toolbarbutton-1" id="button-newim" label="&newIM.label;" tooltiptext="&newIM.tooltip;" oncommand="AbIMSelected();"/>

Просмотреть файл

@ -259,8 +259,7 @@ function AbEditSelectedDirectory()
goEditListDialog(dirUri, null, selecteduri, UpdateCardView);
}
else {
var properties = directory.directoryProperties;
if (properties.dirType == kLDAPDirectory) {
if (directory instanceof Components.interfaces.nsIAbLDAPDirectory) {
var args = { selectedDirectory: directory.dirName,
selectedDirectoryString: null};
args.selectedDirectoryString = selecteduri.substr(kLdapUrlPrefix.length);
@ -348,7 +347,7 @@ function AbDelete()
gAbView.deleteSelectedCards();
}
function AbNewCard(abListItem)
function AbNewCard()
{
goNewCardDialog(GetSelectedDirectory());
}
@ -481,8 +480,7 @@ function GetSelectedAddressesFromDirTree()
if (dirTree.currentIndex >= 0) {
var selectedResource = dirTree.builderView.getResourceAtIndex(dirTree.currentIndex);
var mailingListUri = selectedResource.Value;
var directory = GetDirectoryFromURI(mailingListUri);
var directory = GetDirectoryFromURI(selectedResource.Value);
if (directory.isMailList) {
var listCardsCount = directory.addressLists.Count();
var cards = new Array(listCardsCount);
@ -498,8 +496,7 @@ function GetSelectedAddressesFromDirTree()
function GetSelectedAddresses()
{
var selectedCards = GetSelectedAbCards();
return GetAddressesForCards(selectedCards);
return GetAddressesForCards(GetSelectedAbCards());
}
// Generate a comma separated list of addresses from a given
@ -528,8 +525,7 @@ function GetAddressesForCards(cards)
function GetNumSelectedCards()
{
try {
var treeSelection = gAbView.selection;
return treeSelection.count;
return gAbView.selection.count;
}
catch (ex) {
}
@ -603,9 +599,9 @@ function SelectFirstAddressBook()
{
dirTree.view.selection.select(0);
ChangeDirectoryByURI(GetSelectedDirectory());
gAbResultsTree.focus();
}
ChangeDirectoryByURI(GetSelectedDirectory());
gAbResultsTree.focus();
}
function SelectFirstCard()
{
@ -715,19 +711,12 @@ 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()
{
return gAbView && gAbView.URI;
}
function ChangeDirectoryByURI(uri)
{
if (!uri)
uri = kPersonalAddressbookURI;
if (gAbView && GetAbViewURI() == uri)
if (gAbView && gAbView.URI == uri)
return;
SetAbView(uri, false);
@ -800,7 +789,7 @@ function InvalidateResultsPane()
gAbResultsTree.treeBoxObject.invalidate();
}
function AbNewList(abListItem)
function AbNewList()
{
goNewListDialog(GetSelectedDirectory());
}
@ -886,8 +875,7 @@ function GenerateAddressFromCard(card)
function GetDirectoryFromURI(uri)
{
var directory = rdf.GetResource(uri).QueryInterface(Components.interfaces.nsIAbDirectory);
return directory;
return rdf.GetResource(uri).QueryInterface(Components.interfaces.nsIAbDirectory);
}
// returns null if abURI is not a mailing list URI

Просмотреть файл

@ -142,7 +142,7 @@
</hbox>
<hbox id="newEditButtonBox">
<button id="new" label="&newButton.label;" accesskey="&newButton.accesskey;" tooltiptext="&addressPickerNewButton.tooltip;" oncommand="AbNewCard('dirTree')"/>
<button id="new" label="&newButton.label;" accesskey="&newButton.accesskey;" tooltiptext="&addressPickerNewButton.tooltip;" oncommand="AbNewCard();"/>
<button id="edit" label="&editButton.label;" accesskey="&editButton.accesskey;" tooltiptext="&addressPickerEditButton.tooltip;" oncommand="AbEditSelectedCard()"/>
</hbox>

Просмотреть файл

@ -93,8 +93,8 @@
<commandset id="globalEditMenuItems"/>
<command id="cmd_newNavigator"/>
<command id="cmd_newEditor"/>
<command id="cmd_newcard" oncommand="AbNewCard('dirTree')"/>
<command id="cmd_newlist" oncommand="AbNewList('dirTree')"/>
<command id="cmd_newcard" oncommand="AbNewCard();"/>
<command id="cmd_newlist" oncommand="AbNewList();"/>
<command id="cmd_newmessage" oncommand="AbNewMessage()"/>
<command id="cmd_newim" oncommand="AbIMSelected()"/>
<command id="cmd_printSetup" oncommand="NSPrintSetup()"/>
@ -206,8 +206,8 @@
<menupopup id="menu_FilePopup">
<menu id="menu_New">
<menupopup id="menu_NewPopup">
<menuitem label="&newCard.label;" accesskey="&newCard.accesskey;" oncommand="AbNewCard('dirTree')"/>
<menuitem label="&newListCmd.label;" accesskey="&newListCmd.accesskey;" oncommand="AbNewList('dirTree')"/>
<menuitem label="&newCard.label;" accesskey="&newCard.accesskey;" oncommand="AbNewCard();"/>
<menuitem label="&newListCmd.label;" accesskey="&newListCmd.accesskey;" oncommand="AbNewList();"/>
<menuitem label="&newAddressBookCmd.label;" accesskey="&newAddressBookCmd.accesskey;" oncommand="AbNewAddressBook()"/>
<menuitem label="&newLDAPDirectoryCmd.label;" id="addLDAP" accesskey="&newLDAPDirectoryCmd.accesskey;" oncommand="AbNewLDAPDirectory()"/>
<menuseparator/>