diff --git a/mozilla/editor/ui/dialogs/content/EdColorProps.js b/mozilla/editor/ui/dialogs/content/EdColorProps.js index 305031463cd..d23f26f54ba 100644 --- a/mozilla/editor/ui/dialogs/content/EdColorProps.js +++ b/mozilla/editor/ui/dialogs/content/EdColorProps.js @@ -62,6 +62,7 @@ var backgroundStr = "background"; var colorStyle = "color: "; var backColorStyle = "background-color: "; var backImageStyle = "; background-image: url("; +var gHaveDocumentUrl = false; // dialog initialization code function Startup() @@ -110,6 +111,9 @@ function Startup() defaultBackgroundColor= browserColors.BackgroundColor; } + // We only need to test for this once per dialog load + gHaveDocumentUrl = GetDocumentBaseUrl(); + InitDialog(); if (dialog.DefaultColorsRadio.checked) @@ -124,12 +128,14 @@ function InitDialog() { // Get image from document backgroundImage = globalElement.getAttribute(backgroundStr); - if (backgroundImage.length > 0) + if (backgroundImage.length) { dialog.BackgroundImageInput.value = backgroundImage; dialog.ColorPreview.setAttribute(styleStr, backImageStyle+backgroundImage+");"); } + SetRelativeCheckbox(); + customTextColor = globalElement.getAttribute(textStr); customLinkColor = globalElement.getAttribute(linkStr); customActiveColor = globalElement.getAttribute(alinkStr); @@ -324,7 +330,14 @@ function chooseFile() var fileName = GetLocalFileURL("img"); if (fileName) { + // Always try to relativize local file URLs + if (gHaveDocumentUrl) + fileName = MakeRelativeUrl(fileName); + dialog.BackgroundImageInput.value = fileName; + + SetRelativeCheckbox(); + ValidateAndPreviewImage(true); } SetTextboxFocus(dialog.BackgroundImageInput); @@ -334,6 +347,7 @@ function ChangeBackgroundImage() { // Don't show error message for image while user is typing ValidateAndPreviewImage(false); + SetRelativeCheckbox(); } function ValidateAndPreviewImage(ShowErrorMessage) @@ -347,7 +361,8 @@ function ValidateAndPreviewImage(ShowErrorMessage) { if (IsValidImage(image)) { - backgroundImage = image; + backgroundImage = gHaveDocumentUrl ? MakeAbsoluteUrl(image) : image; + // Append image style styleValue += backImageStyle+backgroundImage+");"; } diff --git a/mozilla/editor/ui/dialogs/content/EdColorProps.xul b/mozilla/editor/ui/dialogs/content/EdColorProps.xul index a3a42fb91dd..0ccf04ed82f 100644 --- a/mozilla/editor/ui/dialogs/content/EdColorProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdColorProps.xul @@ -133,23 +133,21 @@ - - - - - - -