Bug 378224 - Implement optional Return Receipt button for Composition Toolbar. ui-r=aleca, r=darktrojan
authorThomas Duellmann <bugzilla2007@duellmann24.net>
Sun, 31 May 2020 20:43:39 +0300
changeset 29720 ad9902d060b0ab0a74854ca24ef3571ea4077470
parent 29719 41e929c17e1b7074022c82f1c3616689961eaed7
child 29721 9f4a9f7ce10651f40e6788c3c1d648f4fb99d9dd
push id17499
push usermkmelin@iki.fi
push dateSun, 31 May 2020 17:48:51 +0000
treeherdercomm-central@9f4a9f7ce106 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaleca, darktrojan
bugs378224
Bug 378224 - Implement optional Return Receipt button for Composition Toolbar. ui-r=aleca, r=darktrojan
mail/components/compose/content/MsgComposeCommands.js
mail/components/compose/content/messengercompose.xhtml
mail/locales/en-US/messenger/messengercompose/messengercompose.ftl
mail/themes/shared/jar.inc.mn
mail/themes/shared/mail/icons/return-receipt.svg
mail/themes/shared/mail/messengercompose.css
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -1051,16 +1051,35 @@ var defaultController = {
         let selectedURIs = GetSelectedMessages();
         return selectedURIs && selectedURIs.length > 0;
       },
       doCommand() {
         QuoteSelectedMessage();
       },
     },
 
+    cmd_toggleReturnReceipt: {
+      isEnabled() {
+        let cmdToggleReturnReceipt = document.getElementById(
+          "cmd_toggleReturnReceipt"
+        );
+        let msgCompFields = gMsgCompose.compFields;
+        // Update checkmarks on all UI elements associated with the command.
+        cmdToggleReturnReceipt.setAttribute(
+          "checked",
+          msgCompFields.returnReceipt
+        );
+
+        return !gWindowLocked;
+      },
+      doCommand() {
+        ToggleReturnReceipt();
+      },
+    },
+
     cmd_fullZoomReduce: {
       isEnabled() {
         return true;
       },
       doCommand() {
         ZoomManager.reduce();
       },
     },
@@ -1542,16 +1561,17 @@ function updateComposeItems() {
       goUpdateCommand("cmd_smiley");
     }
 
     // Options Menu
     goUpdateCommand("cmd_spelling");
 
     // Workaround to update 'Quote' toolbar button. (See bug 609926.)
     goUpdateCommand("cmd_quoteMessage");
+    goUpdateCommand("cmd_toggleReturnReceipt");
   } catch (e) {}
 }
 
 /**
  * Disables or restores all toolbar items (menus/buttons) in the window.
  *
  * @param aDisable  true = disable all items. false = restore items to the state
  *                  stored before disabling them.
@@ -1862,16 +1882,21 @@ function updateEditItems() {
   goUpdateCommand("cmd_findNext");
   goUpdateCommand("cmd_findPrev");
 }
 
 function updateViewItems() {
   goUpdateCommand("cmd_toggleAttachmentPane");
 }
 
+function updateOptionItems() {
+  goUpdateCommand("cmd_quoteMessage");
+  goUpdateCommand("cmd_toggleReturnReceipt");
+}
+
 function updateAttachmentItems() {
   goUpdateCommand("cmd_toggleAttachmentPane");
   goUpdateCommand("cmd_attachCloud");
   goUpdateCommand("cmd_convertCloud");
   goUpdateCommand("cmd_convertAttachment");
   goUpdateCommand("cmd_cancelUpload");
   goUpdateCommand("cmd_delete");
   goUpdateCommand("cmd_removeAllAttachments");
@@ -2431,20 +2456,16 @@ function convertToRegularAttachment(aAtt
     if (item) {
       items.push(item);
     }
   }
 
   convertListItemsToRegularAttachment(items);
 }
 
-function updateOptionItems() {
-  goUpdateCommand("cmd_quoteMessage");
-}
-
 /* messageComposeOfflineQuitObserver is notified whenever the network
  * connection status has switched to offline, or when the application
  * has received a request to quit.
  */
 var messageComposeOfflineQuitObserver = {
   observe(aSubject, aTopic, aData) {
     // sanity checks
     if (aTopic == "network:offline-status-changed") {
@@ -4230,19 +4251,19 @@ function SetComposeDetails(newValues) {
  * Handles message sending operations.
  *
  * @param {nsIMsgCompDeliverMode} mode - The delivery mode of the operation.
  */
 function GenericSendMessage(msgType) {
   let msgCompFields = GetComposeDetails();
   let subject = msgCompFields.subject;
 
-  // Some other msgCompFields have already been updated instantly in their respective
-  // toggle functions, e.g. ToggleReturnReceipt(), ToggleDSN(),  ToggleAttachVCard(),
-  // and toggleAttachmentReminder().
+  // Some other msgCompFields have already been updated instantly in their
+  // respective toggle functions, e.g. ToggleReturnReceipt(), ToggleDSN(),
+  // ToggleAttachVCard(), and toggleAttachmentReminder().
 
   let sending =
     msgType == Ci.nsIMsgCompDeliverMode.Now ||
     msgType == Ci.nsIMsgCompDeliverMode.Later ||
     msgType == Ci.nsIMsgCompDeliverMode.Background;
   if (sending) {
     expandRecipients();
     // Check if e-mail addresses are complete, in case user turned off
@@ -5238,27 +5259,30 @@ function updateEncodingInStatusBar() {
   if (!encodingStatusPanel) {
     return;
   }
 
   // Update status display; no status display for default text encoding.
   encodingStatusPanel.collapsed = !(encodingStatusPanel.value = encodingUIString);
 }
 
-function ToggleReturnReceipt(target) {
-  var msgCompFields = gMsgCompose.compFields;
+/**
+ * Toggle Return Receipt (Disposition-Notification-To: header).
+ */
+function ToggleReturnReceipt() {
+  let msgCompFields = gMsgCompose.compFields;
   if (msgCompFields) {
     msgCompFields.returnReceipt = !msgCompFields.returnReceipt;
-    target.setAttribute("checked", msgCompFields.returnReceipt);
+    goUpdateCommand("cmd_toggleReturnReceipt");
     gReceiptOptionChanged = true;
   }
 }
 
 function ToggleDSN(target) {
-  var msgCompFields = gMsgCompose.compFields;
+  let msgCompFields = gMsgCompose.compFields;
   if (msgCompFields) {
     msgCompFields.DSN = !msgCompFields.DSN;
     target.setAttribute("checked", msgCompFields.DSN);
     gDSNOptionChanged = true;
   }
 }
 
 function ToggleAttachVCard(target) {
@@ -5474,17 +5498,23 @@ function ComposeCanClose() {
     if (result == 1) {
       gMsgCompose.abort();
       return true;
     }
     return false;
   }
 
   // Returns FALSE only if user cancels save action
-  if (gContentChanged || gMsgCompose.bodyModified || gAutoSaveKickedIn) {
+  if (
+    gContentChanged ||
+    gMsgCompose.bodyModified ||
+    gAutoSaveKickedIn ||
+    gReceiptOptionChanged ||
+    gDSNOptionChanged
+  ) {
     // call window.focus, since we need to pop up a dialog
     // and therefore need to be visible (to prevent user confusion)
     window.focus();
     let draftFolderURI = gCurrentIdentity.draftFolder;
     let draftFolderName = MailUtils.getOrCreateFolder(draftFolderURI)
       .prettyName;
     let result = Services.prompt.confirmEx(
       window,
@@ -6926,19 +6956,17 @@ function LoadIdentity(startup) {
       Recipients2CompFields(msgCompFields);
 
       if (
         !gReceiptOptionChanged &&
         prevReceipt == msgCompFields.returnReceipt &&
         prevReceipt != newReceipt
       ) {
         msgCompFields.returnReceipt = newReceipt;
-        document
-          .getElementById("returnReceiptMenu")
-          .setAttribute("checked", msgCompFields.returnReceipt);
+        goUpdateCommand("cmd_toggleReturnReceipt");
       }
 
       if (
         !gDSNOptionChanged &&
         prevDSN == msgCompFields.DSN &&
         prevDSN != newDSN
       ) {
         msgCompFields.DSN = newDSN;
--- a/mail/components/compose/content/messengercompose.xhtml
+++ b/mail/components/compose/content/messengercompose.xhtml
@@ -347,16 +347,18 @@
     <command id="cmd_fullZoomReset"
              oncommand="goDoCommand('cmd_fullZoomReset');"/>
     <command id="cmd_fullZoomToggle"
              oncommand="goDoCommand('cmd_fullZoomToggle');"/>
   </commandset>
 
   <!-- Options Menu -->
   <command id="cmd_quoteMessage" oncommand="goDoCommand('cmd_quoteMessage')"/>
+  <command id="cmd_toggleReturnReceipt"
+           oncommand="goDoCommand('cmd_toggleReturnReceipt')"/>
   <command id="cmd_insert"/>
   <command id="cmd_viewSecurityStatus"
            oncommand="showMessageComposeSecurityStatus();"/>
 
 #ifdef XP_MACOSX
   <!-- Mac Window menu -->
   <command id="minimizeWindow" label="&minimizeWindow.label;" oncommand="window.minimize();"/>
   <command id="zoomWindow" label="&zoomWindow.label;" oncommand="zoomWindow();"/>
@@ -1697,17 +1699,21 @@
           <menuitem label="&enableInlineSpellChecker.label;" id="menu_inlineSpellCheck"
                     accesskey="&enableInlineSpellChecker.accesskey;" checked="false"
                     type="checkbox"
                     oncommand="enableInlineSpellCheck(!gSpellChecker.enabled);"/>
           <menuitem label="&quoteCmd.label;"
                     accesskey="&quoteCmd.accesskey;"
                     command="cmd_quoteMessage"/>
           <menuseparator/>
-          <menuitem id="returnReceiptMenu" type="checkbox" label="&returnReceiptMenu.label;" accesskey="&returnReceiptMenu.accesskey;" checked="false" oncommand="ToggleReturnReceipt(event.target)"/>
+          <menuitem id="returnReceiptMenu" type="checkbox"
+                    label="&returnReceiptMenu.label;"
+                    accesskey="&returnReceiptMenu.accesskey;"
+                    checked="false"
+                    command="cmd_toggleReturnReceipt"/>
           <menuitem id="dsnMenu" type="checkbox" label="&dsnMenu.label;" accesskey="&dsnMenu.accesskey;" oncommand="ToggleDSN(event.target)"/>
           <menuseparator/>
           <menu id="charsetMenu"
                 data-l10n-id="menu-view-charset"
                 oncommand="SetDocumentCharacterSet(event.target.getAttribute('charset'));"
                 onpopupshowing="UpdateCharsetMenu(gMsgCompose.compFields.characterSet, this);">
             <menupopup id="charsetPopup" detectors="false"
                        onpopupshowing="CharsetMenu.build(this, true, this.getAttribute('detectors') != 'false');"/>
@@ -2077,16 +2083,21 @@
           <menuitem id="list_priority_lowest"
                     name="priority"
                     label="&lowestPriorityCmd.label;"
                     value="Lowest"/>
         </menupopup>
       </menulist>
     </toolbaritem>
 
+    <toolbarbutton id="button-returnReceipt"
+                   class="toolbarbutton-1"
+                   data-l10n-id="button-return-receipt"
+                   type="checkbox" autoCheck="false"
+                   command="cmd_toggleReturnReceipt"/>
   </toolbarpalette>
   <toolbar is="customizable-toolbar" id="composeToolbar2" class="chromeclass-toolbar"
            toolbarname="&showCompositionToolbarCmd.label;"
            accesskey="&showCompositionToolbarCmd.accesskey;"
            fullscreentoolbar="true" mode="full"
 #ifdef XP_MACOSX
            iconsize="small"
 #endif
--- a/mail/locales/en-US/messenger/messengercompose/messengercompose.ftl
+++ b/mail/locales/en-US/messenger/messengercompose/messengercompose.ftl
@@ -32,8 +32,12 @@ pill-action-move-to =
 
 pill-action-move-cc =
     .label = Move to Cc
     .accesskey = C
 
 pill-action-move-bcc =
     .label = Move to Bcc
     .accesskey = B
+
+button-return-receipt =
+    .label = Receipt
+    .tooltiptext = Request a return receipt for this message
--- a/mail/themes/shared/jar.inc.mn
+++ b/mail/themes/shared/jar.inc.mn
@@ -134,22 +134,23 @@
   skin/classic/messenger/icons/previousunread.svg             (../shared/mail/icons/previousunread.svg)
   skin/classic/messenger/icons/print.svg                      (../shared/mail/icons/print.svg)
   skin/classic/messenger/icons/popular.svg                    (../shared/mail/icons/popular.svg)
   skin/classic/messenger/icons/quit.svg                       (../shared/mail/icons/quit.svg)
   skin/classic/messenger/icons/quote.svg                      (../shared/mail/icons/quote.svg)
   skin/classic/messenger/icons/read.svg                       (../shared/mail/icons/read.svg)
   skin/classic/messenger/icons/reader-mode.svg                (../shared/mail/icons/reader-mode.svg)
   skin/classic/messenger/icons/readcol.svg                    (../shared/mail/icons/readcol.svg)
-  skin/classic/messenger/icons/restore.svg                    (../shared/mail/icons/restore.svg)
   skin/classic/messenger/icons/remote-blocked.svg             (../shared/mail/icons/remote-blocked.svg)
   skin/classic/messenger/icons/reply.svg                      (../shared/mail/icons/reply.svg)
   skin/classic/messenger/icons/replyall.svg                   (../shared/mail/icons/replyall.svg)
   skin/classic/messenger/icons/replylist.svg                  (../shared/mail/icons/replylist.svg)
   skin/classic/messenger/icons/reply-forward.svg              (../shared/mail/icons/reply-forward.svg)
+  skin/classic/messenger/icons/restore.svg                    (../shared/mail/icons/restore.svg)
+  skin/classic/messenger/icons/return-receipt.svg             (../shared/mail/icons/return-receipt.svg)
   skin/classic/messenger/icons/right-align.svg                (../shared/mail/icons/right-align.svg)
   skin/classic/messenger/icons/search-folder.svg              (../shared/mail/icons/search-folder.svg)
   skin/classic/messenger/icons/search-glass.svg               (../shared/mail/icons/search-glass.svg)
   skin/classic/messenger/icons/save.svg                       (../shared/mail/icons/save.svg)
   skin/classic/messenger/icons/save-as.svg                    (../shared/mail/icons/save-as.svg)
   skin/classic/messenger/icons/search-not-found.svg           (../shared/mail/icons/search-not-found.svg)
   skin/classic/messenger/icons/search-spinner.svg             (../shared/mail/icons/search-spinner.svg)
   skin/classic/messenger/icons/security.svg                   (../shared/mail/icons/security.svg)
new file mode 100644
--- /dev/null
+++ b/mail/themes/shared/mail/icons/return-receipt.svg
@@ -0,0 +1,7 @@
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - 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/. -->
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="context-fill" fill-opacity="context-fill-opacity">
+  <path d="M6 16a.99.99 0 01-.7-.29l-3-3c-.95-.94.46-2.36 1.4-1.42l2.16 2.16 5.32-7.62c.76-1.1 2.4.05 1.64 1.14l-6 8.6c-.17.24-.44.4-.73.43H6z"/>
+  <path d="M5.6 11.01a.99.99 0 01-.71-.29l-3-3c-.94-.95.46-2.35 1.41-1.43l2.16 2.17L10.77.83c.76-1.1 2.41.05 1.65 1.15l-6 8.6c-.17.24-.44.4-.74.43H5.6z"/>
+</svg>
--- a/mail/themes/shared/mail/messengercompose.css
+++ b/mail/themes/shared/mail/messengercompose.css
@@ -341,16 +341,20 @@
 #button-save {
   list-style-image: url("chrome://messenger/skin/icons/save.svg");
 }
 
 #quoteButton {
   list-style-image: url("chrome://messenger/skin/icons/quote.svg");
 }
 
+#button-returnReceipt {
+  list-style-image: url("chrome://messenger/skin/icons/return-receipt.svg");
+}
+
 #cut-button {
   list-style-image: url("chrome://messenger/skin/icons/cut.svg");
 }
 
 #copy-button {
   list-style-image: url("chrome://messenger/skin/icons/copy.svg");
 }