Bug 99997 - Copy email and address from header to clipboard. r=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Sun, 06 Jan 2019 23:21:43 +0100
changeset 34126 aad2453b9a23def27d08daf3bef668abf2e26afb
parent 34125 a5791d3c3cc6b5efda610e656ecce32ee5ca8ca8
child 34127 6b7c8000a821e2d4c1aac98b03d65ea8355887bd
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersIanN
bugs99997, 232021
Bug 99997 - Copy email and address from header to clipboard. r=IanN Port TB Bug 232021 [name should be included with email address when copying from header menu].
suite/locales/en-US/chrome/mailnews/msgHdrViewPopup.dtd
suite/mailnews/mailContextMenus.js
suite/mailnews/msgHdrViewOverlay.xul
--- a/suite/locales/en-US/chrome/mailnews/msgHdrViewPopup.dtd
+++ b/suite/locales/en-US/chrome/mailnews/msgHdrViewPopup.dtd
@@ -8,16 +8,18 @@
 <!ENTITY EditContact.label                 "Edit Contact…">
 <!ENTITY EditContact.accesskey             "E">
 <!ENTITY ViewContact.label                 "View Contact">
 <!ENTITY ViewContact.accesskey             "V">
 <!ENTITY SendMailTo.label                  "Compose Mail To…">
 <!ENTITY SendMailTo.accesskey              "s">
 <!ENTITY CopyEmailAddress.label            "Copy Email Address">
 <!ENTITY CopyEmailAddress.accesskey        "C">
+<!ENTITY CopyNameAndEmailAddress.label     "Copy Name and Email Address">
+<!ENTITY CopyNameAndEmailAddress.accesskey "N">
 <!ENTITY CreateFilterFrom.label            "Create Filter From…">
 <!ENTITY CreateFilterFrom.accesskey        "F">
 <!ENTITY openInBrowser.label               "Open in Browser">
 <!ENTITY openInBrowser.accesskey           "O">
 <!ENTITY bookmarkLinkCmd.label             "Bookmark This Link…">
 <!ENTITY bookmarkLinkCmd.accesskey         "B">
 <!ENTITY copyLinkCmd.label                 "Copy Link Location">
 <!ENTITY copyLinkCmd.accesskey             "C">
--- a/suite/mailnews/mailContextMenus.js
+++ b/suite/mailnews/mailContextMenus.js
@@ -474,22 +474,32 @@ function SendMailTo(fullAddress, aEvent)
     Ci.nsIMsgCompFormat.OppositeOfDefault :
     Ci.nsIMsgCompFormat.Default;
 
   params.identity = accountManager.getFirstIdentityForServer(GetLoadedMsgFolder().server);
   params.composeFields = fields;
   MailServices.compose.OpenComposeWindowWithParams(null, params);
 }
 
-// CopyEmailAddress takes the email address title button, extracts
-// the email address we stored in there and copies it to the clipboard
-function CopyEmailAddress(emailAddressNode)
+/**
+ * Takes the email address, extracts the address/name
+ * we stored in there and copies it to the clipboard.
+ *
+ * @param addressNode  a node which has an "emailAddress"
+ *                     attribute
+ * @param aIncludeName when true, also copy the name onto the clipboard,
+ *                     otherwise only the email address
+ */
+function CopyEmailAddress(emailAddressNode, aIncludeName = false)
 {
-  if (emailAddressNode)
-    CopyString(emailAddressNode.getAttribute("emailAddress"));
+  if (emailAddressNode) {
+    let address = emailAddressNode.getAttribute(aIncludeName ? "fullAddress"
+                                                             : "emailAddress");
+    CopyString(address);
+  }
 }
 
 // show the message id in the context menu
 function FillMessageIdContextMenu(messageIdNode)
 {
   var msgId = messageIdNode.getAttribute("messageid");
   document.getElementById("messageIdContext-messageIdTarget")
           .setAttribute("label", msgId);
--- a/suite/mailnews/msgHdrViewOverlay.xul
+++ b/suite/mailnews/msgHdrViewOverlay.xul
@@ -74,17 +74,21 @@
   <menuitem id="viewContactItem"
             label="&ViewContact.label;"
             accesskey="&ViewContact.accesskey;"
             hidden="true"
             oncommand="EditContact(document.popupNode);"/>
   <menuitem id="copyEmailAddressItem"
             label="&CopyEmailAddress.label;"
             accesskey="&CopyEmailAddress.accesskey;"
-            oncommand="CopyEmailAddress(document.popupNode)"/>
+            oncommand="CopyEmailAddress(document.popupNode);"/>
+  <menuitem id="copyNameAndEmailAddressItem"
+            label="&CopyNameAndEmailAddress.label;"
+            accesskey="&CopyNameAndEmailAddress.accesskey;"
+            oncommand="CopyEmailAddress(document.popupNode, true);"/>
 </menupopup>
 
 <menupopup id="attachmentListContext" onpopupshowing="return onShowAttachmentContextMenu();">
   <menuitem id="context-openAttachment" label="&openAttachmentCmd.label;" accesskey="&openAttachmentCmd.accesskey;"
      oncommand="handleAttachmentSelection('openAttachment');"/>
   <menuitem id="context-viewAttachment" label="&viewAttachmentCmd.label;" accesskey="&viewAttachmentCmd.accesskey;"
      oncommand="handleAttachmentSelection('viewAttachment');"/>
   <menuitem id="context-saveAttachment" label="&saveAsAttachmentCmd.label;" accesskey="&saveAsAttachmentCmd.accesskey;"