Added main composer toolbar and HLine dialog work

This commit is contained in:
cmanske%netscape.com 1999-06-22 19:12:16 +00:00
Родитель c8ef89364b
Коммит 00a81d1fc0
13 изменённых файлов: 151 добавлений и 78 удалений

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

@ -300,6 +300,20 @@
<box id="outer-box" align="vertical">
<toolbox>
<toolbar>
<titledbutton src="chrome://editor/skin/images/ED_NewFile.gif" align="bottom" value="New" class="popup" onclick="EditorNew()"/>
<titledbutton src="chrome://editor/skin/images/ED_OpenFile.gif" align="bottom" value="Open" class="popup" onclick="EditorOpen()"/>
<titledbutton src="chrome://editor/skin/images/ED_SaveFile.gif" align="bottom" value="Save" class="popup" onclick="EditorSave()"/>
<titledbutton src="chrome://editor/skin/images/ED_Publish.gif" align="bottom" value="Publish" class="popup"/>
<titledbutton src="chrome://editor/skin/images/ED_Preview.gif" align="bottom" value="Preview" class="popup"/>
<titledbutton src="chrome://editor/skin/images/ED_Print.gif" align="bottom" value="Print" class="popup"/>
<titledbutton src="chrome://editor/skin/images/ED_Find.gif" align="bottom" value="Find" onclick="EditorFind()"/>
<titledbutton src="chrome://editor/skin/images/ED_Link.gif" align="bottom" value="Link" onclick="EditorInsertLink()"/>
<titledbutton src="chrome://editor/skin/images/ED_Image.gif" align="bottom" value="Image" onclick="EditorInsertImage()"/>
<titledbutton src="chrome://editor/skin/images/ED_Target.gif" align="bottom" value="Anchor" onclick="EditorInsertNamedAnchor()"/>
<titledbutton src="chrome://editor/skin/images/ED_HLine.gif" align="bottom" value="H.Line" onclick="EditorInsertHLine()"/>
<titledbutton src="chrome://editor/skin/images/ED_Spell.gif" align="bottom" value="Spell" class="popup" onclick="CheckSpelling()"/>
</toolbar>
<toolbar>
<titledbutton id="ParagraphPopup" value="Paragraph" class="popup" align="left" popup="ParagraphMenu"/>
<titledbutton id="FontFacePopup" value="Font" class="popup" align="left" popup="FontFaceMenu"/>
@ -317,10 +331,6 @@
<titledbutton src="chrome://editor/skin/images/ED_Outdent.gif" align="bottom" onclick="EditorIndent('outdent')"/>
<titledbutton src="chrome://editor/skin/images/ED_Indent.gif" align="bottom" onclick="EditorIndent('indent')"/>
<titledbutton src="chrome://editor/skin/images/ED_Align.gif" align="bottom" class="popup" popup="AlignmentMenu"/>
<titledbutton src="chrome://editor/skin/images/ED_Link.gif" align="bottom" onclick="EditorInsertLink()"/>
<titledbutton src="chrome://editor/skin/images/ED_Image.gif" align="bottom" onclick= "EditorInsertImage()"/>
<titledbutton src="chrome://editor/skin/images/ED_HLine.gif" align="bottom" onclick= "EditorInsertHLine()"/>
<titledbutton src="chrome://editor/skin/images/ED_Spell.gif" align="bottom" class="popup" onclick="CheckSpelling()"/>
</toolbar>
</toolbox>

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

@ -41,3 +41,10 @@ images:ED_TextColor.gif
images:ED_BackColor.gif
images:ED_Align.gif
images:ED_ObjectPopup.gif
images:ED_NewFile.gif
images:ED_OpenFile.gif
images:ED_SaveFile.gif
images:ED_Publish.gif
images:ED_Preview.gif
images:ED_Print.gif
images:ED_Find.gif

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

@ -56,6 +56,13 @@ EXPORT_RESOURCE_TOOLBAR = \
$(srcdir)/images/ED_BackColor.gif \
$(srcdir)/images/ED_Align.gif \
$(srcdir)/images/ED_ObjectPopup.gif \
$(srcdir)/images/ED_NewFile.gif \
$(srcdir)/images/ED_OpenFile.gif \
$(srcdir)/images/ED_SaveFile.gif \
$(srcdir)/images/ED_Publish.gif \
$(srcdir)/images/ED_Preview.gif \
$(srcdir)/images/ED_Print.gif \
$(srcdir)/images/ED_Find.gif \
$(NULL)
install::

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

@ -48,6 +48,15 @@ install:: $(DLL)
$(MAKE_INSTALL) images\ED_BackColor.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_Align.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_ObjectPopup.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_NewFile.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_OpenFile.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_SaveFile.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_Publish.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_Preview.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_Print.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_Find.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
clobber::
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\Editor.css
@ -78,4 +87,10 @@ clobber::
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_BackColor.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_Align.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_ObjectPopup.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_NewFile.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_OpenFile.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_SaveFile.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_Publish.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_Preview.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_Print.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_Find.gif

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

