Bug 883540 - Fix text color button in composer to work again after saving msg as draft. r=mkmelin,a=Standard8
authoraceman <acelists@atlas.sk>
Thu, 13 Feb 2014 09:33:51 -0500
changeset 17034 2df100d878c79f5422840503ce241aea5cd357b5
parent 17033 1a30ff535cab8bcfeff47b1391f18eddd453d6ba
child 17038 a5d95c28e762e01d33b1176a2a2842dae8128a96
push id1093
push userbugzilla@standard8.plus.com
push dateTue, 04 Mar 2014 11:48:23 +0000
treeherdercomm-beta@2df100d878c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, Standard8
bugs883540
Bug 883540 - Fix text color button in composer to work again after saving msg as draft. r=mkmelin,a=Standard8
mail/components/compose/content/MsgComposeCommands.js
mail/components/compose/content/editorOverlay.xul
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -982,26 +982,30 @@ function updateComposeItems()
  *
  * @param aDisable  true = disable all items. false = restore items to the state
  *                  stored before disabling them.
  */
 function updateAllItems(aDisable)
 {
   function getDisabledState(aElement) {
     if ("disabled" in aElement)
-      return aElement.disabled;
+      return (aElement.disabled ? "true" : "false");
+    else if (!aElement.hasAttribute("disabled"))
+      return "";
     else
       return aElement.getAttribute("disabled");
   }
 
   function setDisabledState(aElement, aValue) {
     if ("disabled" in aElement)
-      aElement.disabled = aValue;
+      aElement.disabled = (aValue == "true");
+    else if (aValue == "")
+      aElement.removeAttribute("disabled");
     else
-      aElement.setAttribute("disabled", aValue ? "true" : "false");
+      aElement.setAttribute("disabled", aValue);
   }
 
 
   // This array will contain HTMLCollection objects as members.
   let commandItemCollections = [];
   commandItemCollections.push(document.getElementsByTagName("menu"));
   commandItemCollections.push(document.getElementsByTagName("toolbarbutton"));
   commandItemCollections.push(document.querySelectorAll('[command]'));
@@ -1018,17 +1022,17 @@ function updateAllItems(aDisable)
           setDisabledState(commandItem, true);
         }
       }
       else {
         // Any element can appear multiple times in the commandItemCollections
         // list so only act on it if it still has the "stateBeforeSend"
         // attribute.
         if (commandItem.hasAttribute("stateBeforeSend")) {
-          setDisabledState(commandItem, commandItem.getAttribute("stateBeforeSend") == "true");
+          setDisabledState(commandItem, commandItem.getAttribute("stateBeforeSend"));
           commandItem.removeAttribute("stateBeforeSend");
         }
       }
     }
   }
 }
 
 function InitFileSaveAsMenu()
--- a/mail/components/compose/content/editorOverlay.xul
+++ b/mail/components/compose/content/editorOverlay.xul
@@ -923,23 +923,23 @@
 </toolbaritem>
 
 <toolbaritem id="color-buttons-container"
              class="formatting-button">
   <stack id="ColorButtons" align="center">
     <observes element="cmd_fontColor"       attribute="state" onbroadcast="onFontColorChange()"/>
     <observes element="cmd_backgroundColor" attribute="state" onbroadcast="onBackgroundColorChange()"/>
     <box class="color-button" id="BackgroundColorButton"
-         onclick="if (!this.hasAttribute('disabled')) { EditorSelectColor('', event); }"
+         onclick="if (!this.hasAttribute('disabled') || this.getAttribute('disabled') != 'true') { EditorSelectColor('', event); }"
          tooltiptext="&BackgroundColorButton.tooltip;"
          oncommand="/* See MsgComposeCommands.js::updateAllItems for why this attribute is needed here. */">
       <observes element="cmd_backgroundColor" attribute="disabled"/>
     </box>
     <box class="color-button" id="TextColorButton"
-         onclick="if (!this.hasAttribute('disabled')) { EditorSelectColor('Text', event); }"
+         onclick="if (!this.hasAttribute('disabled') || this.getAttribute('disabled') != 'true') { EditorSelectColor('Text', event); }"
          tooltiptext="&TextColorButton.tooltip;"
          oncommand="/* See MsgComposeCommands.js::updateAllItems for why this attribute is needed here. */">
       <observes element="cmd_fontColor" attribute="disabled"/>
     </box>
   </stack>
 </toolbaritem>
   <toolbarbutton id="HighlightColorButton"
                  class="formatting-button"