Bug 1310442 - Make labels of cmd_properties in AB context-sensitive, e.g. "Edit Contact", "Edit List", etc. r=aceman, ui-r=Paenglab
This commit is contained in:
Родитель
f0a99e00ba
Коммит
8653e694ea
|
@ -108,7 +108,27 @@ var DirPaneController =
|
|||
case "cmd_printcardpreview":
|
||||
return (GetSelectedCardIndex() != -1);
|
||||
case "cmd_properties":
|
||||
return (GetSelectedDirectory() != null);
|
||||
let labelAttr = "valueGeneric";
|
||||
let accKeyAttr = "valueGenericAccessKey";
|
||||
let tooltipTextAttr = "valueGenericTooltipText";
|
||||
let isMailList;
|
||||
var selectedDir = GetSelectedDirectory();
|
||||
if (selectedDir) {
|
||||
isMailList = GetDirectoryFromURI(selectedDir).isMailList;
|
||||
labelAttr = isMailList ? "valueMailingList"
|
||||
: "valueAddressBook";
|
||||
accKeyAttr = isMailList ? "valueMailingListAccessKey"
|
||||
: "valueAddressBookAccessKey";
|
||||
tooltipTextAttr = isMailList ? "valueMailingListTooltipText"
|
||||
: "valueAddressBookTooltipText";
|
||||
}
|
||||
goSetLabelAccesskeyTooltiptext("cmd_properties-button", null, null,
|
||||
tooltipTextAttr);
|
||||
goSetLabelAccesskeyTooltiptext("cmd_properties-contextMenu",
|
||||
labelAttr, accKeyAttr);
|
||||
goSetLabelAccesskeyTooltiptext("cmd_properties-menu",
|
||||
labelAttr, accKeyAttr);
|
||||
return (selectedDir != null);
|
||||
case "cmd_newlist":
|
||||
case "cmd_newCard":
|
||||
return true;
|
||||
|
@ -814,3 +834,82 @@ function nearestLeap(aYear) {
|
|||
|
||||
return 2000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label, accesskey, and tooltiptext attributes of an element from
|
||||
* custom attributes of the same element. Typically, the element will be a
|
||||
* command or broadcaster element. JS does not allow omitting function arguments
|
||||
* in the middle of the arguments list, so in that case, please pass an explicit
|
||||
* falsy argument like null or undefined instead; the respective attributes will
|
||||
* not be touched. Empty strings ("") from custom attributes will be applied
|
||||
* correctly. Hacker's shortcut: Passing empty string ("") for any of the custom
|
||||
* attribute names will also set the respective main attribute to empty string ("").
|
||||
* Examples:
|
||||
*
|
||||
* goSetLabelAccesskeyTooltiptext("cmd_foo", "valueFlavor", "valueFlavorAccesskey");
|
||||
* goSetLabelAccesskeyTooltiptext("cmd_foo", "valueFlavor", "valueFlavorAccesskey",
|
||||
* "valueFlavorTooltiptext");
|
||||
* goSetLabelAccesskeyTooltiptext("cmd_foo", null, null, "valueFlavorTooltiptext");
|
||||
* goSetLabelAccesskeyTooltiptext("cmd_foo", "", "", "valueFlavorTooltiptext");
|
||||
*
|
||||
* @param aID the ID of an XUL element (attribute source and target)
|
||||
* @param aLabelAttribute (optional) the name of a custom label attribute of aID, or ""
|
||||
* @param aAccessKeyAttribute (optional) the name of a custom accesskey attribute of aID, or ""
|
||||
* @param aTooltipTextAttribute (optional) the name of a custom tooltiptext attribute of aID, or ""
|
||||
*/
|
||||
function goSetLabelAccesskeyTooltiptext(aID, aLabelAttribute, aAccessKeyAttribute,
|
||||
aTooltipTextAttribute)
|
||||
{
|
||||
let errorMsgIntro = 'Something wrong here: goSetLabelAccesskeyTooltiptext("' +
|
||||
aID + '", ...): ';
|
||||
let node = top.document.getElementById(aID);
|
||||
if (!node) {
|
||||
// tweak for composition's abContactsPanel
|
||||
node = document.getElementById(aID);
|
||||
}
|
||||
if (node) {
|
||||
if (aLabelAttribute) {
|
||||
// In XUL (DOM Level 3), getAttribute() on non-existing attributes returns
|
||||
// "" (instead of null), which is indistinguishable from existing valid
|
||||
// attributes with value="", so we have to check using hasAttribute()
|
||||
if (node.hasAttribute(aLabelAttribute)) {
|
||||
let value = node.getAttribute(aLabelAttribute);
|
||||
node.setAttribute("label", value);
|
||||
} else { // missing custom label attribute
|
||||
let errorMsg = errorMsgIntro +
|
||||
'Missing custom label attribute: ' + aLabelAttribute;
|
||||
dump(errorMsg);
|
||||
}
|
||||
} else if (aLabelAttribute === "") {
|
||||
node.removeAttribute("label");
|
||||
}
|
||||
if (aAccessKeyAttribute) {
|
||||
if (node.hasAttribute(aAccessKeyAttribute)) {
|
||||
let value = node.getAttribute(aAccessKeyAttribute);
|
||||
node.setAttribute("accesskey", value);
|
||||
} else { // missing custom access key attribute
|
||||
let errorMsg = errorMsgIntro +
|
||||
'Missing custom accesskey attribute: ' + aAccessKeyAttribute;
|
||||
dump(errorMsg);
|
||||
}
|
||||
} else if (aAccessKeyAttribute === "") {
|
||||
node.removeAttribute("accesskey");
|
||||
}
|
||||
if (aTooltipTextAttribute) {
|
||||
if (node.hasAttribute(aTooltipTextAttribute)) {
|
||||
let value = node.getAttribute(aTooltipTextAttribute);
|
||||
node.setAttribute("tooltiptext", value);
|
||||
} else { // missing custom tooltiptext attribute
|
||||
let errorMsg = errorMsgIntro +
|
||||
'Missing custom tooltiptext attribute: ' + aTooltipTextAttribute;
|
||||
dump(errorMsg);
|
||||
}
|
||||
} else if (aTooltipTextAttribute === "") {
|
||||
node.removeAttribute("tooltiptext");
|
||||
}
|
||||
} else { // node not found; this is OK sometimes, e.g. for contacts sidebar
|
||||
let errorMsg = errorMsgIntro +
|
||||
'getElementById("' + aID + '") failed!';
|
||||
dump(errorMsg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,26 @@
|
|||
<command id="cmd_delete" oncommand="goDoCommand('cmd_delete');"/>
|
||||
<command id="cmd_properties" oncommand="goDoCommand('cmd_properties');"/>
|
||||
</commandset>
|
||||
<broadcasterset id="cmd_properties-flavors">
|
||||
<broadcaster id="cmd_properties-contextMenu" observes="cmd_properties"
|
||||
valueGeneric="&propertiesContext.label;"
|
||||
valueGenericAccessKey="&propertiesContext.accesskey;"
|
||||
valueAddressBook="&abPropertiesContext.label;"
|
||||
valueAddressBookAccessKey="&abPropertiesContext.accesskey;"
|
||||
valueContact="&editContactContext.label;"
|
||||
valueContactAccessKey="&editContactContext.accesskey;"
|
||||
valueMailingList="&editMailingListContext.label;"
|
||||
valueMailingListAccessKey="&editMailingListContext.accesskey;"/>
|
||||
<broadcaster id="cmd_properties-menu" observes="cmd_properties"
|
||||
valueGeneric="&propertiesMenu.label;"
|
||||
valueGenericAccessKey="&propertiesMenu.accesskey;"
|
||||
valueAddressBook="&abPropertiesMenu.label;"
|
||||
valueAddressBookAccessKey="&abPropertiesMenu.accesskey;"
|
||||
valueContact="&contactPropertiesMenu.label;"
|
||||
valueContactAccessKey="&contactPropertiesMenu.accesskey;"
|
||||
valueMailingList="&mailingListPropertiesMenu.label;"
|
||||
valueMailingListAccessKey="&mailingListPropertiesMenu.accesskey;"/>
|
||||
</broadcasterset>
|
||||
|
||||
<!-- These keys do not really run any command, but they are used to show
|
||||
the hotkeys at the corresponding menuitems -->
|
||||
|
@ -61,10 +81,9 @@
|
|||
key="key_delete"
|
||||
command="cmd_delete"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&addrBookCardProperties.label;"
|
||||
accesskey="&addrBookCardProperties.accesskey;"
|
||||
<menuitem label="&propertiesContext.label;"
|
||||
key="key_properties"
|
||||
command="cmd_properties"/>
|
||||
command="cmd_properties-contextMenu"/>
|
||||
</menupopup>
|
||||
|
||||
<vbox id="results_box" flex="1">
|
||||
|
|
|
@ -83,6 +83,31 @@
|
|||
<command id="cmd_printcardpreview" oncommand="AbPrintPreviewCard();"/>
|
||||
<command id="cmd_printcard" oncommand="AbPrintCard();"/>
|
||||
<command id="cmd_properties" oncommand="goDoCommand('cmd_properties');" disabled="true"/>
|
||||
<broadcasterset id="cmd_properties-flavors">
|
||||
<broadcaster id="cmd_properties-button" observes="cmd_properties"
|
||||
valueGenericTooltipText="&editPropertiesButton.tooltip;"
|
||||
valueAddressBookTooltipText="&editAbPropertiesButton.tooltip;"
|
||||
valueContactTooltipText="&editContactPropertiesButton.tooltip;"
|
||||
valueMailingListTooltipText="&editMailingListPropertiesButton.tooltip;"/>
|
||||
<broadcaster id="cmd_properties-contextMenu" observes="cmd_properties"
|
||||
valueGeneric="&propertiesContext.label;"
|
||||
valueGenericAccessKey="&propertiesContext.accesskey;"
|
||||
valueAddressBook="&abPropertiesContext.label;"
|
||||
valueAddressBookAccessKey="&abPropertiesContext.accesskey;"
|
||||
valueContact="&editContactContext.label;"
|
||||
valueContactAccessKey="&editContactContext.accesskey;"
|
||||
valueMailingList="&editMailingListContext.label;"
|
||||
valueMailingListAccessKey="&editMailingListContext.accesskey;"/>
|
||||
<broadcaster id="cmd_properties-menu" observes="cmd_properties"
|
||||
valueGeneric="&propertiesMenu.label;"
|
||||
valueGenericAccessKey="&propertiesMenu.accesskey;"
|
||||
valueAddressBook="&abPropertiesMenu.label;"
|
||||
valueAddressBookAccessKey="&abPropertiesMenu.accesskey;"
|
||||
valueContact="&contactPropertiesMenu.label;"
|
||||
valueContactAccessKey="&contactPropertiesMenu.accesskey;"
|
||||
valueMailingList="&mailingListPropertiesMenu.label;"
|
||||
valueMailingListAccessKey="&mailingListPropertiesMenu.accesskey;"/>
|
||||
</broadcasterset>
|
||||
<command id="cmd_undo" oncommand="goDoCommand('cmd_undo')" disabled="true"/>
|
||||
<command id="cmd_redo" oncommand="goDoCommand('cmd_redo')" disabled="true"/>
|
||||
<command id="cmd_cut" oncommand="goDoCommand('cmd_cut')" disabled="true"/>
|
||||
|
@ -177,9 +202,7 @@
|
|||
|
||||
<menupopup id="dirTreeContext">
|
||||
<menuitem id="dirTreeContext-properties"
|
||||
label="&editButton2.label;"
|
||||
accesskey="&editButton2.accesskey;"
|
||||
command="cmd_properties"/>
|
||||
command="cmd_properties-contextMenu"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="dirTreeContext-newcard" label="&newContactButton.label;"
|
||||
accesskey="&newContactButton.accesskey;" command="cmd_newCard"/>
|
||||
|
@ -197,9 +220,7 @@
|
|||
|
||||
<menupopup id="abResultsTreeContext">
|
||||
<menuitem id="abResultsTreeContext-properties"
|
||||
label="&editButton2.label;"
|
||||
accesskey="&editButton2.accesskey;"
|
||||
command="cmd_properties"/>
|
||||
command="cmd_properties-contextMenu"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="abResultsTreeContext-newmessage"
|
||||
label="&newmsgButton.label;"
|
||||
|
@ -214,6 +235,7 @@
|
|||
label="&printButton.label;"
|
||||
accesskey="&printButton.accesskey;"
|
||||
command="cmd_printcard"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="abResultsTreeContext-delete"
|
||||
label="&deleteButton2.label;"
|
||||
accesskey="&deleteButton2.accesskey;"
|
||||
|
@ -397,10 +419,8 @@
|
|||
hidden="&hideSwapFnLnUI;"
|
||||
oncommand="AbSwapFirstNameLastName()"/>
|
||||
<menuitem id="menu_properties"
|
||||
label="&propertiesCmd2.label;"
|
||||
accesskey="&propertiesCmd2.accesskey;"
|
||||
key="key_properties"
|
||||
command="cmd_properties"/>
|
||||
command="cmd_properties-menu"/>
|
||||
#ifdef XP_UNIX
|
||||
#ifndef XP_MACOSX
|
||||
<menuseparator id="prefSep"/>
|
||||
|
@ -590,9 +610,8 @@
|
|||
tooltiptext="&newContactButton.tooltip;"/>
|
||||
<toolbarbutton class="toolbarbutton-1" id="button-newlist" label="&newlistButton.label;" tooltiptext="&newlistButton.tooltip;" command="cmd_newlist"/>
|
||||
<toolbarbutton class="toolbarbutton-1" id="button-editcard"
|
||||
label="&editButton2.label;"
|
||||
tooltiptext="&editButton2.tooltip;"
|
||||
command="cmd_properties"/>
|
||||
label="&editPropertiesButton.label;"
|
||||
command="cmd_properties-button"/>
|
||||
<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;" command="cmd_chatWithCard"/>
|
||||
<toolbarbutton class="toolbarbutton-1" id="button-abdelete"
|
||||
|
|
|
@ -2,22 +2,38 @@
|
|||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY propertiesMenu.label "Properties">
|
||||
<!ENTITY propertiesMenu.accesskey "i">
|
||||
<!ENTITY propertiesCmd.key "i">
|
||||
<!ENTITY abPropertiesMenu.label "Address Book Properties">
|
||||
<!ENTITY abPropertiesMenu.accesskey "i">
|
||||
<!ENTITY contactPropertiesMenu.label "Contact Properties">
|
||||
<!ENTITY contactPropertiesMenu.accesskey "i">
|
||||
<!ENTITY mailingListPropertiesMenu.label "Mailing List Properties">
|
||||
<!ENTITY mailingListPropertiesMenu.accesskey "i">
|
||||
|
||||
<!ENTITY addressbookPicker.label "Address Book:">
|
||||
<!ENTITY addressbookPicker.accesskey "k">
|
||||
<!ENTITY searchContacts.label "Search Contacts:">
|
||||
<!ENTITY searchContacts.accesskey "n">
|
||||
<!ENTITY SearchNameOrEmail.label "Name or Email">
|
||||
|
||||
<!ENTITY deleteAddrBookCard.label "Delete">
|
||||
<!ENTITY deleteAddrBookCard.accesskey "D">
|
||||
<!ENTITY addrBookCardProperties.label "Properties">
|
||||
<!ENTITY addrBookCardProperties.accesskey "P">
|
||||
<!ENTITY addtoToFieldMenu.label "Add to To field">
|
||||
<!ENTITY addtoToFieldMenu.accesskey "A">
|
||||
<!ENTITY addtoCcFieldMenu.label "Add to Cc field">
|
||||
<!ENTITY addtoCcFieldMenu.accesskey "C">
|
||||
<!ENTITY addtoBccFieldMenu.label "Add to Bcc field">
|
||||
<!ENTITY addtoBccFieldMenu.accesskey "B">
|
||||
<!ENTITY deleteAddrBookCard.label "Delete">
|
||||
<!ENTITY deleteAddrBookCard.accesskey "D">
|
||||
<!ENTITY propertiesContext.label "Properties">
|
||||
<!ENTITY propertiesContext.accesskey "i">
|
||||
<!ENTITY abPropertiesContext.label "Properties">
|
||||
<!ENTITY abPropertiesContext.accesskey "i">
|
||||
<!ENTITY editContactContext.label "Edit Contact">
|
||||
<!ENTITY editContactContext.accesskey "E">
|
||||
<!ENTITY editMailingListContext.label "Edit List">
|
||||
<!ENTITY editMailingListContext.accesskey "E">
|
||||
|
||||
<!ENTITY toButton.label "Add to To:">
|
||||
<!ENTITY toButton.accesskey "A">
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<!ENTITY addressbookWindow.title "Address Book">
|
||||
<!ENTITY blankResultsPaneMessage.label "This address book shows contacts only after a search">
|
||||
<!ENTITY localResultsOnlyMessage.label "Contacts from remote address books are not shown until you search">
|
||||
|
||||
<!-- File Menu -->
|
||||
<!ENTITY fileMenu.label "File">
|
||||
<!ENTITY fileMenu.accesskey "F">
|
||||
|
@ -75,9 +76,15 @@
|
|||
<!-- LOCALIZATION NOTE (hideSwapFnLnUI) : DONT_TRANSLATE -->
|
||||
<!-- Swap FN/LN UI Set to "false" to show swap fn/ln UI -->
|
||||
<!ENTITY hideSwapFnLnUI "true">
|
||||
<!ENTITY propertiesCmd2.label "Properties">
|
||||
<!ENTITY propertiesCmd2.accesskey "i">
|
||||
<!ENTITY propertiesMenu.label "Properties">
|
||||
<!ENTITY propertiesMenu.accesskey "i">
|
||||
<!ENTITY propertiesCmd.key "i">
|
||||
<!ENTITY abPropertiesMenu.label "Address Book Properties">
|
||||
<!ENTITY abPropertiesMenu.accesskey "i">
|
||||
<!ENTITY contactPropertiesMenu.label "Contact Properties">
|
||||
<!ENTITY contactPropertiesMenu.accesskey "i">
|
||||
<!ENTITY mailingListPropertiesMenu.label "Mailing List Properties">
|
||||
<!ENTITY mailingListPropertiesMenu.accesskey "i">
|
||||
|
||||
<!-- View Menu -->
|
||||
<!ENTITY viewMenu.label "View">
|
||||
|
@ -133,8 +140,15 @@ because displayed names don't have the comma in between. -->
|
|||
<!ENTITY newContactButton.accesskey "C">
|
||||
<!ENTITY newlistButton.label "New List">
|
||||
<!ENTITY newlistButton.accesskey "L">
|
||||
<!ENTITY editButton2.label "Properties">
|
||||
<!ENTITY editButton2.accesskey "P">
|
||||
<!ENTITY editPropertiesButton.label "Edit">
|
||||
<!ENTITY propertiesContext.label "Properties">
|
||||
<!ENTITY propertiesContext.accesskey "i">
|
||||
<!ENTITY abPropertiesContext.label "Properties">
|
||||
<!ENTITY abPropertiesContext.accesskey "i">
|
||||
<!ENTITY editContactContext.label "Edit Contact">
|
||||
<!ENTITY editContactContext.accesskey "E">
|
||||
<!ENTITY editMailingListContext.label "Edit List">
|
||||
<!ENTITY editMailingListContext.accesskey "E">
|
||||
<!ENTITY newmsgButton.label "Write">
|
||||
<!ENTITY newmsgButton.accesskey "W">
|
||||
<!ENTITY newIM.label "Instant Message">
|
||||
|
@ -147,7 +161,10 @@ because displayed names don't have the comma in between. -->
|
|||
<!-- Address Book Toolbar Tooltips -->
|
||||
<!ENTITY newContactButton.tooltip "Create a new address book contact">
|
||||
<!ENTITY newlistButton.tooltip "Create a new list">
|
||||
<!ENTITY editButton2.tooltip "Edit the selected item">
|
||||
<!ENTITY editPropertiesButton.tooltip "Edit the selected item">
|
||||
<!ENTITY editAbPropertiesButton.tooltip "Edit the properties of the selected address book">
|
||||
<!ENTITY editContactPropertiesButton.tooltip "Edit the selected contact">
|
||||
<!ENTITY editMailingListPropertiesButton.tooltip "Edit the selected mailing list">
|
||||
<!ENTITY newmsgButton.tooltip "Send a mail message">
|
||||
<!ENTITY newIM.tooltip "Send an instant message or chat">
|
||||
<!ENTITY deleteButton2.tooltip "Delete selected item">
|
||||
|
|
|
@ -415,6 +415,38 @@ var ResultsPaneController =
|
|||
}
|
||||
return (enabled && (numSelected > 0));
|
||||
case "cmd_properties":
|
||||
let labelAttr = "valueGeneric";
|
||||
let accKeyAttr = "valueGenericAccessKey";
|
||||
let tooltipTextAttr = "valueGenericTooltipText";
|
||||
switch (GetSelectedCardTypes()) {
|
||||
// Set cmd_properties UI according to the type of the selected item(s),
|
||||
// even with multiple selections for which cmd_properties is
|
||||
// not yet available and hence disabled.
|
||||
case kMultipleListsOnly:
|
||||
case kSingleListOnly:
|
||||
labelAttr = "valueMailingList";
|
||||
accKeyAttr = "valueMailingListAccessKey";
|
||||
tooltipTextAttr = "valueMailingListTooltipText";
|
||||
break;
|
||||
case kCardsOnly:
|
||||
labelAttr = "valueContact";
|
||||
accKeyAttr = "valueContactAccessKey";
|
||||
tooltipTextAttr = "valueContactTooltipText";
|
||||
break;
|
||||
case kListsAndCards:
|
||||
default:
|
||||
//use generic set of attributes declared above
|
||||
break;
|
||||
}
|
||||
// This code is shared between main AB and composition's contacts sidebar.
|
||||
// Note that in composition, there's no cmd_properties-button (yet);
|
||||
// the resulting dump() should be ignored.
|
||||
goSetLabelAccesskeyTooltiptext("cmd_properties-button", null, null,
|
||||
tooltipTextAttr);
|
||||
goSetLabelAccesskeyTooltiptext("cmd_properties-contextMenu",
|
||||
labelAttr, accKeyAttr);
|
||||
goSetLabelAccesskeyTooltiptext("cmd_properties-menu",
|
||||
labelAttr, accKeyAttr);
|
||||
// While "Edit Contact" dialogue is still modal (bug 115904, bug 135126),
|
||||
// only enable "Properties" button for single selection; then fix bug 119999.
|
||||
return (GetNumSelectedCards() == 1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче