From c50b46ff042cca7531abdfdad76ec012fdeff713 Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Tue, 15 Feb 2000 15:54:05 +0000 Subject: [PATCH] Added Page Properties (26889) and Page Colors dialogs (14344), removed debug menu only in release (27237), link dialog fixes (27308), lots of dialog rewrite to use titledbox instead of fieldset, rewrote insert table dialog to use boxes. Changed font size to use CSS strings, not for ui, but other bugs prevented inserting spans for size. Other small bug fixes. r=brade. git-svn-id: svn://10.0.0.236/trunk@60891 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsEditorShell.cpp | 51 +- mozilla/editor/base/nsHTMLEditor.cpp | 33 +- mozilla/editor/composer/src/nsEditorShell.cpp | 51 +- .../editor/libeditor/html/nsHTMLEditor.cpp | 33 +- .../ui/composer/content/EditorCommands.js | 124 +++- .../ui/composer/content/EditorContent.css | 15 +- mozilla/editor/ui/composer/content/editor.xul | 17 - .../ui/composer/content/editorOverlay.xul | 46 +- .../composer/locale/en-US/editor.properties | 8 +- .../composer/locale/en-US/editorOverlay.dtd | 39 +- mozilla/editor/ui/composer/skin/editor.css | 9 +- .../editor/ui/dialogs/content/EdColorProps.js | 306 +++++++- .../ui/dialogs/content/EdColorProps.xul | 98 +-- .../ui/dialogs/content/EdDialogCommon.js | 131 +++- .../ui/dialogs/content/EdDialogOverlay.xul | 7 +- .../editor/ui/dialogs/content/EdHLineProps.js | 12 +- .../ui/dialogs/content/EdHLineProps.xul | 8 +- .../editor/ui/dialogs/content/EdImageProps.js | 60 +- .../ui/dialogs/content/EdImageProps.xul | 12 +- .../ui/dialogs/content/EdInsertTable.js | 4 +- .../ui/dialogs/content/EdInsertTable.xul | 116 ++- .../editor/ui/dialogs/content/EdLinkProps.js | 315 +++++---- .../editor/ui/dialogs/content/EdLinkProps.xul | 62 +- .../ui/dialogs/content/EdNamedAnchorProps.js | 2 +- .../ui/dialogs/content/EdNamedAnchorProps.xul | 30 +- .../editor/ui/dialogs/content/EdPageProps.js | 226 ++++-- .../editor/ui/dialogs/content/EdPageProps.xul | 227 ++---- .../editor/ui/dialogs/content/EdTableProps.js | 119 +++- .../ui/dialogs/content/EdTableProps.xul | 664 +++++++++--------- .../locale/en-US/EditorColorProperties.dtd | 9 +- .../locale/en-US/EditorHLineProperties.dtd | 4 +- .../locale/en-US/EditorImageProperties.dtd | 12 +- .../locale/en-US/EditorInsertTable.dtd | 10 +- .../locale/en-US/EditorLinkProperties.dtd | 9 +- .../locale/en-US/EditorPageProperties.dtd | 25 +- .../locale/en-US/EditorTableProperties.dtd | 5 +- .../editor/ui/dialogs/skin/EditorDialog.css | 67 +- 37 files changed, 1705 insertions(+), 1261 deletions(-) diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index fc03a621b18..d175119281f 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -125,6 +125,7 @@ static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID ); static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID); static NS_DEFINE_CID(kEditorControllerCID, NS_EDITORCONTROLLER_CID); +static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); /* Define Interface IDs */ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -384,10 +385,10 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl) aUrl->GetScheme(&pageScheme); aUrl->GetSpec(&pageURLString); - // only save the file spec if this is a local file, and is not - // about:blank - if (nsCRT::strncmp(pageScheme, "file", 4) == 0 && - nsCRT::strncmp(pageURLString,"about:blank", 11) != 0) + // only save the file spec if this is a local file, and is not + // about:blank + if (nsCRT::strncmp(pageScheme, "file", 4) == 0 && + nsCRT::strncmp(pageURLString,"about:blank", 11) != 0) { nsFileURL pageURL(pageURLString); nsFileSpec pageSpec(pageURL); @@ -422,6 +423,15 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl) // This will be remove for "Browser" mode SetDisplayMode(eDisplayModeEdit); +#ifdef DEBUG + // Activate the debug menu only in debug builds + // by removing the "hidden" attribute set "true" in XUL + nsCOMPtr elem; + rv = xulDoc->GetElementById("debugMenu", getter_AddRefs(elem)); + if (elem) + elem->RemoveAttribute("hidden"); +#endif + // Force initial focus to the content window -- HOW? // mWebShellWin->SetFocus(); return NS_OK; @@ -1247,6 +1257,10 @@ nsEditorShell::CheckAndSaveDocument(const PRUnichar *reasonToSave, PRBool *_retv nsAutoString tmp2 = GetString("DontSave"); nsAutoString title; GetDocumentTitleString(title); + // If title is empty, use "untitled" + if (title.Length() == 0) + title = GetString("untitled"); + nsAutoString saveMsg = ((GetString("SaveFilePrompt")).ReplaceSubstring("%title%",title)).ReplaceSubstring("%reason%",ReasonToSave); EConfirmResult result = ConfirmWithCancel(GetString("SaveDocument"), saveMsg, @@ -1613,6 +1627,9 @@ nsEditorShell::UpdateWindowTitle() nsAutoString windowCaption; res = GetDocumentTitleString(windowCaption); + // If title is empty, use "untitled" + if (windowCaption.Length() == 0) + windowCaption = GetString("untitled"); // Append just the 'leaf' filename to the Doc. Title for the window caption if (NS_SUCCEEDED(res)) @@ -1666,10 +1683,6 @@ nsEditorShell::GetDocumentTitleString(nsString& title) nsCOMPtr HTMLDoc = do_QueryInterface(domDoc); if (HTMLDoc) res = HTMLDoc->GetTitle(title); - - // If title is empty, use "untitled" - if (title.Length() == 0) - title = GetString("untitled"); } return res; } @@ -1745,7 +1758,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) if (titleNode) { - //Delete existing children + //Delete existing children (text) of title node nsCOMPtr children; res = titleNode->GetChildNodes(getter_AddRefs(children)); if(NS_SUCCEEDED(res) && children) @@ -1766,7 +1779,8 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) // Get the node, create a and insert it under the HEAD nsCOMPtr<nsIDOMNodeList> headList; res = domDoc->GetElementsByTagName("head",getter_AddRefs(headList)); - if (NS_SUCCEEDED(res) && headList) + if (NS_FAILED(res)) return res; + if (headList) { headList->Item(0, getter_AddRefs(headNode)); if (headNode) @@ -1785,8 +1799,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) // Note: There should ALWAYS be a <title> in any HTML document, // so we will insert the node and not make it undoable res = headNode->AppendChild(titleNode, getter_AddRefs(resultNode)); - if (NS_FAILED(res)) - return NS_ERROR_FAILURE; + if (NS_FAILED(res)) return res; } // Append a text node under the TITLE // only if the title text isn't empty @@ -1794,13 +1807,10 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) { nsCOMPtr<nsIDOMText> textNode; res = domDoc->CreateTextNode(titleStr, getter_AddRefs(textNode)); - if (NS_SUCCEEDED(res) && textNode) - { - // Go through the editor API so action is undoable - res = editor->InsertNode(textNode, titleNode, 0); - // This is the non-undoable code: - //res = titleNode->AppendChild(textNode,getter_AddRefs(resultNode)); - } + if (NS_FAILED(res)) return res; + if (!textNode) return NS_ERROR_FAILURE; + // Go through the editor API so action is undoable + res = editor->InsertNode(textNode, titleNode, 0); } } } @@ -3440,8 +3450,7 @@ nsEditorShell::GetSelectedOrParentTableElement(PRUnichar **aTagName, PRBool *aIs nsAutoString TagName(*aTagName); if (tableEditor) result = tableEditor->GetSelectedOrParentTableElement(*_retval, TagName, *aIsSelected); - // Need an ugly cast to get around "const" return value - *aTagName = (PRUnichar*)TagName.GetUnicode(); + *aTagName = TagName.ToNewUnicode(); } break; default: diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 31aee7ae82c..d4f8422cab1 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -2781,10 +2781,10 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu if (selectedElement) { // If we already found a node, then we have another element, - // so don't return an element + // thus there's not just one element selected if (bNodeFound) { - //bNodeFound; + bNodeFound = PR_FALSE; break; } @@ -2935,9 +2935,8 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) nsresult res=NS_ERROR_NULL_POINTER; nsCOMPtr<nsIDOMSelection> selection; - // DON'T RETURN EXCEPT AT THE END -- WE NEED TO RELEASE THE aAnchorElement - if (!aAnchorElement) - goto DELETE_ANCHOR; // DON'T USE GOTO IN C++! + if (!aAnchorElement) return NS_ERROR_NULL_POINTER; + // We must have a real selection res = GetSelection(getter_AddRefs(selection)); @@ -2945,8 +2944,8 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) { res = NS_ERROR_NULL_POINTER; } - if (NS_FAILED(res) || !selection) - goto DELETE_ANCHOR; + if (NS_FAILED(res)) return res; + if (!selection) return NS_ERROR_NULL_POINTER; PRBool isCollapsed; res = selection->GetIsCollapsed(&isCollapsed); @@ -2963,8 +2962,9 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) if (anchor) { nsAutoString href; - // XXX: ERROR_HANDLING return code lost - if (NS_SUCCEEDED(anchor->GetHref(href)) && href.GetUnicode() && href.Length() > 0) + res = anchor->GetHref(href); + if (NS_FAILED(res)) return res; + if (href.GetUnicode() && href.Length() > 0) { nsAutoEditBatch beginBatching(this); const nsString attribute("href"); @@ -2975,16 +2975,11 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) } } } -DELETE_ANCHOR: - // We don't insert the element created in CreateElementWithDefaults - // into the document like we do in InsertElement, - // so shouldn't we have to do this here? - // It crashes in JavaScript if we do this! - //NS_RELEASE(aAnchorElement); return res; } -NS_IMETHODIMP nsHTMLEditor::SetBackgroundColor(const nsString& aColor) +NS_IMETHODIMP +nsHTMLEditor::SetBackgroundColor(const nsString& aColor) { NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document"); @@ -7505,7 +7500,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange) // now that we have the list, do the font size change on each node PRUint32 listCount; - PRInt32 j; + PRUint32 j; arrayOfNodes->Count(&listCount); for (j = 0; j < listCount; j++) { @@ -7565,7 +7560,7 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( PRInt32 aSizeChange, PRUint32 textLen; aTextNode->GetLength(&textLen); - if ( aEndOffset != textLen ) + if ( (PRUint32)aEndOffset != textLen ) { // we need to split off back of text node res = SplitNode(node, aEndOffset, getter_AddRefs(tmp)); @@ -7636,7 +7631,7 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange, PRInt32 j; PRUint32 childCount; childNodes->GetLength(&childCount); - for (j=0 ; j<childCount; j++) + for (j=0 ; j < (PRInt32)childCount; j++) { nsCOMPtr<nsIDOMNode> childNode; res = childNodes->Item(j, getter_AddRefs(childNode)); diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index fc03a621b18..d175119281f 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -125,6 +125,7 @@ static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); static NS_DEFINE_CID(kCommonDialogsCID, NS_CommonDialog_CID ); static NS_DEFINE_CID(kDialogParamBlockCID, NS_DialogParamBlock_CID); static NS_DEFINE_CID(kEditorControllerCID, NS_EDITORCONTROLLER_CID); +static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); /* Define Interface IDs */ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -384,10 +385,10 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl) aUrl->GetScheme(&pageScheme); aUrl->GetSpec(&pageURLString); - // only save the file spec if this is a local file, and is not - // about:blank - if (nsCRT::strncmp(pageScheme, "file", 4) == 0 && - nsCRT::strncmp(pageURLString,"about:blank", 11) != 0) + // only save the file spec if this is a local file, and is not + // about:blank + if (nsCRT::strncmp(pageScheme, "file", 4) == 0 && + nsCRT::strncmp(pageURLString,"about:blank", 11) != 0) { nsFileURL pageURL(pageURLString); nsFileSpec pageSpec(pageURL); @@ -422,6 +423,15 @@ nsEditorShell::PrepareDocumentForEditing(nsIURI *aUrl) // This will be remove for "Browser" mode SetDisplayMode(eDisplayModeEdit); +#ifdef DEBUG + // Activate the debug menu only in debug builds + // by removing the "hidden" attribute set "true" in XUL + nsCOMPtr<nsIDOMElement> elem; + rv = xulDoc->GetElementById("debugMenu", getter_AddRefs(elem)); + if (elem) + elem->RemoveAttribute("hidden"); +#endif + // Force initial focus to the content window -- HOW? // mWebShellWin->SetFocus(); return NS_OK; @@ -1247,6 +1257,10 @@ nsEditorShell::CheckAndSaveDocument(const PRUnichar *reasonToSave, PRBool *_retv nsAutoString tmp2 = GetString("DontSave"); nsAutoString title; GetDocumentTitleString(title); + // If title is empty, use "untitled" + if (title.Length() == 0) + title = GetString("untitled"); + nsAutoString saveMsg = ((GetString("SaveFilePrompt")).ReplaceSubstring("%title%",title)).ReplaceSubstring("%reason%",ReasonToSave); EConfirmResult result = ConfirmWithCancel(GetString("SaveDocument"), saveMsg, @@ -1613,6 +1627,9 @@ nsEditorShell::UpdateWindowTitle() nsAutoString windowCaption; res = GetDocumentTitleString(windowCaption); + // If title is empty, use "untitled" + if (windowCaption.Length() == 0) + windowCaption = GetString("untitled"); // Append just the 'leaf' filename to the Doc. Title for the window caption if (NS_SUCCEEDED(res)) @@ -1666,10 +1683,6 @@ nsEditorShell::GetDocumentTitleString(nsString& title) nsCOMPtr<nsIDOMHTMLDocument> HTMLDoc = do_QueryInterface(domDoc); if (HTMLDoc) res = HTMLDoc->GetTitle(title); - - // If title is empty, use "untitled" - if (title.Length() == 0) - title = GetString("untitled"); } return res; } @@ -1745,7 +1758,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) if (titleNode) { - //Delete existing children + //Delete existing children (text) of title node nsCOMPtr<nsIDOMNodeList> children; res = titleNode->GetChildNodes(getter_AddRefs(children)); if(NS_SUCCEEDED(res) && children) @@ -1766,7 +1779,8 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) // Get the <HEAD> node, create a <TITLE> and insert it under the HEAD nsCOMPtr<nsIDOMNodeList> headList; res = domDoc->GetElementsByTagName("head",getter_AddRefs(headList)); - if (NS_SUCCEEDED(res) && headList) + if (NS_FAILED(res)) return res; + if (headList) { headList->Item(0, getter_AddRefs(headNode)); if (headNode) @@ -1785,8 +1799,7 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) // Note: There should ALWAYS be a <title> in any HTML document, // so we will insert the node and not make it undoable res = headNode->AppendChild(titleNode, getter_AddRefs(resultNode)); - if (NS_FAILED(res)) - return NS_ERROR_FAILURE; + if (NS_FAILED(res)) return res; } // Append a text node under the TITLE // only if the title text isn't empty @@ -1794,13 +1807,10 @@ nsEditorShell::SetDocumentTitle(const PRUnichar *title) { nsCOMPtr<nsIDOMText> textNode; res = domDoc->CreateTextNode(titleStr, getter_AddRefs(textNode)); - if (NS_SUCCEEDED(res) && textNode) - { - // Go through the editor API so action is undoable - res = editor->InsertNode(textNode, titleNode, 0); - // This is the non-undoable code: - //res = titleNode->AppendChild(textNode,getter_AddRefs(resultNode)); - } + if (NS_FAILED(res)) return res; + if (!textNode) return NS_ERROR_FAILURE; + // Go through the editor API so action is undoable + res = editor->InsertNode(textNode, titleNode, 0); } } } @@ -3440,8 +3450,7 @@ nsEditorShell::GetSelectedOrParentTableElement(PRUnichar **aTagName, PRBool *aIs nsAutoString TagName(*aTagName); if (tableEditor) result = tableEditor->GetSelectedOrParentTableElement(*_retval, TagName, *aIsSelected); - // Need an ugly cast to get around "const" return value - *aTagName = (PRUnichar*)TagName.GetUnicode(); + *aTagName = TagName.ToNewUnicode(); } break; default: diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 31aee7ae82c..d4f8422cab1 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -2781,10 +2781,10 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu if (selectedElement) { // If we already found a node, then we have another element, - // so don't return an element + // thus there's not just one element selected if (bNodeFound) { - //bNodeFound; + bNodeFound = PR_FALSE; break; } @@ -2935,9 +2935,8 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) nsresult res=NS_ERROR_NULL_POINTER; nsCOMPtr<nsIDOMSelection> selection; - // DON'T RETURN EXCEPT AT THE END -- WE NEED TO RELEASE THE aAnchorElement - if (!aAnchorElement) - goto DELETE_ANCHOR; // DON'T USE GOTO IN C++! + if (!aAnchorElement) return NS_ERROR_NULL_POINTER; + // We must have a real selection res = GetSelection(getter_AddRefs(selection)); @@ -2945,8 +2944,8 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) { res = NS_ERROR_NULL_POINTER; } - if (NS_FAILED(res) || !selection) - goto DELETE_ANCHOR; + if (NS_FAILED(res)) return res; + if (!selection) return NS_ERROR_NULL_POINTER; PRBool isCollapsed; res = selection->GetIsCollapsed(&isCollapsed); @@ -2963,8 +2962,9 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) if (anchor) { nsAutoString href; - // XXX: ERROR_HANDLING return code lost - if (NS_SUCCEEDED(anchor->GetHref(href)) && href.GetUnicode() && href.Length() > 0) + res = anchor->GetHref(href); + if (NS_FAILED(res)) return res; + if (href.GetUnicode() && href.Length() > 0) { nsAutoEditBatch beginBatching(this); const nsString attribute("href"); @@ -2975,16 +2975,11 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) } } } -DELETE_ANCHOR: - // We don't insert the element created in CreateElementWithDefaults - // into the document like we do in InsertElement, - // so shouldn't we have to do this here? - // It crashes in JavaScript if we do this! - //NS_RELEASE(aAnchorElement); return res; } -NS_IMETHODIMP nsHTMLEditor::SetBackgroundColor(const nsString& aColor) +NS_IMETHODIMP +nsHTMLEditor::SetBackgroundColor(const nsString& aColor) { NS_PRECONDITION(mDocWeak, "Missing Editor DOM Document"); @@ -7505,7 +7500,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange) // now that we have the list, do the font size change on each node PRUint32 listCount; - PRInt32 j; + PRUint32 j; arrayOfNodes->Count(&listCount); for (j = 0; j < listCount; j++) { @@ -7565,7 +7560,7 @@ nsHTMLEditor::RelativeFontChangeOnTextNode( PRInt32 aSizeChange, PRUint32 textLen; aTextNode->GetLength(&textLen); - if ( aEndOffset != textLen ) + if ( (PRUint32)aEndOffset != textLen ) { // we need to split off back of text node res = SplitNode(node, aEndOffset, getter_AddRefs(tmp)); @@ -7636,7 +7631,7 @@ nsHTMLEditor::RelativeFontChangeOnNode( PRInt32 aSizeChange, PRInt32 j; PRUint32 childCount; childNodes->GetLength(&childCount); - for (j=0 ; j<childCount; j++) + for (j=0 ; j < (PRInt32)childCount; j++) { nsCOMPtr<nsIDOMNode> childNode; res = childNodes->Item(j, getter_AddRefs(childNode)); diff --git a/mozilla/editor/ui/composer/content/EditorCommands.js b/mozilla/editor/ui/composer/content/EditorCommands.js index 6754b0de1c8..04128973e90 100644 --- a/mozilla/editor/ui/composer/content/EditorCommands.js +++ b/mozilla/editor/ui/composer/content/EditorCommands.js @@ -34,7 +34,7 @@ var WebCompose = false; // Set true for Web Composer, leave false for Messen // These must be kept in synch with the XUL <options> lists var gParagraphTagNames = new Array("","P","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","ADDRESS","PRE","DT","DD"); var gFontFaceNames = new Array("","tt","Arial, Helvetica","Times","Courier"); -var gFontSizeNames = new Array("-2","-1","0","+1","+2","+3","+4"); +var gFontSizeNames = new Array("xx-small","x-small","small","medium","large","x-large","xx-large"); var gStyleTags = { "bold" : "b", @@ -629,14 +629,47 @@ function onFontSizeChange() function EditorSetFontSize(size) { if( size == "0" || size == "normal" || - size == "+0" ) + size == "medium" ) { editorShell.RemoveTextProperty("font", size); dump("Removing font size\n"); } else { dump("Setting font size\n"); + // Temp: convert from new CSS size strings to old HTML size strings + switch (size) + { + case "xx-small": + case "x-small": + size = "-2"; + break; + case "small": + size = "-1"; + break; + case "large": + size = "+1"; + break; + case "x-large": + size = "+2"; + break; + case "xx-large": + size = "+3"; + break; + } editorShell.SetTextProperty("font", "size", size); } +/* + BIG BUG! Setting <span> tag is totally horked -- stick with <font size> for beta1 + { + // XXX-THIS IS DEFINITELY WRONG! + // We need to parse the style tag to set/remove only the "font-size" + // TODO: We need a general SetInlineStyle(), RemoveInlineStyle() interface + editorShell.RemoveTextProperty("span", "style"); + dump("Removing font size\n"); + } else { + dump("Setting font size to: "+size+"\n"); + editorShell.SetTextProperty("span", "style", "font-size:"+size); + } +*/ contentWindow.focus(); } @@ -739,9 +772,20 @@ function EditorRemoveLinks() object-specific "Properties..." item */ -function EditorObjectProperties() +// For property dialogs, we want the selected element, +// but will accept a parent table cell if inside one +function GetSelectedElementOrParentCell() { var element = editorShell.GetSelectedElement(""); + if (!element) + element = editorShell.GetElementOrParentByTagName("td",null); + + return element; +} + +function EditorObjectProperties() +{ + var element = GetSelectedElementOrParentCell(); dump("EditorObjectProperties: element="+element+"\n"); if (element) { @@ -757,6 +801,9 @@ function EditorObjectProperties() case 'TABLE': EditorInsertOrEditTable(false); break; + case 'TD': + EditorTableCellProperties(); + break; case 'A': if(element.href) EditorInsertOrEditLink(); @@ -1054,9 +1101,30 @@ function CheckSpelling() contentWindow.focus(); } +function InitBackColorPopup() +{ + var caption = document.getElementById("BackColorCaption"); + if (caption) + { + var captionStr; + var isSelectedObj = new Object(); + var tagNameObj = new Object(); + var element = editorShell.GetSelectedOrParentTableElement(tagNameObj, isSelectedObj); + + if (tagNameObj.value == "table") + captionStr = editorShell.GetString("TableBackColor"); + else if (tagNameObj.value == "td") + captionStr = editorShell.GetString("CellBackColor"); + else + captionStr = editorShell.GetString("PageBackColor"); + + caption.setAttribute("value",captionStr); + } +} + function EditorInitEditMenu() { - + // We will be modifying the Paste menuitem in the future } function EditorInitFormatMenu() @@ -1064,8 +1132,7 @@ function EditorInitFormatMenu() var propertiesMenu = document.getElementById("objectProperties"); if (propertiesMenu) { - var element = editorShell.GetSelectedElement(""); - dump("EditorObjectProperties: element="+element+"\n"); + var element = GetSelectedElementOrParentCell(); if (element) { dump("TagName="+element.nodeName+"\n"); @@ -1077,22 +1144,25 @@ function EditorInitFormatMenu() switch (element.nodeName) { case 'IMG': - objStr = "Image"; + objStr = editorShell.GetString("Image"); break; case 'HR': - objStr = "H.Line"; + objStr = editorShell.GetString("HLine"); break; case 'TABLE': - objStr = "Table"; + objStr = editorShell.GetString("Table"); + break; + case 'TD': + objStr = editorShell.GetString("TableCell"); break; case 'A': if(element.href) { - objStr = "Link"; + objStr = editorShell.GetString("Link"); EditorInsertOrEditLink(); } else if (element.name) { - objStr = "Named Anchor"; + objStr = editorShell.GetString("NamedAnchor"); EditorInsertOrEditNamedAnchor(); } break; @@ -1100,32 +1170,16 @@ function EditorInitFormatMenu() menuStr = menuStr.replace(/%obj%/,objStr); propertiesMenu.setAttribute("value", menuStr) } else { + // No element to set properties on - hide menu item propertiesMenu.setAttribute("hidden","true"); } } } - dump("Calling EditorInitViewMenu()\n"); } function EditorInitToolbars() { - // Set title edit field - var domdoc; - try { domdoc = window.editorShell.editorDocument; } catch (e) { dump( e + "\n"); } - if ( !domdoc ) - { - dump("EditorInitToolbars: EDITOR DOCUMENT NOT FOUND\n"); - return; - } - var title = domdoc.title; - var titleInput = document.getElementById("PageTitleInput"); - if (!title) title = ""; - titleInput.setAttribute("value", title); - - var authorInput = document.getElementById("AuthorInput"); - if (authorInput) - { - } + // Nothing to do now, but we might want some state updating here } function EditorSetDefaultPrefs() @@ -1445,13 +1499,23 @@ function EditorInsertOrEditTable(insertAllowed) // Edit properties of existing table dump("Existing table found ... Editing its properties\n"); - window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", ""); + window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "","TablePanel"); contentWindow.focus(); } else if(insertAllowed) { EditorInsertTable(); } } +function EditorTableCellProperties() +{ + var cell = editorShell.GetElementOrParentByTagName("td", null); + if (cell) { + // Start Table Properties dialog on the "Cell" panel + window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "", "CellPanel"); + contentWindow.focus(); + } +} + function EditorSelectTableCell() { editorShell.SelectTableCell(); diff --git a/mozilla/editor/ui/composer/content/EditorContent.css b/mozilla/editor/ui/composer/content/EditorContent.css index 39af87706ce..ed2feecf158 100644 --- a/mozilla/editor/ui/composer/content/EditorContent.css +++ b/mozilla/editor/ui/composer/content/EditorContent.css @@ -28,24 +28,27 @@ */ a[name] { + margin-left: 2px; /* TEMPORARY TO COMPENSATE FOR BUG */ - padding-left: 16px; + padding-left: 13px; background: url(chrome://editor/skin/images/anchor-in-doc.gif) no-repeat; - background-position: center center; + background-position: center left; } div { + margin-left: 2px; /* TEMPORARY TO COMPENSATE FOR BUG */ - padding-left: 16px; + padding-left: 13px; background: url(chrome://editor/skin/images/div.gif) no-repeat; -/* background-position: center center; */ + background-position: center left; } span { + margin-left: 2px; /* TEMPORARY TO COMPENSATE FOR BUG */ - padding-left: 16px; + padding-left: 13px; background: url(chrome://editor/skin/images/span.gif) no-repeat; -/* background-position: center center; */ + background-position: center left; } table { diff --git a/mozilla/editor/ui/composer/content/editor.xul b/mozilla/editor/ui/composer/content/editor.xul index 8857331c718..e173cfb05c6 100644 --- a/mozilla/editor/ui/composer/content/editor.xul +++ b/mozilla/editor/ui/composer/content/editor.xul @@ -81,7 +81,6 @@ <menupopup id="menu_View_Popup"> <menu id="viewToolbar"/> <menuseparator/> - <!-- item with "disable=true" will be hidden --> <menuitem id="ShowExtraMarkup" value="&showExtraMarkup.label;" accesskey="&extraMarkup.accesskey;" oncommand="EditorSetDisplayStyle(0)" hidden="true"/> <menuitem id="HideExtraMarkup" value="&hideExtraMarkup.label;" accesskey="&extraMarkup.accesskey;" oncommand="EditorSetDisplayStyle(1)"/> <menuitem id="viewSourceMenuitem"/> @@ -145,22 +144,6 @@ </titledbutton> </box> </toolbar> - - <toolbar id="TitleToolbar" persist="collapsed"> - <box align="vertical"> - <spring flex="1"/> - <html:label>Title:</html:label> - <spring flex="1"/> - </box> - <html:input type="text" id="PageTitleInput" flex="70%"/> - <box align="vertical"> - <spring flex="3"/> - <html:label>Author:</html:label> - <spring flex="2"/> - </box> - <html:input type="text" id="PageAuthorInput" flex="30%"/> - <spring class="spacer-throbber" flex="5%"/> - </toolbar> <toolbar id="FormatToolbar" persist="collapsed"> <html:div> <!-- items are filled out from editorOverlay --> diff --git a/mozilla/editor/ui/composer/content/editorOverlay.xul b/mozilla/editor/ui/composer/content/editorOverlay.xul index 744e1474e57..e61a0461de3 100644 --- a/mozilla/editor/ui/composer/content/editorOverlay.xul +++ b/mozilla/editor/ui/composer/content/editorOverlay.xul @@ -72,8 +72,8 @@ <key id="outdentkb" xulkey="true" key="&formatoutdent.keybinding;" onkeypress="EditorIndent('outdent')" /> <key id="removestyleskb" shift="true" xulkey="true" key="&formatremovestyles.keybinding;" onkeypress="EditorRemoveStyle('all')" /> - <key id="decreasefontsizekb" shift="true" xulkey="true" key="&decreaseFontSize.keybinding;" onkeypress="DecreaseFontSize()" /> - <key id="increasefontsizekb" shift="true" xulkey="true" key="&increaseFontSize.keybinding;" onkeypress="IncreaseFontSize()" /> + <key id="decreasefontsizekb" shift="true" xulkey="true" key="&decreaseFontSize.keybinding;" onkeypress="EditorDecreaseFontSize()" /> + <key id="increasefontsizekb" shift="true" xulkey="true" key="&increaseFontSize.keybinding;" onkeypress="EditorIncreaseFontSize()" /> <!-- how to handle return, enter, tab, function keys, arrow keys, others? saari working on solution --> <!-- scroll document/page/line and move caret --> @@ -379,13 +379,16 @@ accesskey="&formatsizemenu.accesskey;" position="2"> <menupopup> - <menuitem value="&size-2Cmd.label;" accesskey="&size-2.accesskey;" oncommand="EditorSetFontSize('-2')"/> - <menuitem value="&size-1Cmd.label;" accesskey="&size-1.accesskey;" oncommand="EditorSetFontSize('-1')"/> - <menuitem value="&size0Cmd.label;" accesskey="&size0.accesskey;" oncommand="EditorSetFontSize('0')"/> - <menuitem value="&size1Cmd.label;" accesskey="&size1.accesskey;" oncommand="EditorSetFontSize('+1')"/> - <menuitem value="&size2Cmd.label;" accesskey="&size2.accesskey;" oncommand="EditorSetFontSize('+2')"/> - <menuitem value="&size3Cmd.label;" accesskey="&size3.accesskey;" oncommand="EditorSetFontSize('+3')"/> - <menuitem value="&size4Cmd.label;" accesskey="&size4.accesskey;" oncommand="EditorSetFontSize('+4')"/> + <menuitem value="&decreaseFontSize.label;" accesskey="&decreasefontsize.accesskey;" oncommand="EditorDecreaseFontSize()"/> + <menuitem value="&increaseFontSize.label;" accesskey="&increasefontsize.accesskey;" oncommand="EditorIncreaseFontSize()"/> + <menuseparator/> + <menuitem value="&size-xx-smallCmd.label;" accesskey="&size-xx-small.accesskey;" oncommand="EditorSetFontSize('xx-small')"/> + <menuitem value="&size-x-smallCmd.label;" accesskey="&size-x-small.accesskey;" oncommand="EditorSetFontSize('x-small')"/> + <menuitem value="&size-smallCmd.label;" accesskey="&size-small.accesskey;" oncommand="EditorSetFontSize('small')"/> + <menuitem value="&size-mediumCmd.label;" accesskey="&size-medium.accesskey;" oncommand="EditorSetFontSize('medium')"/> + <menuitem value="&size-largeCmd.label;" accesskey="&size-large.accesskey;" oncommand="EditorSetFontSize('large')"/> + <menuitem value="&size-x-largeCmd.label;" accesskey="&size-x-large.accesskey;" oncommand="EditorSetFontSize('x-large')"/> + <menuitem value="&size-xx-largeCmd.label;" accesskey="&size-xx-large.accesskey;" oncommand="EditorSetFontSize('xx-large')"/> </menupopup> </menu> @@ -400,7 +403,6 @@ <menuitem value="&styleStrikeThruCmd.label;" accesskey="&stylestrikethru.accesskey;" oncommand="EditorApplyStyle('strike')"/> <menuitem value="&styleSuperscriptCmd.label;" accesskey="&stylesuperscript.accesskey;" oncommand="EditorApplyStyle('sup')"/> <menuitem value="&styleSubscriptCmd.label;" accesskey="&stylesubscript.accesskey;" oncommand="EditorApplyStyle('sub')"/> - <menuitem value="&styleBlinkCmd.label;" accesskey="&styleblink.accesskey;" oncommand="EditorApplyStyle('blink')"/> <menuitem value="&styleNonbreakingCmd.label;" accesskey="&stylenonbreaking.accesskey;" oncommand="EditorApplyStyle('nobr')"/> </menupopup> </menu> @@ -580,16 +582,16 @@ </menu> <popup id="TextColorPopup" popupanchor="bottomleft"> - <html:div id="TextColorCaption" class="color-caption" align="center">&textColorCaption.label;</html:div> + <titledbutton id="TextColorCaption" class="color-caption" value="&textColorCaption.label;" flex="1"/> <!-- TODO: Add "Last color picked" button and text --> <colorpicker id="TextColorPicker" palettename="standard" onclick="EditorSelectTextColor('TextColorPicker','TextColorPopupButton'); parentNode.closePopup();"/> <titledbutton class="push" value="&formatToolbar.colorPicker.default.label;" onclick="EditorRemoveTextColor('TextColorPopupButton'); parentNode.closePopup();"/> </popup> - <popup id="BackColorPopup" popupanchor="bottomleft"> - <!-- Text Caption is filled in at runtime --> + <popup id="BackColorPopup" popupanchor="bottomleft" oncreate="InitBackColorPopup()"> + <!-- Text is filled in at runtime according to what background element will be set --> + <titledbutton id="BackColorCaption" class="color-caption" value="Background Color" flex="1"/> <!-- TODO: Add "Last color picked" button and text --> - <html:div id="BackColorCaption" class="color-caption" align="center">Background Color</html:div> <colorpicker id="BackColorPicker" palettename="standard" onclick="EditorSelectBackColor('BackColorPicker','BackColorPopupButton'); parentNode.closePopup();"/> <titledbutton class="push" value="&formatToolbar.colorPicker.default.label;" onclick="EditorRemoveBackColor('BackColorPopupButton'); parentNode.closePopup();"/> </popup> @@ -674,13 +676,13 @@ <html:select class="toolbar" id="FontSizeSelect" size="1" onchange="EditorSelectFontSize()"> <observes element="Editor:Font:Size" attribute="fontsize" onbroadcast="onFontSizeChange()"/> - <html:option>&size-2Cmd.label;</html:option> - <html:option>&size-1Cmd.label;</html:option> - <html:option>&size0Cmd.label;</html:option> - <html:option>&size1Cmd.label;</html:option> - <html:option>&size2Cmd.label;</html:option> - <html:option>&size3Cmd.label;</html:option> - <html:option>&size4Cmd.label;</html:option> + <html:option>&size-xx-smallCmd.label;</html:option> + <html:option>&size-x-smallCmd.label;</html:option> + <html:option>&size-smallCmd.label;</html:option> + <html:option>&size-mediumCmd.label;</html:option> + <html:option>&size-largeCmd.label;</html:option> + <html:option>&size-x-largeCmd.label;</html:option> + <html:option>&size-xx-largeCmd.label;</html:option> </html:select> <!-- The new Color Picker UI --> @@ -719,7 +721,7 @@ <!-- DEBUG only --> - <menu id="debugMenu" value="&debugMenu.label;"> + <menu id="debugMenu" value="&debugMenu.label;" hidden="true"> <menupopup> <menuitem value="&newEditorTestPage.label;" oncommand="window.openDialog('chrome://editor/content','_blank','chrome,all,dialog=no','chrome://editor/content/EditorInitPage.html')"/> <menuitem value="&textEditorCmd.label;" oncommand="EditorNewPlaintext();" /> diff --git a/mozilla/editor/ui/composer/locale/en-US/editor.properties b/mozilla/editor/ui/composer/locale/en-US/editor.properties index d8ff8b4e4eb..83d81f07a07 100644 --- a/mozilla/editor/ui/composer/locale/en-US/editor.properties +++ b/mozilla/editor/ui/composer/locale/en-US/editor.properties @@ -24,7 +24,6 @@ OpenHTMLFile=Open HTML File SelectImageFile=Select Image File SaveDocument=Save Document SaveDocumentAs=Save Document As -LinkImage=Link Image: EditMode=Edit Mode Preview=Preview CorrectSpelling=(correct spelling) @@ -44,9 +43,11 @@ SaveFileFailed=Saving file failed! DocumentTitle=Document Title NeedDocTitle=Enter a title for the current page. The title identifies the page in the window title and bookmarks. AttributesFor=Current attributes for: -MissingImageError=Please enter or choose an image of type gif, jpg or png. +MissingImageError=Please enter or choose an image of type gif, jpg, or png. EmptyHREFError=You must enter or choose a location (URL) to create a new link. LinkText=Link text: +LinkImage=Link image: +MixedSelection=[Mixed selection] EnterLinkText=Enter text to display for the link: EmptyLinkTextError=You must enter some text for this link. #Don't translate: %n% %min% %max% @@ -73,8 +74,9 @@ untitled=untitled NoNamedAnchors=(No named anchors in this page) NoHeadings=(No headings without anchors) PageBackColor=Page Background Color -CallBackColor=Cell Background Color +CellBackColor=Cell Background Color TableBackColor=Table Background Color +LastPickedColor=Last picked color Table=Table TableCell=Table Cell HLine=H.Line diff --git a/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd b/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd index be9d4c9ac50..80cfd714913 100644 --- a/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd +++ b/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd @@ -259,24 +259,29 @@ <!ENTITY fontcourier.accesskey "c"> <!-- Font Size SubMenu --> +<!ENTITY decreaseFontSize.label "Decrease"> +<!ENTITY decreasefontsize.accesskey "d"> +<!ENTITY decreaseFontSize.keybinding "["> +<!ENTITY increaseFontSize.label "Increase"> +<!ENTITY increasefontsize.accesskey "i"> +<!ENTITY increaseFontSize.keybinding "]"> + <!ENTITY fontsizeMenu.label "Size"> <!ENTITY formatsizemenu.accesskey "s"> -<!ENTITY size-2Cmd.label " -2"> -<!ENTITY size-2.accesskey "-"> -<!ENTITY size-1Cmd.label " -1"> -<!ENTITY size-1.accesskey "s"> -<!ENTITY size0Cmd.label " 0"> -<!ENTITY size0.accesskey "n"> -<!ENTITY size1Cmd.label " +1"> -<!ENTITY size1.accesskey "1"> -<!ENTITY size2Cmd.label " +2"> -<!ENTITY size2.accesskey "2"> -<!ENTITY size3Cmd.label " +3"> -<!ENTITY size3.accesskey "3"> -<!ENTITY size4Cmd.label " +4"> -<!ENTITY size4.accesskey "4"> -<!ENTITY increaseFontSize.keybinding "]"> -<!ENTITY decreaseFontSize.keybinding "["> +<!ENTITY size-xx-smallCmd.label "xx-small"> +<!ENTITY size-xx-small.accesskey "a"> +<!ENTITY size-x-smallCmd.label "x-small"> +<!ENTITY size-x-small.accesskey "m"> +<!ENTITY size-smallCmd.label "small"> +<!ENTITY size-small.accesskey "s"> +<!ENTITY size-mediumCmd.label "medium"> +<!ENTITY size-medium.accesskey "m"> +<!ENTITY size-largeCmd.label "large"> +<!ENTITY size-large.accesskey "l"> +<!ENTITY size-x-largeCmd.label "x-large"> +<!ENTITY size-x-large.accesskey "r"> +<!ENTITY size-xx-largeCmd.label "xx-large"> +<!ENTITY size-xx-large.accesskey "e"> <!-- Font Style SubMenu --> <!ENTITY fontStyleMenu.label "Style"> @@ -296,8 +301,6 @@ <!ENTITY stylesuperscript.accesskey "p"> <!ENTITY styleSubscriptCmd.label "Subscript"> <!ENTITY stylesubscript.accesskey "s"> -<!ENTITY styleBlinkCmd.label "Blink"> -<!ENTITY styleblink.accesskey "l"> <!ENTITY styleNonbreakingCmd.label "Nonbreaking"> <!ENTITY stylenonbreaking.accesskey "n"> diff --git a/mozilla/editor/ui/composer/skin/editor.css b/mozilla/editor/ui/composer/skin/editor.css index 10ddd1c744c..8ac76308936 100644 --- a/mozilla/editor/ui/composer/skin/editor.css +++ b/mozilla/editor/ui/composer/skin/editor.css @@ -33,7 +33,7 @@ toolbox#EditorToolbox { min-width: 1px; } -toolbar#FormatToolbar, toolbar#TitleToolbar { +toolbar#FormatToolbar { border-bottom: 1px solid #003366; } @@ -167,11 +167,6 @@ box#DisplayModeBar div.VerticalSeparator { margin: 1px 0px; } -/* SHOULD BE IN GLOBAL.CSS */ -menuitem[hidden="true"] { - visibility: collapse; -} - spring.spacer3 { width: 3px; height: 3px; @@ -294,7 +289,7 @@ titledbutton#InsertPopupButton { list-style-image:url("chrome://editor/skin/images/object-popup.gif"); } -div.color-caption { +text.color-caption { border: 1px inset white; } diff --git a/mozilla/editor/ui/dialogs/content/EdColorProps.js b/mozilla/editor/ui/dialogs/content/EdColorProps.js index fcf888f5c68..429622319a1 100644 --- a/mozilla/editor/ui/dialogs/content/EdColorProps.js +++ b/mozilla/editor/ui/dialogs/content/EdColorProps.js @@ -20,7 +20,51 @@ * Contributor(s): */ +/* + Behavior notes: + Radio buttons select "UseDefaultColors" vs. "UseCustomColors" modes. + If any color attribute is set in the body, mode is "Custom Colors", + even if 1 or more (but not all) are actually null (= "use default") + 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; + +// Initialize in case we can't get them from prefs??? +var defaultTextColor="#000000"; +var defaultLinkColor="#000099"; +var defaultVisitedLinkColor="#990099"; +var defaultBackgroundColor="#FFFFFF"; + +// Save +var customTextColor; +var customLinkColor; +var customVisitedColor; +var customActiveColor; +var customBackgroundColor; + +// Strings we use often +var styleStr = "style"; +var textStr = "text"; +var linkStr = "link"; +var vlinkStr = "vlink"; +var alinkStr = "alink"; +var bgcolorStr = "bgcolor"; +var backgroundStr = "background"; +var colorStyle = "color:" + // dialog initialization code function Startup() { @@ -38,62 +82,268 @@ function Startup() dialog.NormalText = document.getElementById("NormalText"); dialog.LinkText = document.getElementById("LinkText"); dialog.ActiveLinkText = document.getElementById("ActiveLinkText"); - dialog.FollowedLinkText = document.getElementById("FollowedLinkText"); + dialog.VisitedLinkText = document.getElementById("VisitedLinkText"); + dialog.DefaultColorsRadio = document.getElementById("DefaultColorsRadio"); + dialog.CustomColorsRadio = document.getElementById("CustomColorsRadio"); + dialog.BackgroundImageCheckbox = document.getElementById("BackgroundImageCheckbox"); + dialog.BackgroundImageInput = document.getElementById("BackgroundImageInput"); + + BodyElement = editorShell.editorDocument.body; + if (!BodyElement) + { + dump("Failed to get BODY element!\n"); + window.close(); + } + dump(BodyElement+"\n"); + + // Set element we will edit + globalElement = BodyElement.cloneNode(false); doSetOKCancel(onOK, null); + // Initialize default colors from browser prefs + prefs = GetPrefs(); + if (prefs) + { + dump("Getting browser prefs...\n"); + + // This doesn't necessarily match what appears in the page + // It is complicated by browser.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.use_document_colors"); + dump("browser.use_document_colors = "+ useDocumentColors+"\n"); + if (useDocumentColors) + { + // How do I get current colors as show in page? + } else { + // Use author's browser pref colors + defaultTextColor = prefs.CopyCharPref("browser.foreground_color"); + defaultLinkColor = prefs.CopyCharPref("browser.anchor_color"); + // Note: Browser doesn't store a value for ActiveLinkColor + defaultVisitedLinkColor = prefs.CopyCharPref("browser.visited_color"); + defaultBackgroundColor= prefs.CopyCharPref("browser.background_color"); + } + // Get the last-set background image + lastSetBackgroundImage = prefs.CopyCharPref("editor.default_background_image"); + } InitDialog(); - //.focus(); + if (dialog.DefaultColorsRadio.checked) + dialog.DefaultColorsRadio.focus(); + else + dialog.CustomColorsRadio.focus(); } 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) + { + // If any colors are set, then check the "Custom" radio button + dialog.CustomColorsRadio.checked = true; + } else { + dialog.DefaultColorsRadio.checked = true; + } + + // Save a copy to use when switching from UseDefault to UseCustom + SaveCustomColors(); + + // Get image from document + dialog.BackgroundImage = globalElement.getAttribute(backgroundStr); + + if (dialog.BackgroundImage) + dialog.BackgroundImageCheckbox.checked = true; + else + // See if we saved an image from previous dialog usage + dialog.BackgroundImage = lastSetBackgroundImage; + + if (dialog.BackgroundImage) + { + dialog.BackgroundImageInput.value = dialog.BackgroundImage; + dialog.ColorPreview.setAttribute(backgroundStr, dialog.BackgroundImage); + } } -function GetColor(ColorPickerID, ColorWellID) +function SetColor(ColorWellID, color) { - var color = getColorAndSetColorWell(ColorPickerID, ColorWellID); -dump("GetColor, color="+color+"\n"); - if (!color) + switch( ColorWellID ) { - // No color was clicked on, - // so user clicked on "Don't Specify Color" button - color = "inherit"; - dump("Don't specify color\n"); - } - var colorString = "color:"+color; - switch( ColorPickerID ) - { - case "textCP": + case "textCW": + if (!color) color = defaultTextColor; dialog.textColor = color; - dialog.NormalText.setAttribute("style",colorString); + dialog.NormalText.setAttribute(styleStr,colorStyle+color); break; - case "linkCP": + case "linkCW": + if (!color) color = defaultLinkColor; dialog.linkColor = color; - dialog.LinkText.setAttribute("style",colorString); + dialog.LinkText.setAttribute(styleStr,colorStyle+color); break; - case "followedCP": - dialog.followedLinkColor = color; - dialog.FollowedLinkText.setAttribute("style",colorString); - break; - case "activeCP": + case "activeCW": + if (!color) color = defaultLinkColor; dialog.activeLinkColor = color; - dialog.ActiveLinkText.setAttribute("style",colorString); + dialog.ActiveLinkText.setAttribute(styleStr,colorStyle+color); break; - case "backgroundCP": + 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; - dialog.ColorPreview.setAttribute("bgcolor",color); + dialog.ColorPreview.setAttribute(bgcolorStr,color); 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); +} + +function UseDefaultColors() +{ + dump("UseDefaultColors\n"); + // Save colors to use when switching back to UseCustomColors + SaveCustomColors(); + + SetColor("textCW", defaultTextColor); + SetColor("linkCW", defaultLinkColor); + SetColor("activeCW", defaultLinkColor); //Browser doesn't store this separately + SetColor("visitedCW", defaultVisitedLinkColor); + SetColor("backgroundCW", defaultBackgroundColor); +} + + +function onBackgroundImageCheckbox() +{ + if (dialog.BackgroundImageCheckbox.checked) + { + if (ValidateImage()) + dialog.ColorPreview.setAttribute(backgroundStr, dialog.BackgroundImage); + } else { + dialog.ColorPreview.removeAttribute(backgroundStr); + } } -function RemoveColor(ColorWellID) +function chooseFile() { + // Get a local file, converted into URL format + fileName = editorShell.GetLocalFileURL(window, "img"); + if (fileName && fileName != "") + { + dialog.BackgroundImage = fileName; + dialog.BackgroundImageInput.value = fileName; + dialog.BackgroundImageCheckbox.checked = true; + dialog.ColorPreview.setAttribute(backgroundStr, fileName); + } + + // Put focus into the input field + dialog.BackgroundImageInput.focus(); +} + +function ValidateImage() +{ + var image = dialog.BackgroundImageInput.value.trimString(); + if (image && image != "") + { + if (IsValidImage(image)) + { + dialog.BackgroundImage = image; + return true; + } else { + dialog.BackgroundImage = null; + dialog.BackgroundImageInput.focus(); + ShowInputErrorMessage(GetString("MissingImageError")); + } + } + // Don't allow checkbox if bad or no image + dialog.BackgroundImageCheckbox.checked = false; + return false; +} + +function ValidateData() +{ + // Colors values are updated as they are picked, no validation necessary + if (dialog.DefaultColorsRadio.checked) + { + globalElement.removeAttribute(textStr); + globalElement.removeAttribute(linkStr); + globalElement.removeAttribute(vlinkStr); + globalElement.removeAttribute(alinkStr); + globalElement.removeAttribute(bgcolorStr); + } + 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); + } + if (dialog.BackgroundImageCheckbox.checked) + { + if (!ValidateImage()) + return false; + + globalElement.setAttribute(backgroundStr, dialog.BackgroundImage); + + } else { + globalElement.removeAttribute(backgroundStr); + } + + return true; } 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); + } - return true; // do close the window + // Copy attributes to element we are changing + editorShell.CloneAttributes(BodyElement, globalElement); + return true; // do close the window + } + return false; } diff --git a/mozilla/editor/ui/dialogs/content/EdColorProps.xul b/mozilla/editor/ui/dialogs/content/EdColorProps.xul index 6d65d5860fb..a735731d6ee 100644 --- a/mozilla/editor/ui/dialogs/content/EdColorProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdColorProps.xul @@ -37,21 +37,24 @@ align="vertical"> <html:script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js"/> - <html:script language="JavaScript" src="chrome://editor/content/EdPageProps.js"/> + <html:script language="JavaScript" src="chrome://editor/content/EdColorProps.js"/> <html:script language="JavaScript" src="chrome://global/content/dialogOverlay.js" /> <broadcaster id="args" value=""/> + <html:label>&pageColors.label;</html:label> - <box align="horizontal" class="margin-left-right"> + <box class="margin-left-right"> <!-- must use div else box stretches radio button size --> - <html:div><html:input type="radio" name="ColorMode" id="DefaultColorsRadio"/></html:div> + <html:div><html:input type="radio" name="ColorMode" id="DefaultColorsRadio" onclick="UseDefaultColors()"/></html:div> <html:label for="DefaultColorsRadio">&defaultColorsRadio.label;</html:label> </box> - <box align="horizontal" class="margin-left-right"> - <html:div><html:input type="radio" name="ColorMode" id="CustomColorsRadio"/></html:div> + <box class="margin-left-right"> + <html:div><html:input type="radio" name="ColorMode" id="CustomColorsRadio" onclick="UseCustomColors()"/></html:div> <html:label for="CustomColorsRadio">&customColorsRadio.label;</html:label> </box> <spring class="bigspacer"/> + +<!-- DON'T SHOW COLOR SCHEMES UNTIL REDESIGNED <html:div> <box flex="1"> <html:label for="ColorScheme"> &colorScheme.label;</html:label> @@ -62,100 +65,99 @@ <html:option> White on Black </html:option> </html:select> </box> - <!-- TODO: COLOR SCHEME SELECT LIST --> </html:div> <spring class="bigspacer"/> - <box align="horizontal"> +--> + + <box> <spring class="bigspacer"/> - <box align="vertical" flex="100%"> + <box align="vertical" flex="1"> <box> <html:label class="margin-left-right"> &normalText.label; </html:label> - <spring flex="100%"/> + <spring flex="1"/> <menu class="colorpicker"> <html:div id="textCW" class="color-well"/> - <titledbutton class="popup" align="right" flex="100%" onclick="GetColor('textCP','textCW');"/> + <titledbutton class="popup" align="right" flex="1" onclick="GetColorAndUpdate('textCP','textCW',this);"/> <menupopup id="normalMenuPopup"> - <colorpicker id="textCP" palettename="standard" onclick="GetColor('textCP','textCW');"/> - <titledbutton class="push" value="&colorPicker.default.label;" onclick="GetColor('textCP','textCW');"/> + <colorpicker id="textCP" palettename="standard" onclick="GetColorAndUpdate('textCP','textCW',this);"/> </menupopup> </menu> </box> - <spring class="spacer"/> <box> <html:label class="margin-left-right"> &linkText.label; </html:label> - <spring flex="100%"/> + <spring flex="1"/> <menu class="colorpicker"> <html:div id="linkCW" class="color-well"/> - <titledbutton class="popup" align="right" flex="100%"/> + <titledbutton class="popup" align="right" flex="1"/> <menupopup> - <colorpicker id="linkCP" palettename="standard" onclick="GetColor('linkCP','linkCW');"/> - <titledbutton class="push" value="&colorPicker.default.label;" onclick="RemoveColor('linkCW');"/> + <colorpicker id="linkCP" palettename="standard" onclick="GetColorAndUpdate('linkCP','linkCW',this);"/> </menupopup> </menu> </box> - <spring class="spacer"/> <box> <html:label class="margin-left-right"> &activeLinkText.label; </html:label> - <spring flex="100%"/> + <spring flex="1"/> <menu class="colorpicker"> <html:div id="activeCW" class="color-well"/> - <titledbutton class="popup" align="right" flex="100%"/> + <titledbutton class="popup" align="right" flex="1"/> <menupopup> - <colorpicker id="activeCP" palettename="standard" onclick="GetColor('activeCP','activeCW');"/> - <titledbutton class="push" value="&colorPicker.default.label;" onclick="RemoveColor('activeCW');"/> + <colorpicker id="activeCP" palettename="standard" onclick="GetColorAndUpdate('activeCP','activeCW',this);"/> </menupopup> </menu> </box> - <spring class="spacer"/> <box> - <html:label class="margin-left-right"> &followedLinkText.label; </html:label> - <spring flex="100%"/> + <html:label class="margin-left-right"> &visitedLinkText.label; </html:label> + <spring flex="1"/> <menu class="colorpicker"> - <html:div id="followedCW" class="color-well"/> - <titledbutton class="popup" align="right" flex="100%"/> + <html:div id="visitedCW" class="color-well"/> + <titledbutton class="popup" align="right" flex="1"/> <menupopup> - <colorpicker id="followedCP" palettename="standard" onclick="GetColor('followedCP','followedCW');"/> - <titledbutton class="push" value="&colorPicker.default.label;" onclick="RemoveColor('followedCW');"/> + <colorpicker id="visitedCP" palettename="standard" onclick="GetColorAndUpdate('visitedCP','visitedCW',this);"/> </menupopup> </menu> </box> - <spring class="spacer"/> <box> <html:label class="margin-left-right"> &background.label; </html:label> - <spring flex="100%"/> + <spring flex="1"/> <menu class="colorpicker"> <html:div id="backgroundCW" class="color-well"/> - <titledbutton class="popup" align="right" flex="100%"/> + <titledbutton class="popup" align="right" flex="1"/> <menupopup> - <colorpicker id="backgroundCP" palettename="standard" onclick="GetColor('backgroundCP','backgroundCW');"/> - <titledbutton class="push" value="&colorPicker.default.label;" onclick="RemoveColor('backgroundCW');"/> + <colorpicker id="backgroundCP" palettename="standard" onclick="GetColorAndUpdate('backgroundCP','backgroundCW',this);"/> </menupopup> </menu> </box> </box> <spring class="bigspacer"/> - <box align="vertical" flex="100%" id="ColorPreview"> - <!-- basestyle="min-height:50px; width: 100%; border: 1px inset #CCCCCC; padding: 5px; " style="min-height:50px; width: 100%; border: 1px inset #CCCCCC; padding: 5px; "--> - <html:div id="NormalText">&normalText.label;</html:div> - <spring class="spacer"/> - <html:div id="LinkText">&linkText.label;</html:div> - <spring class="spacer"/> - <html:div id="ActiveLinkText">&activeLinkText.label;</html:div> - <spring class="spacer"/> - <html:div id="FollowedLinkText">&followedLinkText.label;</html:div> - </box> + <!-- Use table cell for preview so we can use BGCOLOR and BACKGROUND attributes --> + <html:table><html:tr> + <html:td id="ColorPreview" valign="top"> + <html:div id="NormalText">&normalText.label;</html:div> + <html:div id="LinkText">&linkText.label;</html:div> + <html:div id="ActiveLinkText">&activeLinkText.label;</html:div> + <html:div id="VisitedLinkText">&visitedLinkText.label;</html:div> + </html:td> + </html:tr></html:table> </box> <html:div class="separator" align="horizontal"/> - <box align="horizontal"> - <html:div><html:input type="checkbox" id="BackgroundImageCheckbox"/></html:div> + <box> + <html:div><html:input type="checkbox" id="BackgroundImageCheckbox" onclick="onBackgroundImageCheckbox()"/></html:div> <html:label for="BackgroundImageCheckbox"> &backgroundImage.label; </html:label> </box> - <box align="horizontal"> + <box> <html:input type="text" class="SizeToParent" id="BackgroundImageInput" flex="1"/> <spring class="spacer"/> - <!-- from EdDialogOverlay.xul --> <titledbutton id="ChooseFile"/> </box> + <box> + <html:div id="SaveImageMsg">&saveImageMsg.label;</html:div> + <spring class="bigspacer"/> + <spring flex="1"/> + <box align="vertical"> + <spring class="bigspacer"/> + <titledbutton id="AdvancedEditButton2"/> + </box> + </box> <html:div class="separator" align="horizontal"/> <box id="okCancelButtons"/> </window> diff --git a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js index af863b83bbc..99b27d3f229 100644 --- a/mozilla/editor/ui/dialogs/content/EdDialogCommon.js +++ b/mozilla/editor/ui/dialogs/content/EdDialogCommon.js @@ -29,6 +29,9 @@ var SelectionOnly = 1; var FormatedWithDoctype = 2; var FormatedWithoutDoctype = 6; var maxPixels = 10000; +// For dialogs that expand in size. Default is smaller size see "onMoreFewer()" below +var SeeMore = false; + // The element being edited - so AdvancedEdit can have access to it var globalElement; @@ -270,7 +273,7 @@ function GetAppropriatePercentString() { var selection = window.editorShell.editorSelection; if (selection) { - if (editorShell.GetElementOrParentByTagName("td",selection.focusNode)) + if (editorShell.GetElementOrParentByTagName("td",selection.anchorNode)) return GetString("PercentOfCell"); } return GetString("PercentOfWindow"); @@ -464,22 +467,126 @@ function getContainer () return null; } -function getColorAndSetColorWell(ColorPickerID, ColorWellID) +function getColor(ColorPickerID) { - var colorWell = document.getElementById(ColorWellID); var colorPicker = document.getElementById(ColorPickerID); + var color; if (colorPicker) { // Extract color from colorPicker and assign to colorWell. - var color = colorPicker.getAttribute('color'); - dump("setColor to: "+color+"\n"); - - if (colorWell) - { - // Use setAttribute so colorwell can be a XUL element, such as titledbutton - colorWell.setAttribute("style", "background-color: " + color); - } + color = colorPicker.getAttribute('color'); + if (color && color == "") + return null; } - return color; } + +function setColorWell(ColorWellID, color) +{ + var colorWell = document.getElementById(ColorWellID); + if (colorWell) + { + if (!color || color == "") + { + // Don't set color (use default) + // Trigger change to not show color swatch + colorWell.setAttribute("default","true"); + } + else + { + colorWell.removeAttribute("default"); + // Use setAttribute so colorwell can be a XUL element, such as titledbutton + colorWell.setAttribute("style", "background-color:"+color); + } + } +} + +function getColorAndSetColorWell(ColorPickerID, ColorWellID) +{ + var color = getColor(ColorPickerID); + setColorWell(ColorWellID, color); + return color; +} + +// Test for valid image by sniffing out the extension +function IsValidImage(imageName) +{ + image = imageName.trimString(); + if ( !image ) + return false; + + /* look for an extension */ + var tailindex = image.lastIndexOf("."); + if ( tailindex == 0 || tailindex == -1 ) /* -1 is not found */ + return false; + + /* move past period, get the substring from the first character after the '.' to the last character (length) */ + tailindex = tailindex + 1; + var type = image.substring(tailindex,image.length); + + /* convert extension to lower case */ + if (type) + type = type.toLowerCase(); + + // TODO: Will we convert .BMPs to a web format? + switch( type ) { + case "gif": + case "jpg": + case "jpeg": + case "png": + return true; + break; + default : + return false; + } +} + +function InitMoreFewer() +{ + // Set SeeMore bool to the OPPOSITE of the current state, + // which is automatically saved by using the 'persist="more"' + // attribute on the dialog.MoreFewerButton button + // onMoreFewer will toggle it and redraw the dialog + SeeMore = (dialog.MoreFewerButton.getAttribute("more") != "1"); + onMoreFewer(); +} + +function onMoreFewer() +{ + if (SeeMore) + { + dialog.MoreSection.setAttribute("style","display: none"); + window.sizeToContent(); + dialog.MoreFewerButton.setAttribute("more","0"); + dialog.MoreFewerButton.setAttribute("value",GetString("MoreProperties")); + SeeMore = false; + } + else + { + dialog.MoreSection.setAttribute("style","display: inherit"); + window.sizeToContent(); + dialog.MoreFewerButton.setAttribute("more","1"); + dialog.MoreFewerButton.setAttribute("value",GetString("FewerProperties")); + SeeMore = true; + } +} + +function GetPrefs() +{ + var prefs; + try { + prefs = Components.classes['component://netscape/preferences']; + if (prefs) prefs = prefs.getService(); + if (prefs) prefs = prefs.QueryInterface(Components.interfaces.nsIPref); + if (prefs) + return prefs; + else + dump("failed to get prefs service!\n"); + + } + catch(ex) + { + dump("failed to get prefs service!\n"); + } + return null; +} diff --git a/mozilla/editor/ui/dialogs/content/EdDialogOverlay.xul b/mozilla/editor/ui/dialogs/content/EdDialogOverlay.xul index 25800dde091..eca4a4bc549 100644 --- a/mozilla/editor/ui/dialogs/content/EdDialogOverlay.xul +++ b/mozilla/editor/ui/dialogs/content/EdDialogOverlay.xul @@ -37,9 +37,10 @@ <html:div class="separator" align="horizontal"/> </box> -<!-- Extra buttons to use in Image Properties Dialog, - which switches position between 2 locations - Placed here to use same attributes as regular button --> +<!-- Extra buttons to use when just button is needed + E.g. Image Properties Dialog switches position between 2 locations + Placed here to use same attributes as AdvancedEditButton button +--> <titledbutton id = "AdvancedEditButton2" class = "push dialog" diff --git a/mozilla/editor/ui/dialogs/content/EdHLineProps.js b/mozilla/editor/ui/dialogs/content/EdHLineProps.js index c850de638ed..ab0643ea32f 100644 --- a/mozilla/editor/ui/dialogs/content/EdHLineProps.js +++ b/mozilla/editor/ui/dialogs/content/EdHLineProps.js @@ -105,13 +105,7 @@ function onSaveDefault() // "false" means set attributes on the globalElement, // not the real element being edited if (ValidateData()) { - var prefs = Components.classes['component://netscape/preferences']; - if (prefs) { - prefs = prefs.getService(); - } - if (prefs) { - prefs = prefs.QueryInterface(Components.interfaces.nsIPref); - } + var prefs = GetPrefs(); if (prefs) { dump("Setting HLine prefs\n"); @@ -145,8 +139,8 @@ function onSaveDefault() // Write the prefs out NOW! prefs.SavePrefFile(); - } - } + } + } } // Get and validate data from widgets. diff --git a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul index fef812473ca..234908e6e9a 100644 --- a/mozilla/editor/ui/dialogs/content/EdHLineProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdHLineProps.xul @@ -43,7 +43,7 @@ <html:script language="JavaScript" src="chrome://editor/content/EdHLineProps.js"/> <keyset id="keyset"/> - <html:fieldset><html:legend align="left">&dimensionsFieldset.label;</html:legend> + <titledbox><title><text align="left" value="&dimensionsBox.label;"/> @@ -69,14 +69,14 @@ - - &alignmentFieldset.label; + + <text align="left" value="&alignmentBox.label;"/> &leftPopup.value; ¢erPopup.value; &rightPopup.value; - + &threeDShading.label; diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.js b/mozilla/editor/ui/dialogs/content/EdImageProps.js index a6935a641db..32428fbe37b 100644 --- a/mozilla/editor/ui/dialogs/content/EdImageProps.js +++ b/mozilla/editor/ui/dialogs/content/EdImageProps.js @@ -24,7 +24,6 @@ */ var insertNew = true; -var SeeMore = true; var wasEnableAll = false; var oldSourceInt = 0; var imageElement; @@ -95,14 +94,14 @@ function Startup() // Set SeeMore bool to the OPPOSITE of the current state, // which is automatically saved by using the 'persist="more"' // attribute on the MoreFewerButton button - // onMoreFewer will toggle the state and redraw the dialog + // onMoreFewerImage will toggle the state and redraw the dialog SeeMore = (dialog.MoreFewerButton.getAttribute("more") != "1"); // Initialize widgets with image attributes in the case where the entire dialog isn't visible - if ( SeeMore ) // this is actually in the opposite state until onMoreFewer is called below + if ( SeeMore ) // this is actually in the opposite state until onMoreFewerImage is called below InitDialog(); - onMoreFewer(); // this call will initialize all widgets if entire dialog is visible + onMoreFewerImage(); // this call will initialize all widgets if entire dialog is visible dialog.srcInput.focus(); } @@ -172,9 +171,8 @@ function InitDialog() } } - imageTypeExtension = checkForImage(); // we want to force an update so initialize "wasEnableAll" to be the opposite of what the actual state is - wasEnableAll = !imageTypeExtension; + wasEnableAll = !IsValidImage(dialog.srcInput.value); doOverallEnabling(); } @@ -259,7 +257,7 @@ dump("alignment ="+alignment+"\n"); globalElement.setAttribute("height", str); } -function onMoreFewer() +function onMoreFewerImage() { if (SeeMore) { @@ -318,8 +316,7 @@ function doDimensionEnabling( doEnable ) function doOverallEnabling() { - var imageTypeExtension = checkForImage(); - var canEnableAll = imageTypeExtension != 0; + var canEnableAll = IsValidImage(dialog.srcInput.value); if ( wasEnableAll == canEnableAll ) return; @@ -337,7 +334,7 @@ function doOverallEnabling() SetElementEnabledByID("alignLabel", canEnableAll ); SetElementEnabledByID("alignTypeSelect", canEnableAll ); - // spacing fieldset + // spacing Box SetElementEnabledByID( "spacingLabel", canEnableAll ); SetElementEnabledByID( "imageleftrightInput", canEnableAll ); SetElementEnabledByID( "leftrightLabel", canEnableAll ); @@ -360,42 +357,6 @@ function doOverallEnabling() SetElementEnabledByID( "removeImageMap", canEnableAll && canRemoveImageMap); } -// an API to validate and image by sniffing out the extension -/* assumes that the element id is "srcInput" */ -/* returns lower-case extension or 0 */ -function checkForImage() -{ - image = dialog.srcInput.value.trimString(); - if ( !image ) - return 0; - - /* look for an extension */ - var tailindex = image.lastIndexOf("."); - if ( tailindex == 0 || tailindex == -1 ) /* -1 is not found */ - return 0; - - /* move past period, get the substring from the first character after the '.' to the last character (length) */ - tailindex = tailindex + 1; - var type = image.substring(tailindex,image.length); - - /* convert extension to lower case */ - if (type) - type = type.toLowerCase(); - - // TODO: Will we convert .BMPs to a web format? - switch( type ) { - case "gif": - case "jpg": - case "jpeg": - case "png": - return type; - break; - default : - return 0; - } -} - - // constrainProportions contribution by pete@postpagan.com // needs to handle pixels/percent @@ -443,8 +404,7 @@ function removeImageMap() // accessible to AdvancedEdit() [in EdDialogCommon.js] function ValidateData() { - var imageTypeExtension = checkForImage(); - if ( !imageTypeExtension ) { + if ( !IsValidImage(dialog.srcInput.value )) { ShowInputErrorMessage(GetString("MissingImageError")); return false; } @@ -498,7 +458,7 @@ function ValidateData() width = ValidateNumberString(width, 1, maxLimitWidth); if (width == "") { if ( !SeeMore ) - onMoreFewer(); + onMoreFewerImage(); dialog.widthInput.focus(); return false; } @@ -509,7 +469,7 @@ function ValidateData() height = ValidateNumberString(height, 1, maxLimitHeight); if (height == "") { if ( !SeeMore ) - onMoreFewer(); + onMoreFewerImage(); dialog.heightInput.focus(); return false; } diff --git a/mozilla/editor/ui/dialogs/content/EdImageProps.xul b/mozilla/editor/ui/dialogs/content/EdImageProps.xul index 17cc6685d64..ae0f2e64419 100644 --- a/mozilla/editor/ui/dialogs/content/EdImageProps.xul +++ b/mozilla/editor/ui/dialogs/content/EdImageProps.xul @@ -50,7 +50,7 @@ - +
@@ -75,8 +75,8 @@ onchange = "doOverallEnabling()" /> - - + + @@ -106,7 +106,7 @@ class = "push dialog" id = "MoreFewerButton" align = "left" - onclick = "onMoreFewer()" + onclick = "onMoreFewerImage()" persist = "more"/> @@ -121,7 +121,7 @@ - +
@@ -294,7 +294,7 @@ - +
diff --git a/mozilla/editor/ui/dialogs/content/EdInsertTable.js b/mozilla/editor/ui/dialogs/content/EdInsertTable.js index 62596f00d32..3e501a7be6b 100644 --- a/mozilla/editor/ui/dialogs/content/EdInsertTable.js +++ b/mozilla/editor/ui/dialogs/content/EdInsertTable.js @@ -153,13 +153,13 @@ function onOK() // Create necessary rows and cells for the table dump("Rows = "+rows+" Columns = "+columns+"\n"); - for (i = 0; i < rows; i++) + for (var i = 0; i < rows; i++) { var newRow = editorShell.CreateElementWithDefaults("tr"); if (newRow) { tableBody.appendChild(newRow); - for (j = 0; j < columns; j++) + for (var j = 0; j < columns; j++) { newCell = editorShell.CreateElementWithDefaults("td"); if (newCell) diff --git a/mozilla/editor/ui/dialogs/content/EdInsertTable.xul b/mozilla/editor/ui/dialogs/content/EdInsertTable.xul index 67f90910449..15c81dfaa50 100644 --- a/mozilla/editor/ui/dialogs/content/EdInsertTable.xul +++ b/mozilla/editor/ui/dialogs/content/EdInsertTable.xul @@ -30,80 +30,58 @@ - - - -