зеркало из https://github.com/mozilla/gecko-dev.git
Fixed insert element bugs. Added message if no misspelled words. Changed 'More Atrributes' to 'Advanced Edit' in dialogs. Improved generic message dialog. Added remove link button to link dialog
This commit is contained in:
Родитель
a44c365623
Коммит
db6e5788b8
|
@ -2108,14 +2108,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
|
|||
PRUint32 selectedNodeContentCount=0;
|
||||
nsCOMPtr<nsIDOMCharacterData>selectedParentNodeAsText;
|
||||
selectedParentNodeAsText = do_QueryInterface(parentSelectedNode);
|
||||
#ifdef DEBUG_cmanske
|
||||
// What is the parent node for the selection?
|
||||
nsAutoString tag;
|
||||
parentSelectedNode->GetNodeName(tag);
|
||||
printf("DeleteSelectionAndPrepareToCreateNode: Parent of selected node: ");
|
||||
wprintf(tag.GetUnicode());
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
/* if the selection is a text node, split the text node if necesary
|
||||
and compute where to put the new node
|
||||
*/
|
||||
|
@ -2159,14 +2152,6 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
|
|||
result = parentChildList->Item(offsetOfSelectedNode, getter_AddRefs(selectedNode));
|
||||
if ((NS_SUCCEEDED(result)) && selectedNode)
|
||||
{
|
||||
#if 0 //def DEBUG_cmanske
|
||||
// What is the item at the selected offset?
|
||||
nsAutoString tag;
|
||||
selectedNode->GetNodeName(tag);
|
||||
printf("Selected Node's name = ");
|
||||
wprintf(tag.GetUnicode());
|
||||
printf("\n");
|
||||
#endif
|
||||
nsCOMPtr<nsIDOMCharacterData>selectedNodeAsText;
|
||||
selectedNodeAsText = do_QueryInterface(selectedNode);
|
||||
nsCOMPtr<nsIDOMNodeList>childList;
|
||||
|
|
|
@ -2308,18 +2308,17 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentSelectedNode;
|
||||
PRInt32 splitPointOffset;
|
||||
PRInt32 offsetOfSelectedNode;
|
||||
PRInt32 offsetForInsert;
|
||||
res = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
|
||||
if (NS_SUCCEEDED(res) && NS_SUCCEEDED(selection->GetAnchorOffset(&splitPointOffset)) && parentSelectedNode)
|
||||
if (NS_SUCCEEDED(res) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetForInsert)) && parentSelectedNode)
|
||||
{
|
||||
#ifdef DEBUG_cmanske
|
||||
{
|
||||
nsAutoString name;
|
||||
parentSelectedNode->GetNodeName(name);
|
||||
printf("parentSelectedNode: ");
|
||||
printf("InsertElement: Anchor node of selection: ");
|
||||
wprintf(name.GetUnicode());
|
||||
printf("\n");
|
||||
printf(" Offset: %d\n", offsetForInsert);
|
||||
}
|
||||
#endif
|
||||
nsAutoString tagName;
|
||||
|
@ -2328,15 +2327,15 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
|
|||
nsCOMPtr<nsIDOMNode> parent = parentSelectedNode;
|
||||
nsCOMPtr<nsIDOMNode> topChild = parentSelectedNode;
|
||||
nsCOMPtr<nsIDOMNode> tmp;
|
||||
PRInt32 offset = offsetOfSelectedNode;
|
||||
|
||||
nsAutoString parentTagName;
|
||||
PRBool isRoot;
|
||||
|
||||
// Search up the parent chain to find a suitable container
|
||||
while (!CanContainTag(parent, tagName))
|
||||
{
|
||||
// If the current parent is a root (body or table cell)
|
||||
// then go no further - we can't insert
|
||||
nsAutoString parentTagName;
|
||||
parent->GetNodeName(parentTagName);
|
||||
PRBool isRoot;
|
||||
res = IsRootTag(parentTagName, isRoot);
|
||||
if (!NS_SUCCEEDED(res) || isRoot)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -2347,18 +2346,31 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
|
|||
topChild = parent;
|
||||
parent = tmp;
|
||||
}
|
||||
|
||||
// we need to split up to the child of parent
|
||||
res = SplitNodeDeep(topChild, parentSelectedNode, splitPointOffset);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
// topChild already went to the right on the split
|
||||
// so we don't need to add one to offset when figuring
|
||||
// out where to plop list
|
||||
offset = GetIndexOf(parent,topChild);
|
||||
|
||||
// Now we can finally insert the new node
|
||||
res = InsertNode(aElement, parent, offset);
|
||||
#ifdef DEBUG_cmanske
|
||||
{
|
||||
nsAutoString name;
|
||||
parent->GetNodeName(name);
|
||||
printf("Parent node to insert under: ");
|
||||
wprintf(name.GetUnicode());
|
||||
printf("\n");
|
||||
topChild->GetNodeName(name);
|
||||
printf("TopChild to split: ");
|
||||
wprintf(name.GetUnicode());
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
if (parent != topChild)
|
||||
{
|
||||
// we need to split some levels above the original selection parent
|
||||
res = SplitNodeDeep(topChild, parentSelectedNode, offsetForInsert);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
// topChild went to the right on the split
|
||||
// so this is the offset to insert at
|
||||
offsetForInsert = GetIndexOf(parent,topChild);
|
||||
}
|
||||
// Now we can insert the new node
|
||||
res = InsertNode(aElement, parent, offsetForInsert);
|
||||
|
||||
// Set caret after element, but check for special case
|
||||
// of inserting table-related elements: set in first cell instead
|
||||
|
@ -2634,6 +2646,19 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
|
|||
{
|
||||
// Collapse selection to just after desired element,
|
||||
selection->Collapse(parent, offsetInParent+1);
|
||||
#ifdef DEBUG_cmanske
|
||||
{
|
||||
nsAutoString name;
|
||||
parent->GetNodeName(name);
|
||||
printf("SetCaretAfterElement: Parent node: ");
|
||||
wprintf(name.GetUnicode());
|
||||
printf(" Offset: %d\n\nHTML:\n", offsetInParent+1);
|
||||
nsString Format("text/html");
|
||||
nsString ContentsAs;
|
||||
OutputToString(ContentsAs, Format, 2);
|
||||
wprintf(ContentsAs.GetUnicode());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2108,14 +2108,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
|
|||
PRUint32 selectedNodeContentCount=0;
|
||||
nsCOMPtr<nsIDOMCharacterData>selectedParentNodeAsText;
|
||||
selectedParentNodeAsText = do_QueryInterface(parentSelectedNode);
|
||||
#ifdef DEBUG_cmanske
|
||||
// What is the parent node for the selection?
|
||||
nsAutoString tag;
|
||||
parentSelectedNode->GetNodeName(tag);
|
||||
printf("DeleteSelectionAndPrepareToCreateNode: Parent of selected node: ");
|
||||
wprintf(tag.GetUnicode());
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
/* if the selection is a text node, split the text node if necesary
|
||||
and compute where to put the new node
|
||||
*/
|
||||
|
@ -2159,14 +2152,6 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
|
|||
result = parentChildList->Item(offsetOfSelectedNode, getter_AddRefs(selectedNode));
|
||||
if ((NS_SUCCEEDED(result)) && selectedNode)
|
||||
{
|
||||
#if 0 //def DEBUG_cmanske
|
||||
// What is the item at the selected offset?
|
||||
nsAutoString tag;
|
||||
selectedNode->GetNodeName(tag);
|
||||
printf("Selected Node's name = ");
|
||||
wprintf(tag.GetUnicode());
|
||||
printf("\n");
|
||||
#endif
|
||||
nsCOMPtr<nsIDOMCharacterData>selectedNodeAsText;
|
||||
selectedNodeAsText = do_QueryInterface(selectedNode);
|
||||
nsCOMPtr<nsIDOMNodeList>childList;
|
||||
|
|
|
@ -2308,18 +2308,17 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentSelectedNode;
|
||||
PRInt32 splitPointOffset;
|
||||
PRInt32 offsetOfSelectedNode;
|
||||
PRInt32 offsetForInsert;
|
||||
res = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
|
||||
if (NS_SUCCEEDED(res) && NS_SUCCEEDED(selection->GetAnchorOffset(&splitPointOffset)) && parentSelectedNode)
|
||||
if (NS_SUCCEEDED(res) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetForInsert)) && parentSelectedNode)
|
||||
{
|
||||
#ifdef DEBUG_cmanske
|
||||
{
|
||||
nsAutoString name;
|
||||
parentSelectedNode->GetNodeName(name);
|
||||
printf("parentSelectedNode: ");
|
||||
printf("InsertElement: Anchor node of selection: ");
|
||||
wprintf(name.GetUnicode());
|
||||
printf("\n");
|
||||
printf(" Offset: %d\n", offsetForInsert);
|
||||
}
|
||||
#endif
|
||||
nsAutoString tagName;
|
||||
|
@ -2328,15 +2327,15 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
|
|||
nsCOMPtr<nsIDOMNode> parent = parentSelectedNode;
|
||||
nsCOMPtr<nsIDOMNode> topChild = parentSelectedNode;
|
||||
nsCOMPtr<nsIDOMNode> tmp;
|
||||
PRInt32 offset = offsetOfSelectedNode;
|
||||
|
||||
nsAutoString parentTagName;
|
||||
PRBool isRoot;
|
||||
|
||||
// Search up the parent chain to find a suitable container
|
||||
while (!CanContainTag(parent, tagName))
|
||||
{
|
||||
// If the current parent is a root (body or table cell)
|
||||
// then go no further - we can't insert
|
||||
nsAutoString parentTagName;
|
||||
parent->GetNodeName(parentTagName);
|
||||
PRBool isRoot;
|
||||
res = IsRootTag(parentTagName, isRoot);
|
||||
if (!NS_SUCCEEDED(res) || isRoot)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -2347,18 +2346,31 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
|
|||
topChild = parent;
|
||||
parent = tmp;
|
||||
}
|
||||
|
||||
// we need to split up to the child of parent
|
||||
res = SplitNodeDeep(topChild, parentSelectedNode, splitPointOffset);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
// topChild already went to the right on the split
|
||||
// so we don't need to add one to offset when figuring
|
||||
// out where to plop list
|
||||
offset = GetIndexOf(parent,topChild);
|
||||
|
||||
// Now we can finally insert the new node
|
||||
res = InsertNode(aElement, parent, offset);
|
||||
#ifdef DEBUG_cmanske
|
||||
{
|
||||
nsAutoString name;
|
||||
parent->GetNodeName(name);
|
||||
printf("Parent node to insert under: ");
|
||||
wprintf(name.GetUnicode());
|
||||
printf("\n");
|
||||
topChild->GetNodeName(name);
|
||||
printf("TopChild to split: ");
|
||||
wprintf(name.GetUnicode());
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
if (parent != topChild)
|
||||
{
|
||||
// we need to split some levels above the original selection parent
|
||||
res = SplitNodeDeep(topChild, parentSelectedNode, offsetForInsert);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
// topChild went to the right on the split
|
||||
// so this is the offset to insert at
|
||||
offsetForInsert = GetIndexOf(parent,topChild);
|
||||
}
|
||||
// Now we can insert the new node
|
||||
res = InsertNode(aElement, parent, offsetForInsert);
|
||||
|
||||
// Set caret after element, but check for special case
|
||||
// of inserting table-related elements: set in first cell instead
|
||||
|
@ -2634,6 +2646,19 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
|
|||
{
|
||||
// Collapse selection to just after desired element,
|
||||
selection->Collapse(parent, offsetInParent+1);
|
||||
#ifdef DEBUG_cmanske
|
||||
{
|
||||
nsAutoString name;
|
||||
parent->GetNodeName(name);
|
||||
printf("SetCaretAfterElement: Parent node: ");
|
||||
wprintf(name.GetUnicode());
|
||||
printf(" Offset: %d\n\nHTML:\n", offsetInParent+1);
|
||||
nsString Format("text/html");
|
||||
nsString ContentsAs;
|
||||
OutputToString(ContentsAs, Format, 2);
|
||||
wprintf(ContentsAs.GetUnicode());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,6 +259,8 @@
|
|||
|
||||
<html:script language="JavaScript" src="chrome://editor/content/EditorCommands.js">
|
||||
</html:script>
|
||||
<script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js">
|
||||
</script>
|
||||
|
||||
<broadcaster id="args" value="chrome://editor/content/EditorInitPage.html"/>
|
||||
<broadcaster id="canPrint"/>
|
||||
|
|
|
@ -476,8 +476,8 @@ function CheckSpelling()
|
|||
dump(firstMisspelledWord+"\n");
|
||||
if( firstMisspelledWord == "")
|
||||
{
|
||||
dump("THERE IS NO MISSPELLED WORD!\n");
|
||||
// TODO: PUT UP A MESSAGE BOX TO TELL THE USER
|
||||
// No misspelled word - tell user
|
||||
window.openDialog("chrome://editor/content/EdMessage.xul", "NoSpellError", "chrome", "", "No misspelled word was found.", "Check Spelling");
|
||||
spellChecker.CloseSpellChecking();
|
||||
} else {
|
||||
dump("We found a MISSPELLED WORD\n");
|
||||
|
|
|
@ -23,6 +23,14 @@ function InitEditorShell()
|
|||
return true;
|
||||
}
|
||||
|
||||
function StringExists(string)
|
||||
{
|
||||
if (string != null && string != "undefined" && string.length > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function ClearList(list)
|
||||
{
|
||||
for( i = (list.length-1); i >= 0; i-- ) {
|
||||
|
@ -93,7 +101,6 @@ function ValidateNumberString(value, minValue, maxValue)
|
|||
}
|
||||
message = "The number you entered ("+number+") is outside of allowed range.\nPlease enter a number between "+minValue+" and "+maxValue;
|
||||
ShowInputErrorMessage(message);
|
||||
window.openDialog("chrome://editor/content/EdMessage.xul", "MsgDlg", "chrome", "", message, "Input Error", "OK");
|
||||
|
||||
// Return an empty string to indicate error
|
||||
return "";
|
||||
|
@ -102,7 +109,7 @@ function ValidateNumberString(value, minValue, maxValue)
|
|||
function ShowInputErrorMessage(message)
|
||||
{
|
||||
// This is NOT MODAL as of 7/16/99!
|
||||
window.openDialog("chrome://editor/content/EdMessage.xul", "MsgDlg", "chrome", "", message, "Input Error", "OK");
|
||||
window.openDialog("chrome://editor/content/EdMessage.xul", "MsgDlg", "chrome", "", message, "Input Error");
|
||||
}
|
||||
|
||||
function TrimStringLeft(string)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<xul:broadcaster id="args" value=""/>
|
||||
<hr width="100%"/>
|
||||
<xul:box>
|
||||
<xul:titledbutton class="spaced" id="Advanced" onclick="onAdvanced()" value="More Attributes..."/>
|
||||
<xul:titledbutton class="spaced" id="AdvancedEdit" onclick="onAdvanced()" value="Advanced Edit..."/>
|
||||
<xul:spring flex="100%"/>
|
||||
<xul:titledbutton class="spaced" id="OK" onclick="onOK()" value="OK"/>
|
||||
<xul:titledbutton class="spaced" id="Cancel" onclick="onCancel()" value="Cancel"/>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<!ENTITY saveSettings.label "Save Settings">
|
||||
<!ENTITY OKButton.label "OK">
|
||||
<!ENTITY CancelButton.label "Cancel">
|
||||
<!ENTITY MoreAttributesButton.label "More Attributes...">
|
||||
<!ENTITY AdvancedEditButton.label "Advanced Edit...">
|
||||
|
||||
]>
|
||||
|
||||
|
@ -92,7 +92,7 @@
|
|||
</table>
|
||||
<hr width="100%"/>
|
||||
<xul:box>
|
||||
<xul:titledbutton class="spaced" id="MoreAttributes" onclick="onMoreAttributes()" value="&MoreAttributesButton.label;"/>
|
||||
<xul:titledbutton class="spaced" id="AdvancedEdit" onclick="onAdvancedEdit()" value="&AdvancedEditButton.label;"/>
|
||||
<xul:spring flex="100%"/>
|
||||
<xul:titledbutton class="spaced" id="OK" onclick="onOK()" value="&OKButton.label;"/>
|
||||
<xul:titledbutton class="spaced" id="Cancel" onclick="onCancel()" value="&CancelButton.label;"/>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
<!ENTITY OKButton.label "OK">
|
||||
<!ENTITY CancelButton.label "Cancel">
|
||||
<!ENTITY advancedButton.label "Advanced">
|
||||
<!ENTITY advancedButton.label "Advanced Edit">
|
||||
|
||||
]>
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<!ENTITY OKButton.label "OK">
|
||||
<!ENTITY CancelButton.label "Cancel">
|
||||
<!ENTITY MoreAttributesButton.label "More Attributes...">
|
||||
<!ENTITY AdvancedEditButton.label "Advanced Edit...">
|
||||
|
||||
]>
|
||||
|
||||
|
@ -89,7 +89,7 @@
|
|||
</table>
|
||||
<hr width="100%"/>
|
||||
<xul:box>
|
||||
<xul:titledbutton class="spaced" id="MoreAttributes" onclick="onMoreAttributes()" value="&MoreAttributesButton.label;"/>
|
||||
<xul:titledbutton class="spaced" id="AdvancedEdit" onclick="onAdvancedEdit()" value="&AdvancedEditButton.label;"/>
|
||||
<xul:spring flex="100%"/>
|
||||
<xul:titledbutton class="spaced" id="OK" onclick="onOK()" value="&OKButton.label;"/>
|
||||
<xul:titledbutton class="spaced" id="Cancel" onclick="onCancel()" value="&CancelButton.label;"/>
|
||||
|
|
|
@ -4,11 +4,13 @@ var insertNew = true;
|
|||
var needLinkText = false;
|
||||
var selection;
|
||||
var insertLinkAroundSelection = false;
|
||||
var linkTextInput;
|
||||
var hrefInput;
|
||||
var linkMessage;
|
||||
|
||||
// NOTE: Use "href" instead of "a" to distinguish from Named Anchor
|
||||
// The returned node is has an "a" tagName
|
||||
var tagName = "href";
|
||||
var dialog;
|
||||
|
||||
// dialog initialization code
|
||||
function Startup()
|
||||
|
@ -16,17 +18,15 @@ function Startup()
|
|||
if (!InitEditorShell())
|
||||
return;
|
||||
|
||||
// Create dialog object to store controls for easy access
|
||||
dialog = new Object;
|
||||
dialog.linkTextInput = document.getElementById("linkTextInput");
|
||||
dialog.hrefInput = document.getElementById("hrefInput");
|
||||
linkTextInput = document.getElementById("linkTextInput");
|
||||
hrefInput = document.getElementById("hrefInput");
|
||||
|
||||
// Kinda clunky: Message was wrapped in a <p>, so actual message is a child text node
|
||||
dialog.linkMessage = (document.getElementById("linkMessage")).firstChild;
|
||||
// Message was wrapped in a <p>, so actual message is a child text node
|
||||
linkMessage = (document.getElementById("linkMessage")).firstChild;
|
||||
|
||||
if (null == dialog.linkTextInput ||
|
||||
null == dialog.hrefInput ||
|
||||
null == dialog.linkMessage )
|
||||
if (null == linkTextInput ||
|
||||
null == hrefInput ||
|
||||
null == linkMessage )
|
||||
{
|
||||
dump("Not all dialog controls were found!!!\n");
|
||||
}
|
||||
|
@ -38,17 +38,17 @@ function Startup()
|
|||
|
||||
if (insertNew) {
|
||||
dump("Setting focus to linkTextInput\n");
|
||||
dialog.linkTextInput.focus();
|
||||
linkTextInput.focus();
|
||||
} else {
|
||||
dump("Setting focus to linkTextInput\n");
|
||||
dialog.hrefInput.focus();
|
||||
hrefInput.focus();
|
||||
|
||||
// We will not insert a new link at caret, so remove link text input field
|
||||
parentNode = dialog.linkTextInput.parentNode;
|
||||
parentNode = linkTextInput.parentNode;
|
||||
if (parentNode) {
|
||||
dump("Removing link text input field.\n");
|
||||
parentNode.removeChild(dialog.linkTextInput);
|
||||
dialog.linkTextInput = null;
|
||||
parentNode.removeChild(linkTextInput);
|
||||
linkTextInput = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ function initDialog()
|
|||
insertNew = false;
|
||||
// Link source string is the source URL of image
|
||||
// TODO: THIS STILL DOESN'T HANDLE MULTIPLE SELECTED IMAGES!
|
||||
dialog.linkMessage.data = imageElement.getAttribute("src");;
|
||||
linkMessage.data = imageElement.getAttribute("src");;
|
||||
}
|
||||
} else {
|
||||
// We don't have an element selected,
|
||||
|
@ -112,7 +112,7 @@ function initDialog()
|
|||
} else {
|
||||
dump("Selected text for link source not found. Non-text elements selected?\n");
|
||||
}
|
||||
dialog.linkMessage.data = selectedText;
|
||||
linkMessage.data = selectedText;
|
||||
}
|
||||
|
||||
if (!selection.isCollapsed)
|
||||
|
@ -133,17 +133,23 @@ function chooseFile()
|
|||
// Get a local file, converted into URL format
|
||||
fileName = editorShell.GetLocalFileURL(window, "html");
|
||||
if (fileName != "") {
|
||||
dialog.hrefInput.value = fileName;
|
||||
hrefInput.value = fileName;
|
||||
}
|
||||
// Put focus into the input field
|
||||
dialog.hrefInput.focus();
|
||||
hrefInput.focus();
|
||||
}
|
||||
|
||||
function RemoveLink()
|
||||
{
|
||||
// Simple clear the input field!
|
||||
hrefInput.value = "";
|
||||
}
|
||||
|
||||
function onOK()
|
||||
{
|
||||
// TODO: VALIDATE FIELDS BEFORE COMMITING CHANGES
|
||||
|
||||
href = TrimString(dialog.hrefInput.value);
|
||||
href = TrimString(hrefInput.value);
|
||||
if (href.length > 0) {
|
||||
// Coalesce into one undo transaction
|
||||
editorShell.BeginBatchChanges();
|
||||
|
@ -157,10 +163,10 @@ function onOK()
|
|||
// Append the link text as the last child node
|
||||
// of the anchor node
|
||||
dump("Creating text node\n");
|
||||
newText = TrimString(dialog.linkTextInput.value);
|
||||
newText = TrimString(linkTextInput.value);
|
||||
if (newText.length == 0) {
|
||||
ShowInputErrorMessage("You must enter some text for this link.");
|
||||
dialog.linkTextInput.focus();
|
||||
linkTextInput.focus();
|
||||
return;
|
||||
}
|
||||
textNode = editorShell.editorDocument.createTextNode(newText);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<!ENTITY OKButton.label "OK">
|
||||
<!ENTITY CancelButton.label "Cancel">
|
||||
<!ENTITY MoreAttributesButton.label "More Attributes...">
|
||||
<!ENTITY AdvancedEditButton.label "Advanced Edit...">
|
||||
|
||||
<!-- This button is for the progressive disclosure of additional editing functionality -->
|
||||
<!ENTITY AdditionalEditingButton.label "Advanced">
|
||||
|
@ -25,13 +25,14 @@
|
|||
<!ENTITY windowTitle.label "Link Properties">
|
||||
|
||||
<!-- These are in the link source fieldset. -->
|
||||
<!ENTITY LinkSourceFieldset.label "Link Source">
|
||||
<!ENTITY LinkSourceText.label "Enter text to display for a new link:">
|
||||
<!ENTITY LinkText.label "Link text:">
|
||||
<!ENTITY LinkTextInput.label "Enter text to display for a new link:">
|
||||
|
||||
<!-- These controls are in the Dimensions Fieldset of the advanced area -->
|
||||
<!ENTITY LinkURLFieldset.label "Link To">
|
||||
<!ENTITY LinkURLEditField.label "Enter a web page location or local file:">
|
||||
<!ENTITY LinkChooseFileButton.label "Choose File...">
|
||||
<!ENTITY RemoveLinkButton.label "Remove Link">
|
||||
|
||||
]>
|
||||
|
||||
|
@ -49,29 +50,30 @@
|
|||
</script>
|
||||
<xul:broadcaster id="args" value=""/>
|
||||
|
||||
<fieldset><legend align="left"> &LinkSourceFieldset.label; </legend>
|
||||
<xul:box align="vertical">
|
||||
<xul:box> align="horizontal">
|
||||
<label class="smallmargin" id="linkMessage" for="linkTextInput"> &LinkSourceText.label; </label>
|
||||
</xul:box>
|
||||
<input type="text" size="25" length="25" id="linkTextInput"></input>
|
||||
</xul:box>
|
||||
</fieldset>
|
||||
<xul:box align="vertical">
|
||||
<xul:box> align="horizontal">
|
||||
<label class="smallmargin" id="linkMessage" for="linkTextMessage"> &LinkTextInput.label; </label>
|
||||
</xul:box>
|
||||
<input type="text" size="25" length="25" id="linkTextInput"></input>
|
||||
</xul:box>
|
||||
|
||||
<fieldset><legend align="left"> &LinkURLFieldset.label; </legend>
|
||||
<xul:box align="vertical">
|
||||
<xul:box align="horizontal">
|
||||
<label class="smallmargin" for="ChooseFile"> &LinkURLEditField.label; </label>
|
||||
<xul:spring flex="100%"/>
|
||||
<button id="RemoveLink" onclick="RemoveLink()"> &RemoveLinkButton.label; </button>
|
||||
</xul:box>
|
||||
<xul:box align="horizontal">
|
||||
<input type="text" size="25" length="25" id="hrefInput"></input>
|
||||
<xul:spring flex="100%"/>
|
||||
<button class="ChooseFile" id="ChooseFile" onclick="ChooseFile()"> &LinkChooseFileButton.label; </button>
|
||||
</xul:box>
|
||||
</xul:box>
|
||||
</fieldset>
|
||||
|
||||
<xul:box>
|
||||
<xul:titledbutton class="spaced" id="MoreAttributes" onclick="onMoreAttributes()" value="&MoreAttributesButton.label;"/>
|
||||
<xul:titledbutton class="spaced" id="AdvancedEdit" onclick="onAdvancedEdit()" value="&AdvancedEditButton.label;"/>
|
||||
<xul:spring flex="100%"/>
|
||||
<xul:titledbutton class="spaced" id="OK" onclick="onOK()" value="&OKButton.label;"/>
|
||||
<xul:titledbutton class="spaced" id="Cancel" onclick="onCancel()" value="&CancelButton.label;"/>
|
||||
|
|
|
@ -10,15 +10,18 @@ function Startup()
|
|||
|
||||
// Message is wrapped in a <div>
|
||||
// We will add child text node(s)
|
||||
messageParent = (document.getElementById("message"));
|
||||
messageText = window.arguments[1];
|
||||
if (messageText && messageText.length > 0)
|
||||
{
|
||||
var messageParent = (document.getElementById("message"));
|
||||
var messageText = String(window.arguments[1]);
|
||||
|
||||
if (StringExists(messageText)) {
|
||||
var messageFragment;
|
||||
|
||||
// Let the caller use "\n" to cause breaks
|
||||
// Translate these into <br> tags
|
||||
|
||||
done = false;
|
||||
while (!done) {
|
||||
breakIndex = messageText.search(/\n/);
|
||||
breakIndex = messageText.indexOf('\n');
|
||||
if (breakIndex == 0) {
|
||||
// Ignore break at the first character
|
||||
messageText = messageText.slice(1);
|
||||
|
@ -48,77 +51,42 @@ function Startup()
|
|||
// We must have a message
|
||||
window.close();
|
||||
}
|
||||
titleText = window.arguments[2];
|
||||
if (titleText.length > 0) {
|
||||
|
||||
titleText = String(window.arguments[2]);
|
||||
if (StringExists(titleText)) {
|
||||
dump(titleText+" is the message dialog title\n");
|
||||
window.title = titleText;
|
||||
}
|
||||
|
||||
button1 = document.getElementById("button1");
|
||||
button2 = document.getElementById("button2");
|
||||
button3 = document.getElementById("button3");
|
||||
button4 = document.getElementById("button4");
|
||||
// All buttons must have the same parent
|
||||
buttonParent = button1.parentNode;
|
||||
// Set the button text from dialog arguments
|
||||
// if first button doesn't have text, use "OK"
|
||||
InitButton(3,"button1", true);
|
||||
InitButton(4,"button2", false);
|
||||
InitButton(5,"button3", false);
|
||||
InitButton(6,"button4", false);
|
||||
}
|
||||
|
||||
button1Text = window.arguments[3];
|
||||
if (button1Text && button1Text.length > 0)
|
||||
{
|
||||
dump(button1Text+"\n");
|
||||
button1.setAttribute("value", button1Text);
|
||||
} else {
|
||||
// We must have at least one button!
|
||||
window.close();
|
||||
function InitButton(argIndex, buttonID, useOK)
|
||||
{
|
||||
var button = document.getElementById(buttonID);
|
||||
var text = String(window.arguments[argIndex]);
|
||||
var exists = StringExists(text);
|
||||
if (!exists && useOK) {
|
||||
text = "OK";
|
||||
exists = true;
|
||||
}
|
||||
|
||||
button2Text = window.arguments[4];
|
||||
if (button2Text && button2Text.length > 0)
|
||||
if (exists)
|
||||
{
|
||||
dump(button2Text+"\n");
|
||||
button2.setAttribute("value", button2Text);
|
||||
dump(text+"\n");
|
||||
button.setAttribute("value", text);
|
||||
} else {
|
||||
buttonParent.removeChild(button2);
|
||||
}
|
||||
|
||||
button3Text = window.arguments[5];
|
||||
if (button3Text && button3Text.length > 0)
|
||||
{
|
||||
dump(button3Text+"\n");
|
||||
button3.setAttribute("value", button3Text);
|
||||
} else {
|
||||
buttonParent.removeChild(button3);
|
||||
}
|
||||
|
||||
button4Text = window.arguments[6];
|
||||
if (button4Text && button4Text.length > 0)
|
||||
{
|
||||
dump(button4Text+"\n");
|
||||
button4.setAttribute("value", button4Text);
|
||||
} else {
|
||||
buttonParent.removeChild(button4);
|
||||
var buttonParent = document.getElementById(buttonID).parentNode;
|
||||
buttonParent.removeChild(button);
|
||||
}
|
||||
}
|
||||
|
||||
function onButton1()
|
||||
function onButton(buttonNumber)
|
||||
{
|
||||
window.opener.msgResult = 1;
|
||||
window.close();
|
||||
}
|
||||
|
||||
function onButton2()
|
||||
{
|
||||
window.opener.msgResult = 2;
|
||||
window.close();
|
||||
}
|
||||
|
||||
function onButton3()
|
||||
{
|
||||
window.opener.msgResult = 3;
|
||||
window.close();
|
||||
}
|
||||
|
||||
function onButton3()
|
||||
{
|
||||
window.opener.msgResult = 4;
|
||||
window.opener.msgResult = buttonNumber;
|
||||
window.close();
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
<spring style="height: 15px"/>
|
||||
<box align="horizontal" style="margin: 10px">
|
||||
<spring flex="100%"/>
|
||||
<titledbutton class="MsgButton" id="button1" onclick="onButton1()"/>
|
||||
<titledbutton class="MsgButton" id="button2" onclick="onButton2()"/>
|
||||
<titledbutton class="MsgButton" id="button3" onclick="onButton3()"/>
|
||||
<titledbutton class="MsgButton" id="button4" onclick="onButton4()"/>
|
||||
<titledbutton class="MsgButton" id="button1" onclick="onButton(1)"/>
|
||||
<titledbutton class="MsgButton" id="button2" onclick="onButton(2)"/>
|
||||
<titledbutton class="MsgButton" id="button3" onclick="onButton(3)"/>
|
||||
<titledbutton class="MsgButton" id="button4" onclick="onButton(4)"/>
|
||||
<spring flex="100%"/>
|
||||
</box>
|
||||
</window>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<!ENTITY anchorNameEditField.label "Anchor Name:">
|
||||
<!ENTITY OKButton.label "OK">
|
||||
<!ENTITY CancelButton.label "Cancel">
|
||||
<!ENTITY moreButton.label "More Attributes...">
|
||||
<!ENTITY moreButton.label "Advanced Edit...">
|
||||
|
||||
]>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче