Simplified insert logic in dialogs

This commit is contained in:
cmanske%netscape.com 1999-07-03 00:54:23 +00:00
Родитель f1c37b22bb
Коммит eaa80e2526
4 изменённых файлов: 4 добавлений и 36 удалений

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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);

Просмотреть файл

@ -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();
}