@ -1,38 +1,21 @@
// OnOK(), Undo(), and Cancel() are in EdDialogCommon.js
// applyChanges() must be implemented here
var appCore;
var toolkitCore;
//Cancel() is in EdDialogCommon.js
var editorShell;
var insertNew = true;
var undoCount = 0;
var inserted = false;
var tagname = "TAG NAME"
// dialog initialization code
function Startup()
{
dump("Doing Startup...\n");
toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore)
toolkitCore.Init("ToolkitCore");
// 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;
}
if(!toolkitCore) {
dump("toolkitCore not found!!! And we can't close the dialog!\n");
}
// NEVER create an appcore here - we must find parent editor's
// temporary while this window is opend with ShowWindowWithArgs
dump("Getting parent appcore\n");
var editorName = document.getElementById("args").getAttribute("value");
dump("Got editorAppCore called " + editorName + "\n");
appCore = XPAppCoresManager.Find(editorName);
if(!appCore || !toolkitCore) {
dump("EditorAppCore not found!!!\n");
toolkitCore.CloseWindow(window);
return;
}
dump("EditorAppCore found for ???????? dialog\n");
dump("EditoreditorShell found for NamedAnchor Properties dialog\n");
// Create dialog object to store controls for easy access
dialog = new Object;
@ -47,7 +30,7 @@ function Startup()
function initDialog() {
// Get a single selected element of the desired type
element = appCore.getSelectedElement(tagName);
element = editorShell.GetSelectedElement(tagName);
if (element) {
// We found an element and don't need to insert one
@ -64,16 +47,27 @@ function initDialog() {
if(!element)
{
dump("Failed to get selected element or create a new one!\n");
//toolkitCore.CloseWindow(window);
window.close();
}
}
function applyChanges()
function onOK()
{
// Set all attributes from the dialog values, for example:
element.setAttribute("src",dialog.Src.value);
// Set attribute example:
// imageElement.setAttribute("src",dialog.srcInput.value);
if (insertNew) {
appCore.insertElement(element, true)
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();
}

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

@ -19,17 +19,13 @@
<table>
<tr>
<td>
<fieldset><legend align="left">LEGEND TITLE </legend>
</fieldset>
</td>
</tr>
<tr>
<!-- THIS SHOULD BE A XUL FRAGMENT -->
<td align = "right">
<button class="spaced" id="OK" onclick="onOK()" width="50">OK</button>
<button class="spaced" id="Preview" onclick="applyChanges()" width="50">Preview</button>
<button class="spaced" id="Undo" onclick="onUndo()" width="50">Undo</button>
<button class="spaced" id="Cancel" onclick="onCancel()" width="50">Cancel</button>
<button class="spaced" id="OK" onclick="onOK()">OK</button>
<button class="spaced" id="Cancel" onclick="onCancel()">Cancel</button>
</td>
</tr>
</table>

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

@ -2,6 +2,7 @@ var editorShell;
var toolkitCore;
var tagName = "hr";
var hLineElement;
var tempLineElement;
var percentChar = "";
var maxPixels = 10000;
var shading = true;
@ -27,6 +28,13 @@ function Startup()
window.close();
return;
}
// Create a temporary element to use with Save Settings as default
tempLineElement = window.editorShell.editorDocument.createElement("HR");
if (!hLineElement) {
dump("Temporary HLine element was not created!\n");
window.close();
return;
}
// Create dialog object to store controls for easy access
dialog = new Object;
@ -89,8 +97,10 @@ function SetPixelOrPercent(percentString)
function onSaveDefault()
{
if (ValidateData()) {
editorShell.SaveHLineSettings(hLineElement);
// "false" means set attributes on the tempLineElement,
// not the real element being edited
if (ValidateData(false)) {
editorShell.SaveHLineSettings(tempLineElement);
dump("Saving HLine settings to preferences\n");
}
}
@ -100,7 +110,7 @@ function onAdvanced()
//TODO: Call the generic attribute editor ("extra HTML")
}
function ValidateData()
function ValidateData(setAttributes)
{
// Height is always pixels
height = ValidateNumberString(dialog.heightInput.value, 1, maxPixels);
@ -110,7 +120,11 @@ function ValidateData()
return false;
}
dump("Setting height="+height+"\n");
hLineElement.setAttribute("height", height);
if (setAttributes) {
hLineElement.setAttribute("height", height);
} else {
hLineElement.setAttribute("height", height);
}
var maxLimit;
dump("Validate width. PercentChar="+percentChar+"\n");
@ -128,7 +142,12 @@ function ValidateData()
}
width = width + percentChar;
dump("Height="+height+" Width="+width+"\n");
hLineElement.setAttribute("width", width);
if (setAttributes) {
hLineElement.setAttribute("width", width);
} else {
tempLineElement.setAttribute("width", width);
}
align = "left";
if (dialog.centerAlign.checked) {
@ -136,12 +155,24 @@ function ValidateData()
} else if (dialog.rightAlign.checked) {
align = "right";
}
hLineElement.setAttribute("align", align);
if (setAttributes) {
hLineElement.setAttribute("align", align);
} else {
tempLineElement.setAttribute("align", align);
}
if (dialog.shading.checked) {
hLineElement.removeAttribute("noshade");
if (setAttributes) {
hLineElement.removeAttribute("noshade");
} else {
tempLineElement.removeAttribute("noshade");
}
} else {
hLineElement.setAttribute("noshade", "");
if (setAttributes) {
hLineElement.setAttribute("noshade", "");
} else {
tempLineElement.setAttribute("noshade", "");
}
}
return true;
}
@ -151,7 +182,7 @@ function onOK()
// Since we only edit existing HLines,
// ValidateData will set the new attributes
// so there's nothing else to do
if (ValidateData()) {
if (ValidateData(true)) {
window.close();
dump("CLOSING EdHLineProps\n");
}

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

@ -3,7 +3,7 @@
<?xml-stylesheet href="chrome://editordlgs/skin/EditorDialog.css" type="text/css"?>
<!DOCTYPE window>
<!-- dialog containing a control requiring initial setup -->
<xul:window width="280" height="305" title="Horizontal Line Properties"
<xul:window width="280" height="285" title="Horizontal Line Properties"
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.w3.org/TR/REC-html40"
onload = "Startup()">
@ -13,7 +13,7 @@
</script>
<script language="JavaScript" src="chrome://editordlgs/content/EdHLineProps.js">
</script>
<table width="95%">
<table width="95%"> <!-- WIDTH SHOULD BE 100%, BUT BUG PREVENTS THAT -->
<tr>
<td colspan="2">
<fieldset><legend align="left">Dimensions</legend>
@ -58,18 +58,19 @@
<button id="SaveDefault" onclick="onSaveDefault()">Save settings</button>
</td>
</tr>
</table>
<hr class="DividerLine" width="90%"/>
<table width="95%"> <!-- WIDTH SHOULD BE 100%, BUT BUG PREVENTS THAT -->
<tr>
<td colspan="2">
<hr width="100%"/>
<xul:box align="horizontal" id="status-bar">
<td>
<button class="spaced" id="Advanced" onclick="onAdvanced()">Advanced Attributes</button>
<xul:spring flex="100%"/>
</td>
<td align="right">
<button class="spaced" id="OK" onclick="onOK()">OK</button>
<button class="spaced" id="Cancel" onclick="onCancel()" width="50">Cancel</button>
</xul:box>
</td>
</tr>
</table>
<button class="spaced" id="Cancel" onclick="onCancel()">Cancel</button>
</td>
</tr>
</table>
<xul:popup id="PixelOrPercentMenu">
<xul:menu>

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

@ -101,7 +101,6 @@ function onAdvanced()
//dialog.AdvancedRow.style.display = "table-row";
dialog.AdvancedRow.style.visibility = "visible";
}
}
function SelectWidthUnits()

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

