Simplified insert logic in dialogs

git-svn-id: svn://10.0.0.236/trunk@38209 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cmanske%netscape.com
1999-07-03 00:54:23 +00:00
parent 7e457f3a5a
commit 83a865e345
4 changed files with 4 additions and 36 deletions

View File

@@ -1,7 +1,6 @@
//Cancel() is in EdDialogCommon.js
var editorShell;
var insertNew = true;
var inserted = false;
var tagname = "TAG NAME"
// dialog initialization code
@@ -56,18 +55,7 @@ function onOK()
// Set attribute example:
// imageElement.setAttribute("src",dialog.srcInput.value);
if (insertNew) {
editorShell.InsertElement(element, true);
// Select the newly-inserted image
editorShell.SelectElement(element);
// Mark that we inserted so we can collapse the selection
// when dialog closes
inserted = true;
}
if (inserted) {
// We selected the object, undo it by
// setting caret to just after the inserted element
editorShell.SetSelectionAfterElement(imageElement);
editorShell.InsertElement(element, false);
}
window.close();
}

View File

@@ -316,15 +316,7 @@ function onOK()
// handle insertion of new image
if (insertNew) {
dump("src="+imageElement.getAttribute("src")+" alt="+imageElement.getAttribute("alt")+"\n");
editorShell.InsertElement(imageElement, true);
// Select the newly-inserted image
editorShell.SelectElement(imageElement);
// Mark that we inserted so we can collapse the selection
// when dialog closes
// We selected the object, undo it by
// setting caret to just after the inserted element
editorShell.SetSelectionAfterElement(imageElement);
editorShell.InsertElement(imageElement, false);
}
// dismiss dialog

View File

@@ -170,7 +170,7 @@ function onOK()
anchorElement.appendChild(textNode);
}
dump("Inserting\n");
editorShell.InsertElement(anchorElement, true);
editorShell.InsertElement(anchorElement, false);
} else if (insertLinkAroundSelection) {
dump("Setting link around selected text\n");
editorShell.InsertLinkAroundSelection(anchorElement);

View File

@@ -1,7 +1,6 @@
//Cancel() is in EdDialogCommon.js
var editorShell;
var insertNew = true;
var inserted = false;
var tagName = "anchor"
var anchorElement = null;
@@ -65,21 +64,10 @@ function onOK()
} else {
// Replace spaces with "_" else it causes trouble in URL parsing
name = ReplaceWhitespace(name, "_");
imageElement.setAttribute("name",name);
anchorElement.setAttribute("name",name);
if (insertNew) {
// Don't delete selected text when inserting
editorShell.InsertElement(element, false);
// Select the newly-inserted image
editorShell.SelectElement(element);
// Mark that we inserted so we can collapse the selection
// when dialog closes
inserted = true;
}
if (inserted) {
// We selected the object, undo it by
// setting caret to just after the inserted element
editorShell.SetSelectionAfterElement(imageElement);
}
window.close();
}