Adding Named Anchor UI files

This commit is contained in:
cmanske%netscape.com 1999-06-22 20:19:38 +00:00
parent 2ae131ed77
commit fe50001323
2 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,77 @@
//Cancel() is in EdDialogCommon.js
var editorShell;
var insertNew = true;
var inserted = false;
var tagname = "TAG NAME"
// 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;
}
dump("EditoreditorShell found for NamedAnchor Properties dialog\n");
// 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() {
// Get a single selected element of the desired type
element = editorShell.GetSelectedElement(tagName);
if (element) {
// 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");
element = appCore.createElementWithDefaults(tagName);
}
if(!element)
{
dump("Failed to get selected element or create a new one!\n");
window.close();
}
}
function CreatePixelOrPercentMenu()
{
dump("Creating PixelOrPercent popup menu\n");
}
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);
}
window.close();
}

View File

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>
<?xml-stylesheet href="chrome://editordlgs/skin/EditorDialog.css" type="text/css"?>
<!DOCTYPE window>
<!-- dialog containing a control requiring initial setup -->
<xul:window width="260" height="140" title="Target Properties"
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.w3.org/TR/REC-html40"
onload = "Startup()">
<!-- Methods common to all editor dialogs -->
<script language="JavaScript" src="chrome://editordlgs/content/EdDialogCommon.js">
</script>
<script language="JavaScript" src="chrome://editordlgs/content/EdNamedAnchorProps.js">
</script>
<xul:broadcaster id="args" value=""/>
<table>
<tr>
<td>
Enter a name for this target:<br/>
<input type="text" id="name" size="30"/>
</td>
</tr>
<tr>
<!-- THIS SHOULD BE A XUL FRAGMENT -->
<td align = "right">
<hr width="100%"/>
<xul:box align="horizontal" id="status-bar" width="100%">
<button class="spaced" id="Advanced" onclick="onAdvanced()">Advanced Attributes</button>
<xul:spring flex="100%"/>
<button class="spaced" id="OK" onclick="onOK()">OK</button>
<button class="spaced" id="Cancel" onclick="onCancel()">Cancel</button>
</xul:box>
</td>
</tr>
</table>
</xul:window>