@ -10,3 +10,5 @@ EdLinkProps.js
EdLinkProps.xul
EdSpellCheck.js
EdSpellCheck.xul
EdNamedAnchorProps.xul
EdNamedAnchorProps.js

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

@ -36,6 +36,8 @@ EXPORT_RESOURCE_CONTENT = \
$(srcdir)/EdHLineProps.js \
$(srcdir)/EdSpellCheck.xul \
$(srcdir)/EdSpellCheck.js \
$(srcdir)/EdNamedAnchorProps.xul \
$(srcdir)/EdNamedAnchorProps.js \
$(NULL)
install::

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

@ -20,15 +20,17 @@ DEPTH=..\..\..\..
include <$(DEPTH)\config\rules.mak>
install::
$(MAKE_INSTALL) EdDialogCommon.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdLinkProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdLinkProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdImageProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdImageProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdHLineProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdHLineProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdSpellCheck.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdSpellCheck.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdDialogCommon.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdLinkProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdLinkProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdImageProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdImageProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdHLineProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdHLineProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdSpellCheck.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdSpellCheck.js $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdNamedAnchorProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdNamedAnchorProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
clobber::
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdDialogCommon.js
@ -40,3 +42,5 @@ clobber::
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdHLineProps.js
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdSpellCheck.xul
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdSpellCheck.js
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdNamedAnchorProps.xul
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdNamedAnchorProps.js

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

@ -145,3 +145,8 @@ input[type="file"] {
titledbutton.PixelOrPercent {
min-width: 7em;
}
hr.DividerLine {
height: 2px;
}