зеркало из https://github.com/mozilla/pjs.git
Simplified insert logic in dialogs
This commit is contained in:
Родитель
f1c37b22bb
Коммит
eaa80e2526
|
@ -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();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче