diff --git a/mozilla/editor/ui/composer/content/ComposerCommands.js b/mozilla/editor/ui/composer/content/ComposerCommands.js
index 25347126916..014bb1bf7bf 100644
--- a/mozilla/editor/ui/composer/content/ComposerCommands.js
+++ b/mozilla/editor/ui/composer/content/ComposerCommands.js
@@ -141,6 +141,7 @@ function SetupComposerWindowCommands()
commandManager.registerCommand("cmd_revert", nsRevertCommand);
commandManager.registerCommand("cmd_openRemote", nsOpenRemoteCommand);
commandManager.registerCommand("cmd_preview", nsPreviewCommand);
+ commandManager.registerCommand("cmd_editSendPage", nsSendPageCommand);
commandManager.registerCommand("cmd_quit", nsQuitCommand);
commandManager.registerCommand("cmd_close", nsCloseCommand);
commandManager.registerCommand("cmd_preferences", nsPreferencesCommand);
@@ -392,9 +393,9 @@ function CloseWindow()
{
FinishHTMLSource();
- // Close window; check to make sure document is saved
- var result = CheckAndSaveDocument(window.editorShell.GetString("BeforeClosing"));
- if (result == true) // If they saved the document, or it is unchanged, exit
+ // Check to make sure document is saved. "true" means allow "Don't Save" button,
+ // so user can choose to close without saving
+ if (CheckAndSaveDocument(window.editorShell.GetString("BeforeClosing"), true))
{
if (window.InsertCharWindow)
SwitchInsertCharToAnotherEditorOrClose();
@@ -441,31 +442,51 @@ var nsPreviewCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
- // maybe disable if we haven't saved?
- // return (window.editorShell && !window.editorShell.documentModified);
- return (window.editorShell != null);
+ return (window.editorShell != null && (DocumentHasBeenSaved() || window.editorShell.documentModified));
},
doCommand: function(aCommand)
{
FinishHTMLSource();
+
// Don't continue if user canceled during prompt for saving
- if (!CheckAndSaveDocument(window.editorShell.GetString("BeforePreview")))
+ // DocumentHasBeenSaved will test if we have a URL and suppress "Don't Save" button if not
+ if (!CheckAndSaveDocument(window.editorShell.GetString("BeforePreview"), DocumentHasBeenSaved()))
return;
- var fileurl = "";
- try {
- fileurl = window._content.location;
- } catch (e) {
- return;
- }
+ // Check if we saved again just in case?
+ if (DocumentHasBeenSaved())
+ window.openDialog(getBrowserURL(), "EditorPreview", "chrome,all,dialog=no", window._content.location);
+ }
+};
- // CheckAndSave doesn't tell us if the user said "Don't Save",
- // so make sure we have a url:
- if (fileurl != "" && fileurl != "about:blank")
- {
- window.openDialog(getBrowserURL(), "EditorPreview", "chrome,all,dialog=no", fileurl);
- }
+//-----------------------------------------------------------------------------------
+var nsSendPageCommand =
+{
+ isCommandEnabled: function(aCommand, dummy)
+ {
+ return (window.editorShell != null && (DocumentHasBeenSaved() || window.editorShell.documentModified));
+ },
+
+ doCommand: function(aCommand)
+ {
+ FinishHTMLSource();
+
+ // Don't continue if user canceled during prompt for saving
+ // DocumentHasBeenSaved will test if we have a URL and suppress "Don't Save" button if not
+ if (!CheckAndSaveDocument(window.editorShell.GetString("SendPageReason"), DocumentHasBeenSaved()))
+ return;
+
+ // Check if we saved again just in case?
+ if (DocumentHasBeenSaved())
+ {
+ // Lauch Messenger Composer window with current page as contents
+ var pageTitle = window.editorShell.editorDocument.title;
+ var pageUrl = window.editorShell.editorDocument.location;
+ window.openDialog("chrome://messenger/content/messengercompose/messengercompose.xul", "_blank",
+ "chrome,all,dialog=no", "attachment='" + pageUrl + "',body='" + pageUrl +
+ "',subject='" + pageTitle + "',bodyislink=true");
+ }
}
};
@@ -765,7 +786,7 @@ var nsPagePropertiesCommand =
},
doCommand: function(aCommand)
{
- window.openDialog("chrome://editor/content/EdPageProps.xul","_blank", "chrome,close,titlebar,modal,resizable", "");
+ window.openDialog("chrome://editor/content/EdPageProps.xul","_blank", "chrome,close,titlebar,modal", "");
}
};
diff --git a/mozilla/editor/ui/composer/content/editor.js b/mozilla/editor/ui/composer/content/editor.js
index 15f2d0407ad..fb03e6487b6 100644
--- a/mozilla/editor/ui/composer/content/editor.js
+++ b/mozilla/editor/ui/composer/content/editor.js
@@ -342,49 +342,29 @@ function editorSendPage()
"chrome,all,dialog=no", "attachment='" + pageUrl + "',body='" + pageUrl +
"',subject='" + pageTitle + "',bodyislink=true");
}
- else if (CheckAndSaveDocument(GetString("SendPageReason")))
+ else if (CheckAndSaveDocument(GetString("SendPageReason")), DocumentHasBeenSaved())
editorSendPage();
window._content.focus();
}
-/*
-// This is redundant -- use CheckAndSaveDocument instead
-function sendPageMustSave()
+function DocumentHasBeenSaved()
{
- var result = {value:0};
- commonDialogsService.UniversalDialog(
- window,
- null,
- window.editorShell.GetString("SendPage"),
- window.editorShell.GetString("SendPageCaption"),
- null,
- window.editorShell.GetString("Yes"),
- window.editorShell.GetString("No"),
- null,
- null,
- null,
- null,
- {value:0},
- {value:0},
- "chrome://global/skin/question-icon.gif",
- {value:"false"},
- 2,
- 0,
- 0,
- result
- );
-
- if (result.value == 0) // They chose "Yes" -- they'd like to save their document now
- {
- var returned = window.editorShell.saveDocument(false, false);
- if (returned)
- editorSendPage(); // They saved the page, now we can send page :)
+ fileurl = "";
+ try {
+ fileurl = window._content.location;
+ } catch (e) {
+ return false;
}
-}
-*/
-function CheckAndSaveDocument(reasonToSave)
+ if (fileurl == "" || fileurl == "about:blank")
+ return false;
+
+ // We have a file URL already
+ return true;
+}
+
+function CheckAndSaveDocument(reasonToSave, allowDontSave)
{
var document = editorShell.editorDocument;
if (!editorShell.documentModified)
@@ -407,7 +387,7 @@ function CheckAndSaveDocument(reasonToSave)
null,
window.editorShell.GetString("Save"), // Save Button
window.editorShell.GetString("Cancel"), // Cancel Button
- window.editorShell.GetString("DontSave"), // Don't Save Button
+ (allowDontSave ? window.editorShell.GetString("DontSave") : null), // Don't Save Button
null,
null,
null,
@@ -415,7 +395,7 @@ function CheckAndSaveDocument(reasonToSave)
{value:0},
"chrome://global/skin/question-icon.gif",
{value:"false"},
- 3,
+ (allowDontSave ? 3 : 2),
0,
0,
result
@@ -462,7 +442,8 @@ function EditorCanClose()
// Returns FALSE only if user cancels save action
//dump("Calling EditorCanClose\n");
- var canClose = CheckAndSaveDocument(GetString("BeforeClosing"));
+ // "true" means allow "Don't Save" button
+ var canClose = CheckAndSaveDocument(GetString("BeforeClosing"), true);
// This is our only hook into closing via the "X" in the caption
// or "Quit" (or other paths?)
@@ -476,34 +457,6 @@ function EditorCanClose()
// --------------------------- View menu ---------------------------
-function EditorViewSource()
-{
- // Temporary hack: save to a file and call up the source view window
- // using the local file url.
- if (CheckAndSaveDocument(GetString("BeforeViewSource")))
- return;
-
- fileurl = "";
- try {
- fileurl = window._content.location;
- } catch (e) {
- return;
- }
-
- // CheckAndSave doesn't tell us if the user said "Don't Save",
- // so make sure we have a url:
- if (fileurl != "" && fileurl != "about:blank")
- {
- // Use a browser window to view source
- window.openDialog( "chrome://navigator/content/viewSource.xul",
- "_blank",
- "chrome,menubar,status,dialog=no,resizable",
- fileurl,
- "view-source" );
- }
-}
-
-
function EditorSetDocumentCharacterSet(aCharset)
{
if(editorShell)
@@ -822,16 +775,24 @@ function EditorSelectColor(colorType)
// Launch the ColorPicker dialog
// TODO: Figure out how to position this under the color buttons on the toolbar
window.openDialog("chrome://editor/content/EdColorPicker.xul", "_blank", "chrome,close,titlebar,modal", "", gColorObj);
+
+ // User canceled the dialog
+ if (gColorObj.Cancel)
+ return;
+
+ var broadcaster;
if (colorType == "Text")
{
if (currentColor != gColorObj.TextColor)
window.editorShell.SetTextProperty("font", "color", gColorObj.TextColor);
- // Trying to force updating of "state" in command node
- // so next caret move updates color button, but not working!
- //goUpdateCommand("cmd_fontColor");
- SetTextColorButton(gColorObj.TextColor);
+ // Update the broadcaster state (this will trigger color button update)
+ broadcaster = document.getElementById("cmd_fontColor");
+ if (broadcaster)
+ broadcaster.setAttribute("state",gColorObj.TextColor);
+
+ //SetTextColorButton(gColorObj.TextColor);
}
else if (element)
{
@@ -853,9 +814,10 @@ function EditorSelectColor(colorType)
}
else if (currentColor != gColorObj.BackgroundColor)
window.editorShell.SetBackgroundColor(gColorObj.BackgroundColor);
-
-// goUpdateCommand("cmd_backgroundColor");
- SetBackgroundColorButton(gColorObj.BackgroundColor);
+
+ broadcaster = document.getElementById("cmd_backgroundColor");
+ if (broadcaster)
+ broadcaster.setAttribute("state",gColorObj.BackgroundColor);
}
window._content.focus();
}
@@ -909,31 +871,28 @@ function SetEditMode(mode)
if (mode == DisplayModeSource)
{
- // Get the current contents and output into the SourceWindow
- if (bodyNode)
+ // Get the entire document's source string
+ var source = editorShell.GetContentsAs("text/html", 0);
+ if (source.length > 0)
{
- var childCount = bodyNode.childNodes.length;
- if( childCount)
- {
- gSourceContentWindow.setAttribute("value",editorShell.GetContentsAs("text/html", 0)); //gOutputBodyOnly));
- gSourceContentWindow.focus();
- // Note: We can't set the caret location in a multiline textfield
- return;
- }
+ // Don't include anything before "
0)
+ gSourceContentWindow.value = source.slice(headStart);
+ else
+ headStart = source;
+
+ gSourceContentWindow.focus();
}
- // If we fall through, revert to previous node
- SetDisplayMode(PreviousNonSourceDisplayMode);
+ else
+ SetDisplayMode(PreviousNonSourceDisplayMode);
}
else if (previousMode == DisplayModeSource)
{
// We are comming from edit source mode,
// so transfer that back into the document
- //TODO: THIS IS NOT WORKING YET!
editorShell.RebuildDocumentFromSource(gSourceContentWindow.value);
-/*
- editorShell.SelectAll();
- editorShell.InsertSource(gSourceContentWindow.value);
-*/
+
// Clear out the source editor buffer
gSourceContentWindow.value = "";
@@ -1040,6 +999,32 @@ function SetDisplayMode(mode)
window._content.focus();
}
+
+ // We must set check on menu item since toolbar may have been used
+ document.getElementById("viewPreviewMode").setAttribute("checked","false");
+ document.getElementById("viewNormalMode").setAttribute("checked","false");
+ document.getElementById("viewAllTagsMode").setAttribute("checked","false");
+ document.getElementById("viewSourceMode").setAttribute("checked","true");
+
+ var menuID;
+ switch(mode)
+ {
+ case DisplayModePreview:
+ menuID = "viewPreviewMode";
+ break;
+ case DisplayModeNormal:
+ menuID = "viewNormalMode";
+ break;
+ case DisplayModeAllTags:
+ menuID = "viewAllTagsMode";
+ break;
+ case DisplayModeSource:
+ menuID = "viewSourceMode";
+ break;
+ }
+ if (menuID.length > 0)
+ document.getElementById(menuID).setAttribute("checked","true");
+
return true;
}
}
@@ -1048,7 +1033,6 @@ function SetDisplayMode(mode)
function DisableMenusForHTMLSource(disable)
{
// Disable toolbar buttons
- DisableItem("findButton", disable);
DisableItem("spellingButton", disable);
DisableItem("imageButton", disable);
DisableItem("hlineButton", disable);
@@ -1056,6 +1040,10 @@ function DisableMenusForHTMLSource(disable)
DisableItem("linkButton", disable);
DisableItem("namedAnchorButton", disable);
+ // Any toolbar can be toggled on/off except the format toolbar
+ DisableItem("viewFormatToolbar", disable);
+
+
// Top-level menus that we completely hide
CollapseItem("insertMenu", disable);
CollapseItem("formatMenu", disable);
@@ -1073,7 +1061,8 @@ function DisableMenusForHTMLSource(disable)
for (var i = 0; i < children.length; i++)
{
var item = children.item(i);
- if (item.id != "viewNormalMode" &&
+ if (item.id != "viewToolbar" &&
+ item.id != "viewNormalMode" &&
item.id != "viewAllTagsMode" &&
item.id != "viewSourceMode" &&
item.id != "viewPreviewMode" &&
diff --git a/mozilla/editor/ui/composer/content/editorOverlay.xul b/mozilla/editor/ui/composer/content/editorOverlay.xul
index ec80989b9b0..46bfce5aca8 100644
--- a/mozilla/editor/ui/composer/content/editorOverlay.xul
+++ b/mozilla/editor/ui/composer/content/editorOverlay.xul
@@ -148,8 +148,8 @@
-
-
+
+
@@ -309,8 +309,9 @@
-
-
+
+
+
@@ -345,11 +346,10 @@
diff --git a/mozilla/editor/ui/composer/content/pref-composer.xul b/mozilla/editor/ui/composer/content/pref-composer.xul
index ffaf05cb52e..0ced6bdb77e 100644
--- a/mozilla/editor/ui/composer/content/pref-composer.xul
+++ b/mozilla/editor/ui/composer/content/pref-composer.xul
@@ -49,8 +49,7 @@
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/mozilla/editor/ui/composer/locale/en-US/editor.properties b/mozilla/editor/ui/composer/locale/en-US/editor.properties
index 6fa2d1a220f..1a840321672 100644
--- a/mozilla/editor/ui/composer/locale/en-US/editor.properties
+++ b/mozilla/editor/ui/composer/locale/en-US/editor.properties
@@ -38,14 +38,12 @@ Alert=Alert
CantEditFramesetMsg=This editor cannot edit HTML framesets. Try editing the page for each frame separately.
CantEditMimeTypeMsg=This type of page can't be edited.
CantEditDocumentMsg=This page can't be edited for some reason.
-
HTMLFiles=HTML Files
IMGFiles=Image Files
TextFiles=Text Files
AllFiles=All Files
-BeforeClosing= before closing
-BeforeViewSource=in order to view source
-BeforePreview=in order to preview
+BeforeClosing=before closing
+BeforePreview=before previewing in Navigator
# LOCALIZATION NOTE (SaveFilePrompt): Don't translate %title% and %reason% (this is the reason for asking user to close, such as "before closing")
SaveFilePrompt=Save changes to "%title%" %reason%?
SaveFileFailed=Saving file failed!
@@ -91,10 +89,15 @@ untitled=untitled
NoNamedAnchors=(No named anchors in this page)
NoHeadings=(No headings without anchors)
TextColor=Text Color
-PageBackgroundColor=Page Background Color
-TableBackgroundColor=Table Background Color
-CellBackgroundColor=Cell Background Color
+PageColor=Page Background Color
+TableColor=Table Background Color
+CellColor=Cell Background Color
TableOrCellColor=Table or Cell Color
+LinkColor=Link Text Color
+ActiveLinkColor=Active Link Color
+VisitedLinkColor=Visited Link Color
+Color=Color
+NoColorError=Click on a color or enter a valid HTML color string
Table=Table
TableCell=Table Cell
HLine=Horizontal Line
diff --git a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js
index 1f5c4751cdf..550f914575d 100644
--- a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js
+++ b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.js
@@ -106,7 +106,6 @@ function Startup()
**/
function onOK()
{
- dump("in onOK\n")
UpdateObject(); // call UpdateObject fn to update element in document
window.opener.AdvancedEditOK = true;
window.opener.globalElement = element;
@@ -191,7 +190,7 @@ function doRemoveAttribute( which )
switch ( tree.id ) {
case "HTMLATree":
HTMLRAttrs[HTMLRAttrs.length] = TrimString(name.getAttribute("value"));
- dump("HTMLRAttrs[" + (HTMLRAttrs.length - 1) + "]: " + HTMLRAttrs[HTMLRAttrs.length-1] + "\n");
+// dump("HTMLRAttrs[" + (HTMLRAttrs.length - 1) + "]: " + HTMLRAttrs[HTMLRAttrs.length-1] + "\n");
break;
case "CSSATree":
CSSRAttrs[CSSRAttrs.length] = TrimString(name.getAttribute("value"));
diff --git a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul
index 224a11b0022..f3ad0dfd764 100644
--- a/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul
+++ b/mozilla/editor/ui/dialogs/content/EdAdvancedEdit.xul
@@ -102,7 +102,7 @@
-
+
@@ -134,7 +134,7 @@
-
+
@@ -166,7 +166,7 @@
-
+
diff --git a/mozilla/editor/ui/dialogs/content/EdColorPicker.js b/mozilla/editor/ui/dialogs/content/EdColorPicker.js
index 01a6cc40c68..4ca17cf2cba 100644
--- a/mozilla/editor/ui/dialogs/content/EdColorPicker.js
+++ b/mozilla/editor/ui/dialogs/content/EdColorPicker.js
@@ -25,11 +25,14 @@
var insertNew = true;
var tagname = "TAG NAME"
var dialog;
+var color = "";
var LastPickedColor = "";
-var ColorType; // = "Text";
+var ColorType = "Text";
+var TextType = false;
var TableOrCell = false;
var LastPickedIsDefault = true;
-var gLocation;
+var NoDefault = false;
+
// dialog initialization code
function Startup()
@@ -40,6 +43,8 @@ function Startup()
return;
}
+ window.arguments[1].Cancel = false;
+
// Create dialog object to store controls for easy access
dialog = new Object;
@@ -53,34 +58,40 @@ function Startup()
dialog.ColorSwatch = document.getElementById("ColorPickerSwatch");
// The type of color we are setting:
- // Text, or background: Page, Table, or Cell
- ColorType = window.arguments[1].Type;
+ // text: Text, Link, ActiveLink, VisitedLink,
+ // or background: Page, Table, or Cell
+ if (window.arguments[1].Type)
+ {
+ ColorType = window.arguments[1].Type;
+ // Get string for dialog title from passed-in type
+ // (note constraint on editor.properties string name)
+ window.title = GetString(ColorType+"Color");
+ }
+
+ if (!window.title)
+ window.title = GetString("Color");
+
dialog.ColorInput.value = "";
- var color = "";
// window.arguments[1] is object to set initial and return color
switch (ColorType)
{
case "Page":
- window.title = GetString("PageBackgroundColor");
if (window.arguments[1].PageColor)
color = window.arguments[1].PageColor;
break;
case "Table":
- window.title = GetString("TableBackgroundColor");
if (window.arguments[1].TableColor)
color = window.arguments[1].TableColor;
break;
case "Cell":
- window.title = GetString("CellBackgroundColor");
if (window.arguments[1].CellColor)
color = window.arguments[1].CellColor;
break;
case "TableOrCell":
TableOrCell = true;
document.getElementById("TableOrCellGroup").setAttribute("collapsed", "false");
- window.title = GetString("TableOrCellColor");
if (window.arguments[1].TableColor)
{
color = window.arguments[1].TableColor;
@@ -88,14 +99,13 @@ function Startup()
}
else
{
- if (window.arguments[1].CellColor)
- color = window.arguments[1].CellColor;
-
+ color = window.arguments[1].CellColor;
dialog.CellRadio.checked = true;
}
break;
default:
- window.title = GetString("TextColor");
+ // Any other type will change some kind of text,
+ TextType = true;
if (window.arguments[1].TextColor)
color = window.arguments[1].TextColor;
break;
@@ -103,16 +113,14 @@ function Startup()
SetCurrentColor(color)
- if (ColorType == "Text")
+ if (TextType)
LastPickedColor = dialog.LastPickedColor.getAttribute("LastTextColor");
else
LastPickedColor = dialog.LastPickedColor.getAttribute("LastBackgroundColor");
-dump("LastPickedColor = "+LastPickedColor+"|\n");
-
dialog.LastPickedColor.setAttribute("style","background-color: "+LastPickedColor);
- doSetOKCancel(onOK, onCancel);
+ doSetOKCancel(onOK, onCancelColor);
// Set method to detect clicking on OK button
// so we don't get fooled by changing "default" behavior
@@ -120,10 +128,17 @@ dump("LastPickedColor = "+LastPickedColor+"|\n");
// Make the "Last-picked" the default button
// until the user selects a color
-
dialog.Ok.removeAttribute("default");
dialog.LastPickedButton.setAttribute("default","true");
+ // Caller can prevent user from submitting an empty, i.e., default color
+ NoDefault = window.arguments[1].NoDefault;
+ if (NoDefault)
+ {
+ // Hide the "Default button -- user must pick a color
+ document.getElementById("DefaultColorButton").setAttribute("collapsed","true");
+ }
+
SetTextfieldFocus(dialog.ColorInput);
SetWindowLocation();
@@ -162,6 +177,7 @@ function SelectLastPickedColor()
function SetCurrentColor(color)
{
// TODO: Validate color?
+ if(!color) color = "";
dialog.ColorInput.value = color.trimString().toLowerCase();
SetColorSwatch();
}
@@ -198,21 +214,32 @@ function onOKClick()
window.close();
}
-function onOK()
+function ValidateData()
{
- var color;
if (LastPickedIsDefault)
color = LastPickedColor;
else
color = dialog.ColorInput.value;
-
+
color = color.trimString().toLowerCase();
+
// TODO: Validate the color string!
-dump("ColorPicker onOK: color = "+color+"|\n");
+ if (NoDefault && color.length == 0)
+ {
+ ShowInputErrorMessage(GetString("NoColorError"));
+ SetTextfieldFocus(dialog.ColorInput);
+ return false;
+ }
+ return true;
+}
+
+function onOK()
+{
+ if (!ValidateData()) return;
// Set return values and save in persistent color attributes
- if (ColorType == "Text")
+ if (TextType)
{
window.arguments[1].TextColor = color;
if (color.length > 0)
@@ -232,3 +259,11 @@ dump("ColorPicker onOK: color = "+color+"|\n");
return true; // do close the window
}
+
+function onCancelColor()
+{
+ // Tells caller that user canceled
+ window.arguments[1].Cancel = true;
+ SaveWindowLocation();
+ window.close();
+}
\ No newline at end of file
diff --git a/mozilla/editor/ui/dialogs/content/EdColorPicker.xul b/mozilla/editor/ui/dialogs/content/EdColorPicker.xul
index df7efea45ff..44f80ec926b 100644
--- a/mozilla/editor/ui/dialogs/content/EdColorPicker.xul
+++ b/mozilla/editor/ui/dialogs/content/EdColorPicker.xul
@@ -84,7 +84,7 @@
-
diff --git a/mozilla/editor/ui/dialogs/content/EdColorProps.js b/mozilla/editor/ui/dialogs/content/EdColorProps.js
index e5092ae1ee3..82bdc101d90 100644
--- a/mozilla/editor/ui/dialogs/content/EdColorProps.js
+++ b/mozilla/editor/ui/dialogs/content/EdColorProps.js
@@ -28,31 +28,25 @@
When in "Custom Colors" mode, all colors will be set on body tag,
even if they are just default colors, to assure compatable colors in page.
User cannot select "use default" for individual colors
- When in UseDefaultColors mode, the color buttons can be used,
- Instead of disabling using color buttons while in UseDefault mode,
- and we switch to UseCustom mode automatically
- This let's user start with default palette as starting point for
- really setting colors
- (2_13 Can't disable color buttons anyway!)
*/
//Cancel() is in EdDialogCommon.js
var BodyElement;
var prefs;
-var lastSetBackgroundImage;
+var backgroundImage;
// Initialize in case we can't get them from prefs???
var defaultTextColor="#000000";
var defaultLinkColor="#000099";
-var defaultVisitedLinkColor="#990099";
+var defaultActiveColor="#000099";
+var defaultVisitedColor="#990099";
var defaultBackgroundColor="#FFFFFF";
-// Save
var customTextColor;
var customLinkColor;
-var customVisitedColor;
var customActiveColor;
+var customVisitedColor;
var customBackgroundColor;
// Strings we use often
@@ -64,6 +58,7 @@ var alinkStr = "alink";
var bgcolorStr = "bgcolor";
var backgroundStr = "background";
var colorStyle = "color: ";
+var backColorStyle = "background-color: ";
var backImageStyle = " background-image: url(";
// dialog initialization code
@@ -94,7 +89,6 @@ function Startup()
dump("Failed to get BODY element!\n");
window.close();
}
- dump(BodyElement+"\n");
// Set element we will edit
globalElement = BodyElement.cloneNode(false);
@@ -105,14 +99,11 @@ function Startup()
var prefs = GetPrefs();
if (prefs)
{
- dump("Getting browser prefs...\n");
-
// This doesn't necessarily match what appears in the page
// It is complicated by browser.display.use_document_colors
// TODO: WE MUST FORCE WINDOW TO USE DOCUMENT COLORS!!!
// How do we do that without changing browser prefs?
var useDocumentColors = prefs.GetBoolPref("browser.display.use_document_colors");
- dump("browser.display.use_document_colors = "+ useDocumentColors+"\n");
if (useDocumentColors)
{
// How do I get current colors as show in page?
@@ -122,20 +113,14 @@ function Startup()
defaultTextColor = prefs.CopyCharPref("browser.display.foreground_color");
defaultLinkColor = prefs.CopyCharPref("browser.anchor_color");
// Note: Browser doesn't store a value for ActiveLinkColor
- defaultVisitedLinkColor = prefs.CopyCharPref("browser.visited_color");
+ defaultActiveColor = defaultLinkColor;
+ defaultVisitedColor = prefs.CopyCharPref("browser.visited_color");
defaultBackgroundColor= prefs.CopyCharPref("browser.display.background_color");
}
catch (ex) {
dump("Failed getting browser colors from prefs\n");
}
}
- try {
- // Get the last-set background image
- lastSetBackgroundImage = prefs.CopyCharPref("editor.default_background_image");
- }
- catch (ex) {
- dump("Failed getting browser colors from prefs\n");
- }
}
InitDialog();
@@ -149,159 +134,235 @@ function Startup()
function InitDialog()
{
- SetColor("textCW", globalElement.getAttribute(textStr));
- SetColor("linkCW", globalElement.getAttribute(linkStr));
- SetColor("visitedCW", globalElement.getAttribute(vlinkStr));
- SetColor("activeCW", globalElement.getAttribute(alinkStr));
- SetColor("backgroundCW", globalElement.getAttribute(bgcolorStr));
-
- if (dialog.textColor ||
- dialog.linkColor ||
- dialog.visitedLinkColor ||
- dialog.activeLinkColor ||
- dialog.backgroundColor)
+ // Get image from document
+ backgroundImage = globalElement.getAttribute(backgroundStr);
+ if (backgroundImage.length > 0)
{
+ dialog.BackgroundImageInput.value = backgroundImage;
+ dialog.ColorPreview.setAttribute(styleStr, backImageStyle+backgroundImage+");");
+ }
+
+ customTextColor = globalElement.getAttribute(textStr);
+ customLinkColor = globalElement.getAttribute(linkStr);
+ customActiveColor = globalElement.getAttribute(alinkStr);
+ customVisitedColor = globalElement.getAttribute(vlinkStr);
+ customBackgroundColor = globalElement.getAttribute(bgcolorStr);
+
+ if (customTextColor ||
+ customLinkColor ||
+ customVisitedColor ||
+ customActiveColor ||
+ customBackgroundColor)
+ {
+ // Set default color explicitly for any that are missing
+ if (!customTextColor) customTextColor = defaultTextColor;
+ if (!customLinkColor) customLinkColor = defaultLinkColor;
+ if (!customActiveColor) customActiveColor = defaultActiveColor;
+ if (!customVisitedColor) customVisitedColor = defaultVisitedColor;
+ if (!customBackgroundColor) customBackgroundColor = defaultBackgroundColor;
+
// If any colors are set, then check the "Custom" radio button
dialog.CustomColorsRadio.checked = true;
- } else {
- dialog.DefaultColorsRadio.checked = true;
+ UseCustomColors();
}
-
- // Save a copy to use when switching from UseDefault to UseCustom
- SaveCustomColors();
-
- // Get image from document
- dialog.BackgroundImage = globalElement.getAttribute(backgroundStr);
- if (dialog.BackgroundImage)
+ else
{
- dialog.BackgroundImageInput.value = dialog.BackgroundImage;
- dialog.ColorPreview.setAttribute(backgroundStr, dialog.BackgroundImage);
+ dialog.DefaultColorsRadio.checked = true;
+ UseDefaultColors();
}
}
+function GetColorAndUpdate(ColorWellID)
+{
+ // Only allow selecting when in custom mode
+ if (!dialog.CustomColorsRadio.checked) return;
-function SetColor(ColorWellID, color)
+ var colorObj = new Object;
+ var colorWell = document.getElementById(ColorWellID);
+ if (!colorWell) return;
+
+ // Don't allow a blank color, i.e., using the "default"
+ colorObj.NoDefault = true;
+
+ switch( ColorWellID )
+ {
+ case "textCW":
+ colorObj.Type = "Text";
+ colorObj.TextColor = customTextColor;
+ break;
+ case "linkCW":
+ colorObj.Type = "Link";
+ colorObj.TextColor = customLinkColor;
+ break;
+ case "activeCW":
+ colorObj.Type = "ActiveLink";
+ colorObj.TextColor = customActiveColor;
+ break;
+ case "visitedCW":
+ colorObj.Type = "VisitedLink";
+ colorObj.TextColor = customVisitedColor;
+ break;
+ case "backgroundCW":
+ colorObj.Type = "Page";
+ colorObj.PageColor = customBackgroundColor;
+ break;
+ }
+
+ window.openDialog("chrome://editor/content/EdColorPicker.xul", "_blank", "chrome,close,titlebar,modal", "", colorObj);
+
+ // User canceled the dialog
+ if (colorObj.Cancel)
+ return;
+
+ color = "";
+ switch( ColorWellID )
+ {
+ case "textCW":
+ color = customTextColor = colorObj.TextColor;
+ break;
+ case "linkCW":
+ color = customLinkColor = colorObj.TextColor;
+ break;
+ case "activeCW":
+ color = customActiveColor = colorObj.TextColor;
+ break;
+ case "visitedCW":
+ color = customVisitedColor = colorObj.TextColor;
+ break;
+ case "backgroundCW":
+ color = customBackgroundColor = colorObj.BackgroundColor;
+ break;
+ }
+
+ setColorWell(ColorWellID, color);
+ SetColorPreview(ColorWellID, color);
+
+ // Setting a color automatically changes into UseCustomColors mode
+ //dialog.CustomColorsRadio.checked = true;
+}
+
+function SetColorPreview(ColorWellID, color)
{
switch( ColorWellID )
{
case "textCW":
- if (!color) color = defaultTextColor;
- dialog.textColor = color;
dialog.NormalText.setAttribute(styleStr,colorStyle+color);
break;
case "linkCW":
- if (!color) color = defaultLinkColor;
- dialog.linkColor = color;
dialog.LinkText.setAttribute(styleStr,colorStyle+color);
break;
case "activeCW":
- if (!color) color = defaultLinkColor;
- dialog.activeLinkColor = color;
dialog.ActiveLinkText.setAttribute(styleStr,colorStyle+color);
break;
case "visitedCW":
- if (!color) color = defaultVisitedLinkColor;
- dialog.visitedLinkColor = color;
dialog.VisitedLinkText.setAttribute(styleStr,colorStyle+color);
break;
case "backgroundCW":
- if (!color) color = defaultBackgroundColor;
- dialog.backgroundColor = color;
// Must combine background color and image style values
- styleValue = colorStyle+color;
- if (dialog.backgroundImage > 0)
- styleValue += ";"+backImageStyle+backImageStyle+");";
+ styleValue = backColorStyle+color;
+ if (backgroundImage.length > 0)
+ styleValue += ";"+backImageStyle+backgroundImage+");";
dialog.ColorPreview.setAttribute(styleStr,styleValue);
break;
}
- setColorWell(ColorWellID, color);
-}
-
-function GetColorAndUpdate(ColorPickerID, ColorWellID, widget)
-{
- // Close the colorpicker
- widget.parentNode.closePopup();
- SetColor(ColorWellID, getColor(ColorPickerID));
-
- // Setting a color automatically changes into UseCustomColors mode
- dialog.CustomColorsRadio.checked = true;
-}
-
-function SaveCustomColors()
-{
- customTextColor = dialog.textColor;
- customLinkColor = dialog.linkColor;
- customVisitedColor = dialog.visitedLinkColor;
- customActiveColor = dialog.activeLinkColor;
- customBackgroundColor = dialog.backgroundColor;
}
function UseCustomColors()
{
- // Restore from saved colors
- SetColor("textCW", customTextColor);
- SetColor("linkCW", customLinkColor);
- SetColor("activeCW", customActiveColor);
- SetColor("visitedCW", customVisitedColor);
- SetColor("backgroundCW", customBackgroundColor);
+ SetElementEnabledById("TextButton", true);
+ SetElementEnabledById("LinkButton", true);
+ SetElementEnabledById("ActiveLinkButton", true);
+ SetElementEnabledById("VisitedLinkButton", true);
+ SetElementEnabledById("BackgroundButton", true);
+
+ SetColorPreview("textCW", customTextColor);
+ SetColorPreview("linkCW", customLinkColor);
+ SetColorPreview("activeCW", customActiveColor);
+ SetColorPreview("visitedCW", customVisitedColor);
+ SetColorPreview("backgroundCW", customBackgroundColor);
+
+ setColorWell("textCW", customTextColor);
+ setColorWell("linkCW", customLinkColor);
+ setColorWell("activeCW", customActiveColor);
+ setColorWell("visitedCW", customVisitedColor);
+ setColorWell("backgroundCW", customBackgroundColor);
}
function UseDefaultColors()
{
- dump("UseDefaultColors\n");
- // Save colors to use when switching back to UseCustomColors
- SaveCustomColors();
+ SetColorPreview("textCW", defaultTextColor);
+ SetColorPreview("linkCW", defaultLinkColor);
+ SetColorPreview("activeCW", defaultActiveColor);
+ SetColorPreview("visitedCW", defaultVisitedColor);
+ SetColorPreview("backgroundCW", defaultBackgroundColor);
- SetColor("textCW", defaultTextColor);
- SetColor("linkCW", defaultLinkColor);
- SetColor("activeCW", defaultLinkColor); //Browser doesn't store this separately
- SetColor("visitedCW", defaultVisitedLinkColor);
- SetColor("backgroundCW", defaultBackgroundColor);
+ // Setting to blank color will remove color from buttons,
+ setColorWell("textCW", "");
+ setColorWell("linkCW", "");
+ setColorWell("activeCW", "");
+ setColorWell("visitedCW", "");
+ setColorWell("backgroundCW", "");
+
+ // Disable color buttons
+ SetElementEnabledById("TextButton", false);
+ SetElementEnabledById("LinkButton", false);
+ SetElementEnabledById("ActiveLinkButton", false);
+ SetElementEnabledById("VisitedLinkButton", false);
+ SetElementEnabledById("BackgroundButton", false);
}
function chooseFile()
{
- // Get a local file, converted into URL format
+ // Get a local image file, converted into URL format
fileName = GetLocalFileURL("img");
if (fileName && fileName != "")
{
- dialog.BackgroundImage = fileName;
- dialog.BackgroundImageInput.value = fileName;
- dialog.ColorPreview.setAttribute(backgroundStr, fileName);
- // First make a string with just background color
- var styleValue = colorStyle+dialog.backgroundColor+";";
- if (ValidateImage())
- {
- // Append image style
- styleValue += backImageStyle+dialog.BackgroundImage+");";
- }
-dump(styleValue+"=style value when setting image\n")
- // Set style on preview (removes image if not checked or not valid)
- dialog.ColorPreview.setAttribute(styleStr, styleValue);
+ dialog.BackgroundImageInput = filename;
+ ValidateAndPreviewImage(true);
}
-
- // Put focus into the input field
SetTextfieldFocus(dialog.BackgroundImageInput);
}
-function ValidateImage()
+function ChangeBackgroundImage()
{
+ // Don't show error message for image while user is typing
+ ValidateAndPreviewImage(false);
+}
+
+function ValidateAndPreviewImage(ShowErrorMessage)
+{
+ // First make a string with just background color
+ var styleValue = backColorStyle+dialog.backgroundColor+";";
+
var image = dialog.BackgroundImageInput.value.trimString();
- if (image && image != "")
+ if (image.length > 0)
{
if (IsValidImage(image))
{
- dialog.BackgroundImage = image;
- return true;
- } else {
- dialog.BackgroundImage = null;
+ backgroundImage = image;
+ // Append image style
+ styleValue += backImageStyle+backgroundImage+");";
+ }
+ else
+ {
+ backgroundImage = null;
+ if (ShowErrorMessage)
+ {
+ SetTextfieldFocus(dialog.BackgroundImageInput);
+ // Tell user about bad image
+ ShowInputErrorMessage(GetString("MissingImageError"));
+ }
+ return false;
}
}
- SetTextfieldFocus(dialog.BackgroundImageInput);
- ShowInputErrorMessage(GetString("MissingImageError"));
+ else backgroundImage = null;
- return false;
+ // Set style on preview (removes image if not valid)
+ dialog.ColorPreview.setAttribute(styleStr, styleValue);
+
+ // Note that an "empty" string is valid
+ return true;
}
function ValidateData()
@@ -317,21 +378,24 @@ function ValidateData()
}
else
{
- globalElement.setAttribute(textStr, dialog.textColor);
- globalElement.setAttribute(linkStr, dialog.linkColor);
- globalElement.setAttribute(vlinkStr, dialog.visitedLinkColor);
- globalElement.setAttribute(alinkStr, dialog.activeLinkColor);
- globalElement.setAttribute(bgcolorStr, dialog.backgroundColor);
+ globalElement.setAttribute(textStr, customTextColor);
+ globalElement.setAttribute(linkStr, customLinkColor);
+ globalElement.setAttribute(vlinkStr, customVisitedColor);
+ globalElement.setAttribute(alinkStr, customActiveColor);
+ globalElement.setAttribute(bgcolorStr, customBackgroundColor);
}
- if (ValidateImage())
+ if (ValidateAndPreviewImage(true))
{
- globalElement.setAttribute(backgroundStr, dialog.BackgroundImage);
- } else {
- globalElement.removeAttribute(backgroundStr);
- return false;
- }
-
+ // A valid image may be null for no image
+ if (backgroundImage)
+ {
+ globalElement.setAttribute(backgroundStr, backgroundImage);
+ } else {
+ globalElement.removeAttribute(backgroundStr);
+ return false;
+ }
+ }
return true;
}
@@ -339,13 +403,6 @@ function onOK()
{
if (ValidateData())
{
- // Save image for future editing
- if (prefs && dialog.BackgroundImage)
- {
- dump("Saving default background image in prefs\n");
- prefs.SetCharPref("editor.default_background_image", dialog.BackgroundImage);
- }
-
// Copy attributes to element we are changing
editorShell.CloneAttributes(BodyElement, globalElement);
diff --git a/mozilla/editor/ui/dialogs/content/EdColorProps.xul b/mozilla/editor/ui/dialogs/content/EdColorProps.xul
index 8f311987523..7a34630fd29 100644
--- a/mozilla/editor/ui/dialogs/content/EdColorProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdColorProps.xul
@@ -46,103 +46,99 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
-
+
+
+
diff --git a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js
index 510ecc3798e..fd7e1ba8776 100644
--- a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js
+++ b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js
@@ -574,14 +574,6 @@ function onAdvancedEdit()
if (window.AdvancedEditOK) {
// Copy edited attributes to the dialog widgets:
InitDialog();
-/*
-// Use this if we want to close the parent dialog immediately
- if (onOK()) {
- // I'm not sure why, but calling onOK() from JS doesn't trigger closing
- // automatically as it does when you click on the OK button!
- window.close();
- }
-*/
}
}
}
diff --git a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul
index bdd6f5b9361..81b24bd257c 100644
--- a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul
@@ -48,7 +48,7 @@
-
+
@@ -67,7 +67,7 @@
-
+
diff --git a/mozilla/editor/ui/dialogs/content/EdImageMapHotSpot.xul b/mozilla/editor/ui/dialogs/content/EdImageMapHotSpot.xul
index af3f57dfd90..6d5519651b9 100644
--- a/mozilla/editor/ui/dialogs/content/EdImageMapHotSpot.xul
+++ b/mozilla/editor/ui/dialogs/content/EdImageMapHotSpot.xul
@@ -46,7 +46,7 @@
-
+
@@ -71,7 +71,7 @@
-
+
diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.xul b/mozilla/editor/ui/dialogs/content/EdImageProps.xul
index 17be03f9329..7d440624107 100644
--- a/mozilla/editor/ui/dialogs/content/EdImageProps.xul
+++ b/mozilla/editor/ui/dialogs/content/EdImageProps.xul
@@ -54,7 +54,7 @@
-
+
@@ -88,7 +88,9 @@
+
+