From 3549eafa0997dd62ce1bab41e4e1ec94fd5ca09d Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Sat, 5 Jan 2002 20:40:05 +0000 Subject: [PATCH] Fix updating toolbar color after page color is changed, b=115694, r=syd, sr=hewitt --- .../ui/composer/content/ComposerCommands.js | 1 + editor/ui/composer/content/editor.js | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/editor/ui/composer/content/ComposerCommands.js b/editor/ui/composer/content/ComposerCommands.js index 778f5438485b..8694f5b50a32 100644 --- a/editor/ui/composer/content/ComposerCommands.js +++ b/editor/ui/composer/content/ComposerCommands.js @@ -1661,6 +1661,7 @@ var nsColorPropertiesCommand = doCommand: function(aCommand) { window.openDialog("chrome://editor/content/EdColorProps.xul","_blank", "chrome,close,titlebar,modal", ""); + UpdateDefaultColors(); window._content.focus(); } }; diff --git a/editor/ui/composer/content/editor.js b/editor/ui/composer/content/editor.js index 325502c9ceb5..e7af441405ae 100644 --- a/editor/ui/composer/content/editor.js +++ b/editor/ui/composer/content/editor.js @@ -812,6 +812,42 @@ function onBackgroundColorChange() } } +// Call this when user changes text and/or background colors of the page +function UpdateDefaultColors() +{ + var BrowserColors = GetDefaultBrowserColors(); + var bodyelement = GetBodyElement(); + var defTextColor = gDefaultTextColor; + var defBackColor = gDefaultBackgroundColor; + + if (bodyelement) + { + var color = bodyelement.getAttribute("text"); + if (color) + gDefaultTextColor = color; + else if (BrowserColors) + gDefaultTextColor = BrowserColors.TextColor; + + color = bodyelement.getAttribute("bgcolor"); + if (color) + gDefaultBackgroundColor = color; + else if (BrowserColors) + gDefaultBackgroundColor = BrowserColors.BackgroundColor; + } + + // Trigger update on toolbar + if (defTextColor != gDefaultTextColor) + { + goUpdateCommand("cmd_fontColor"); + onFontColorChange(); + } + if (defBackColor != gDefaultBackgroundColor) + { + goUpdateCommand("cmd_backgroundColor"); + onBackgroundColorChange(); + } +} + function GetBackgroundElementWithColor() { gColorObj.Type = "";