gecko-dev/editor/ui/dialogs/content/EdDialogTemplate.js

62 строки
1.5 KiB
JavaScript
Исходник Обычный вид История

//Cancel() is in EdDialogCommon.js
var editorShell;
1999-05-08 02:26:23 +04:00
var insertNew = true;
var tagname = "TAG NAME"
1999-05-08 02:26:23 +04:00
// dialog initialization code
function Startup()
{
// get the editor shell from the parent window
editorShell = window.opener.editorShell;
editorShell = editorShell.QueryInterface(Components.interfaces.nsIEditorShell);
if(!editorShell) {
dump("EditoreditorShell not found!!!\n");
window.close();
return;
1999-05-08 02:26:23 +04:00
}
dump("EditoreditorShell found for NamedAnchor Properties dialog\n");
1999-05-08 02:26:23 +04:00
// Create dialog object to store controls for easy access
dialog = new Object;
// GET EACH CONTROL -- E.G.:
//dialog.editBox = document.getElementById("editBox");
initDialog();
// SET FOCUS TO FIRST CONTROL
//dialog.editBox.focus();
}
function initDialog() {
1999-05-14 05:30:19 +04:00
// Get a single selected element of the desired type
element = editorShell.GetSelectedElement(tagName);
1999-05-08 02:26:23 +04:00
1999-05-14 05:30:19 +04:00
if (element) {
1999-05-08 02:26:23 +04:00
// We found an element and don't need to insert one
insertNew = false;
dump("Found existing image\n");
} else {
insertNew = true;
// We don't have an element selected,
// so create one with default attributes
dump("Element not selected - calling createElementWithDefaults\n");
1999-05-14 05:30:19 +04:00
element = appCore.createElementWithDefaults(tagName);
1999-05-08 02:26:23 +04:00
}
1999-05-14 05:30:19 +04:00
if(!element)
1999-05-08 02:26:23 +04:00
{
dump("Failed to get selected element or create a new one!\n");
window.close();
1999-05-08 02:26:23 +04:00
}
}
function onOK()
1999-05-08 02:26:23 +04:00
{
// Set attribute example:
// imageElement.setAttribute("src",dialog.srcInput.value);
1999-05-08 02:26:23 +04:00
if (insertNew) {
1999-07-03 04:54:23 +04:00
editorShell.InsertElement(element, false);
1999-05-08 02:26:23 +04:00
}
window.close();
}