Bug 1583415 - Autoresize askSendFormat dialog to not let the buttons go out of view. r=Paenglab
authorAlessandro Castellani <alessandro@thunderbird.net>
Tue, 08 Oct 2019 16:39:21 -0700
changeset 27899 6370a0f66ec1b727ecda13b86ec1d277ac03f471
parent 27898 d7b26f4d5ea17e94a0faee54f64783538bd6e0da
child 27900 080bed041a01c876b8330a87cd3dab526b1f7dc9
push id16544
push userrichard.marti@gmail.com
push dateFri, 11 Oct 2019 17:24:42 +0000
treeherdercomm-central@6370a0f66ec1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPaenglab
bugs1583415
Bug 1583415 - Autoresize askSendFormat dialog to not let the buttons go out of view. r=Paenglab
mailnews/compose/content/askSendFormat.js
mailnews/compose/content/askSendFormat.xul
--- a/mailnews/compose/content/askSendFormat.js
+++ b/mailnews/compose/content/askSendFormat.js
@@ -11,54 +11,56 @@ document.addEventListener("dialogaccept"
  * {action: nsIMsgCompSendFormat.AskUser, convertible: nsIMsgCompConvertible.Yes}
  */
 function Startup() {
   gParam = window.arguments[0];
 
   const msgCompSendFormat = Ci.nsIMsgCompSendFormat;
   const msgCompConvertible = Ci.nsIMsgCompConvertible;
 
-  var bundle = document.getElementById("askSendFormatStringBundle");
+  // Select the node that need to be udpated.
+  let mailSendFormatExplanation = document.getElementById(
+    "mailSendFormatExplanation"
+  );
+  let icon = document.getElementById("convertDefault");
+
+  let bundle = document.getElementById("askSendFormatStringBundle");
+  let convertibleAltering = bundle.getString("convertibleAltering");
+  let convertibleNo = bundle.getString("convertibleNo");
+  let convertibleYes = bundle.getString("convertibleYes");
 
   // If the user hits the close box, we will abort.
   gParam.abort = true;
 
-  // Set the question label
-  var mailSendFormatExplanation = document.getElementById(
-    "mailSendFormatExplanation"
-  );
-  var icon = document.getElementById("convertDefault");
-
   switch (gParam.convertible) {
     case msgCompConvertible.Altering:
-      mailSendFormatExplanation.textContent = bundle.getString(
-        "convertibleAltering"
-      );
+      mailSendFormatExplanation.textContent = convertibleAltering;
       icon.className = "question-icon";
       break;
     case msgCompConvertible.No:
-      mailSendFormatExplanation.textContent = bundle.getString("convertibleNo");
+      mailSendFormatExplanation.textContent = convertibleNo;
       icon.className = "alert-icon";
       break;
     default:
       // msgCompConvertible.Yes
-      mailSendFormatExplanation.textContent = bundle.getString(
-        "convertibleYes"
-      );
-      // XXX change this to use class message-icon once bug 512173 is fixed
-      icon.className = "question-icon";
+      mailSendFormatExplanation.textContent = convertibleYes;
+      icon.className = "message-icon";
       break;
   }
 
   // Set the default radio array value and recommendation.
-  var group = document.getElementById("mailDefaultHTMLAction");
+  let group = document.getElementById("mailDefaultHTMLAction");
   if (gParam.action != msgCompSendFormat.AskUser) {
     group.value = gParam.action;
     group.selectedItem.label += " " + bundle.getString("recommended");
   }
+
+  setTimeout(() => {
+    window.sizeToContent();
+  }, 80);
 }
 
 function Send() {
   // gParam.action should be an integer for when it is returned to MsgComposeCommands.js
   gParam.action = parseInt(
     document.getElementById("mailDefaultHTMLAction").value
   );
   gParam.abort = false;
--- a/mailnews/compose/content/askSendFormat.xul
+++ b/mailnews/compose/content/askSendFormat.xul
@@ -4,30 +4,30 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
 
 <!DOCTYPE dialog SYSTEM "chrome://messenger/locale/messengercompose/askSendFormat.dtd">
 
 <dialog id="askSendFormat"
         title="&windowTitle.label;"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        xmlns:html="http://www.w3.org/1999/xhtml"
         buttonpack="center"
         onload="Startup();"
         buttonlabelaccept="&send.label;"
         buttonaccesskeyaccept="&send.accesskey;"
-        style="width: 75ch;">
+        style="width: 75ch; height: 20em;">
 
   <script src="chrome://messenger/content/messengercompose/askSendFormat.js"/>
 
   <stringbundle id="askSendFormatStringBundle"
                 src="chrome://messenger/locale/messengercompose/askSendFormat.properties"/>
 
-    <separator class="thin"/>
-    <hbox>
+    <hbox flex="1">
       <separator orient="vertical"/>
       <vbox id="askImageBox">
         <image id="convertDefault"/>
       </vbox>
       <separator orient="vertical"/>
       <vbox flex="1">
         <description>&recipient.label;</description>
         <description id="mailSendFormatExplanation"/>