Bug 883540 - Fix text color button in composer to work again after saving msg as draft. r=mkmelin,a=Standard8
--- 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"