From 8667c2b02fe374409ecfcbb5288ac7796cd549bf Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Mon, 17 Sep 2001 19:31:19 +0000 Subject: [PATCH] Added support to use relative URLs in link and image dialogs and let user convert to/from absolute URLs, b=72583, r=brade,akkana, sr=kin git-svn-id: svn://10.0.0.236/trunk@103003 18797224-902f-48f8-a5cc-f745e15eee43 --- .../editor/ui/dialogs/content/EdColorProps.js | 19 +- .../ui/dialogs/content/EdColorProps.xul | 34 +- .../ui/dialogs/content/EdDialogCommon.js | 367 ++++++++++++++++++ .../ui/dialogs/content/EdDialogOverlay.xul | 8 + .../editor/ui/dialogs/content/EdImageProps.js | 94 +++-- .../ui/dialogs/content/EdImageProps.xul | 79 ++-- .../editor/ui/dialogs/content/EdLinkProps.js | 49 ++- .../editor/ui/dialogs/content/EdLinkProps.xul | 10 +- 8 files changed, 532 insertions(+), 128 deletions(-) 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 @@ - - - - - - -