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 16088 a27ee7a01aace6cba897d63656947ea8ea370e5e
parent 16087 29eb1bad3a822ec71d0bf8556677d4cf3be400ef
child 16089 5d0f4ea39b13631d367d1427bf593c950e3c9a44
push id48
push usermbanner@mozilla.com
push dateThu, 13 Mar 2014 13:32:05 +0000
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
@@ -880,26 +880,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]'));
@@ -916,17 +920,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"