Added UI for paragraph style and preliminary versions of image and link dialogs

This commit is contained in:
cmanske%netscape.com 1999-05-05 23:29:18 +00:00
parent e9a081a149
commit 5f7dc926d8
18 changed files with 533 additions and 422 deletions

View File

@ -232,6 +232,36 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak()
return result;
}
NS_IMETHODIMP nsHTMLEditor::GetParagraphFormat(nsString& aParagraphFormat)
{
nsresult result = NS_ERROR_NOT_INITIALIZED;
return result;
}
NS_IMETHODIMP nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat)
{
nsresult result = NS_ERROR_NOT_INITIALIZED;
//Kinda sad to waste memory just to force lower case
nsAutoString tag = aParagraphFormat;
tag.ToLowerCase();
if (tag == "normal" || tag == "p") {
result = RemoveParagraphStyle();
} else {
result = ReplaceBlockParent(tag);
}
// XXXX: Horrible hack! We are doing this because
// of an error in Gecko which is not rendering the
// document after a change via the DOM - gpk 2/13/99
// BEGIN HACK!!!
HACKForceRedraw();
// END HACK
return result;
}
// Methods shared with the base editor.
// Note: We could call each of these via nsTextEditor -- is that better?
NS_IMETHODIMP nsHTMLEditor::EnableUndo(PRBool aEnable)
@ -1037,7 +1067,7 @@ NS_IMETHODIMP
nsHTMLEditor::RemoveParent(const nsString &aParentTag)
{
if (gNoisy) {
printf("---------- nsHTMLEditor::RemoveParagraphStyle ----------\n");
printf("---------- nsHTMLEditor::RemoveParent ----------\n");
}
nsresult result=NS_ERROR_NOT_INITIALIZED;

View File

@ -110,6 +110,9 @@ public:
NS_IMETHOD RemoveParagraphStyle();
NS_IMETHOD RemoveParent(const nsString &aParentTag);
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat);
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
NS_IMETHOD InsertLink(nsString& aURL);
NS_IMETHOD InsertImage(nsString& aURL,
nsString& aWidth, nsString& aHeight,

View File

@ -232,6 +232,36 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak()
return result;
}
NS_IMETHODIMP nsHTMLEditor::GetParagraphFormat(nsString& aParagraphFormat)
{
nsresult result = NS_ERROR_NOT_INITIALIZED;
return result;
}
NS_IMETHODIMP nsHTMLEditor::SetParagraphFormat(const nsString& aParagraphFormat)
{
nsresult result = NS_ERROR_NOT_INITIALIZED;
//Kinda sad to waste memory just to force lower case
nsAutoString tag = aParagraphFormat;
tag.ToLowerCase();
if (tag == "normal" || tag == "p") {
result = RemoveParagraphStyle();
} else {
result = ReplaceBlockParent(tag);
}
// XXXX: Horrible hack! We are doing this because
// of an error in Gecko which is not rendering the
// document after a change via the DOM - gpk 2/13/99
// BEGIN HACK!!!
HACKForceRedraw();
// END HACK
return result;
}
// Methods shared with the base editor.
// Note: We could call each of these via nsTextEditor -- is that better?
NS_IMETHODIMP nsHTMLEditor::EnableUndo(PRBool aEnable)
@ -1037,7 +1067,7 @@ NS_IMETHODIMP
nsHTMLEditor::RemoveParent(const nsString &aParentTag)
{
if (gNoisy) {
printf("---------- nsHTMLEditor::RemoveParagraphStyle ----------\n");
printf("---------- nsHTMLEditor::RemoveParent ----------\n");
}
nsresult result=NS_ERROR_NOT_INITIALIZED;

View File

@ -110,6 +110,9 @@ public:
NS_IMETHOD RemoveParagraphStyle();
NS_IMETHOD RemoveParent(const nsString &aParentTag);
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat);
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat);
NS_IMETHOD InsertLink(nsString& aURL);
NS_IMETHOD InsertImage(nsString& aURL,
nsString& aWidth, nsString& aHeight,

View File

@ -57,6 +57,8 @@ public:
const nsString *aAttribute,
const nsString *aValue,
PRBool &aFirst, PRBool &aAll, PRBool &aAny)=0;
NS_IMETHOD GetParagraphFormat(nsString& aParagraphFormat)=0;
NS_IMETHOD SetParagraphFormat(const nsString& aParagraphFormat)=0;
NS_IMETHOD RemoveTextProperty(nsIAtom *aProperty, const nsString *aAttribute)=0;
NS_IMETHOD DeleteSelection(nsIEditor::ECollapsedSelectionAction aAction)=0;
NS_IMETHOD InsertText(const nsString& aStringToInsert)=0;

View File

@ -1,11 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://navigator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://editor/skin/" type="text/css"?>
<!DOCTYPE window
[
<!-- These entity declarations will go into a separare, locale file at some point -->
<!-- These entity declarations will go into a separate, locale file at some point -->
<!-- Window title -->
<!ENTITY editorWindow.title "Editor">
@ -78,7 +78,19 @@
<menuitem name=".Color..." onclick=""/>
<menuitem name=".Remove All Style(s)" onclick=""/>
<separator />
<menuitem name=".Heading" onclick=""/>
<menu name="Paragraph/Heading">
<menuitem name="Normal" onclick="SetParagraphFormat('normal')"/>
<menuitem name="Heading 1" onclick="SetParagraphFormat('h1')"/>
<menuitem name="Heading 2" onclick="SetParagraphFormat('h2')"/>
<menuitem name="Heading 3" onclick="SetParagraphFormat('h3')"/>
<menuitem name="Heading 4" onclick="SetParagraphFormat('h4')"/>
<menuitem name="Heading 5" onclick="SetParagraphFormat('h5')"/>
<menuitem name="Address" onclick="SetParagraphFormat('address')"/>
<menuitem name="Preformat" onclick="SetParagraphFormat('pre')"/>
<menuitem name="List item" onclick="SetParagraphFormat('li')"/>
<menuitem name="Definition term" onclick="SetParagraphFormat('dt')"/>
<menuitem name="Definition description" onclick="SetParagraphFormat('dd')"/>
</menu>
</menu>
<menu name="Tools">
<menuitem name=".Spell Check" onclick=""/>
@ -100,21 +112,43 @@
</menubar>
<box id="outer-box" align="vertical">
<broadcaster id="Editor:Style:IsBold" bold="false"/>
<broadcaster id="Editor:Style:IsItalic"/>
<broadcaster id="Editor:Style:IsUnderline"/>
<box id="outer-box" align="vertical">
<toolbox>
<toolbar>
<titledbutton align="left" class="popup" value="Normal"/>
<titledbutton align="left" class="popup" value="Size"/>
<titledbutton align="left" class="popup" value="Color"/>
<titledbutton src="chrome://editor/skin/images/ED_Bold.gif" align="bottom"
onclick="EditorApplyStyle('b')">
<toolbar>
<!-- Most of the message handlers don't work! -->
<html:select class="combobox" size="1" id="paraFormat" onchange="OnChangeParaFormat()">
<html:optgroup>
<html:option onclick="SetParagraphFormat('normal')">Normal</html:option>
<html:option onclick="SetParagraphFormat('h1')">Heading 1</html:option>
<html:option onclick="SetParagraphFormat('h2')">Heading 2</html:option>
<html:option onclick="SetParagraphFormat('h3')">Heading 3</html:option>
<html:option onclick="SetParagraphFormat('h4')">Heading 4</html:option>
<html:option onclick="SetParagraphFormat('h5')">Heading 5</html:option>
<html:option onclick="SetParagraphFormat('address')">Address</html:option>
<html:option onclick="SetParagraphFormat('li')">List Item</html:option>
<html:option onclick="SetParagraphFormat('dt')">Definition Term</html:option>
<html:option onclick="SetParagraphFormat('dd')">Definition Description</html:option>
</html:optgroup>
</html:select>
<html:select class="combobox" size="1" id="fontSize" onchange="OnChangeFontSize()">
<html:optgroup label="fontSize">
<html:option>-2</html:option>
<html:option>-1</html:option>
<html:option>0</html:option>
<html:option>1</html:option>
<html:option>2</html:option>
<html:option>3</html:option>
<html:option>4</html:option>
</html:optgroup>
</html:select>
<titledbutton align="left" class="popup" value="Color"/>
<titledbutton src="chrome://editor/skin/images/ED_Bold.gif" align="bottom" onclick="EditorApplyStyle('b')">
<observes element="Editor:Style:IsBold" attribute="bold" onchange="onBoldChange()"/>
</titledbutton>
</titledbutton>
<titledbutton src="chrome://editor/skin/images/ED_Italic.gif" align="bottom" onclick="EditorApplyStyle('i')"/>
<titledbutton src="chrome://editor/skin/images/ED_Underline.gif" align="bottom" onclick="EditorApplyStyle('u')"/>
<titledbutton src="chrome://editor/skin/images/ED_ClearStyle.gif" align="bottom" onclick="EditorRemoveStyle('all')"/>
@ -122,13 +156,14 @@
<titledbutton src="chrome://editor/skin/images/ED_Numbers.gif" align="bottom" onclick="EditorInsertList('ol')"/>
<titledbutton src="chrome://editor/skin/images/ED_Indent.gif" align="bottom" onclick="EditorIndent('indent')"/>
<titledbutton src="chrome://editor/skin/images/ED_Left.gif" align="bottom" class="popup" onclick="EditorAlign('left')"/>
<titledbutton src="chrome://editor/skin/images/ED_Link.gif" align="bottom" class="popup" onclick="EditorInsertLink()"/>
<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()"/>
</toolbar>
</toolbox>
<html:iframe type="content" id="content-frame" html:name="content" html:src="chrome://editor/content/EditorInitPage.html" flex="100%" />
<html:iframe type="content" id="content-frame" html:src="chrome://editor/content/EditorInitPage.html" flex="100%" />
</box>
</window>

View File

@ -1,247 +1,219 @@
var editorType = "html";
var editorName = "EditorAppCoreHTML";
/* the following variables are expected to be defined
in the embedding file:
/* Main Composer window UI control */
/*the editor type, i.e. "text" or "html" */
var editorType = "html";
/* the name of the editor. Must be unique to this window clique */
var editorName = "EditorAppCoreHTML";
var appCore = null;
var toolkitCore = null;
var editorType -- the editor type, i.e. "text" or "html"
var editorName -- the name of the editor. Must be unique to this window clique
*/
function Startup()
{
dump("Doing Startup...\n");
/* Get the global Editor AppCore and the XPFE toolkit core into globals here */
appCore = XPAppCoresManager.Find(editorName);
dump("Looking up EditorAppCore...\n");
if (appCore == null) {
dump("Creating EditorAppCore...\n");
appCore = new EditorAppCore();
if (appCore != null) {
if (appCore) {
dump("EditorAppCore has been created.\n");
appCore.Init(editorName);
appCore.setEditorType(editorType);
appCore.setContentWindow(window.frames[0]);
appCore.setWebShellWindow(window);
appCore.setToolbarWindow(window);
appCore.setContentWindow( window.frames[0] );
appCore.setWebShellWindow(window);
appCore.setToolbarWindow(window);
dump("EditorAppCore windows have been set.\n");
}
} else {
dump("EditorAppCore has already been created! Why?\n");
}
toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore) {
toolkitCore.Init("ToolkitCore");
dump("ToolkitCore initialized for Editor\n");
}
} else {
dump("ToolkitCore found\n");
}
}
function EditorFind(firstTime)
{
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore) {
toolkitCore.Init("ToolkitCore");
}
}
if (toolkitCore && firstTime) {
toolkitCore.ShowWindow("resource:/res/samples/find.xul", window);
}
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
appCore.find("test", true, true);
}
}
function EditorShowClipboard()
{
dump("In EditorShowClipboard...\n");
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Doing EditorShowClipboard...\n");
appCore.showClipboard();
}
}
function SetParagraphFormat(paraFormat)
{
if (appCore) {
dump("Doing SetParagraphFormat...\n");
appCore.setParagraphFormat(paraFormat);
}
}
// Debug methods to test the SELECT element used in a toolbar:
function OnChangeParaFormat()
{
dump(" *** Change Paragraph Format combobox setting\n");
}
function OnFocusParaFormat()
{
dump(" *** OnFocus -- Paragraph Format\n");
}
function OnBlurParaFormat()
{
dump(" *** OnBlur -- Paragraph Format\n");
}
function EditorApplyStyle(styleName)
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Applying Style\n");
appCore.setTextProperty(styleName, null, null);
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorRemoveStyle(styleName)
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Removing Style\n");
appCore.removeTextProperty(styleName, null);
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorGetText()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Getting text\n");
var outputText = appCore.contentsAsText;
dump(outputText + "\n");
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorGetHTML()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Getting HTML\n");
var outputText = appCore.contentsAsHTML;
dump(outputText + "\n");
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorUndo()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Undoing\n");
appCore.undo();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorRedo()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Redoing\n");
appCore.redo();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorCut()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Cutting\n");
appCore.cut();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorCopy()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Copying\n");
appCore.copy();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorPaste()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Pasting\n");
appCore.paste();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorSelectAll()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Selecting all\n");
appCore.selectAll();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorInsertText()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Inserting text\n");
appCore.insertText("Once more into the breach, dear friends.\n");
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorInsertLink()
{
dump("Starting Insert Link...\n");
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
dump("Link Properties Dialog starting...\n");
var toolkitCore = GetToolkitCore();
if (toolkitCore) {
toolkitCore.ShowModalDialog("chrome://editordlgs/content/EdLinkProps.xul",
window);
}
} else {
dump("EditorAppCore has not been created!\n");
dump("Starting Insert Link... appCore, toolkitCore: "+(appCore==null)+(toolkitCore==null)+"\n");
if (appCore && toolkitCore) {
dump("Link Properties Dialog starting...\n");
toolkitCore.ShowModalDialog("chrome://editordlgs/content/EdLinkProps.xul",
window);
}
}
function EditorInsertList(listType)
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Inserting link\n");
appCore.insertList(listType);
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorInsertImage()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
dump("Inserting image\n");
appCore.insertImage();
} else {
dump("EditorAppCore has not been created!\n");
dump("Starting Insert Image...\n");
if (appCore && toolkitCore) {
dump("Link Properties Dialog starting...\n");
toolkitCore.ShowModalDialog("chrome://editordlgs/content/EdImageProps.xul",
window);
}
}
function EditorExit()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null) {
if (appCore) {
dump("Exiting\n");
appCore.exit();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorPrintPreview() {
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore)
toolkitCore.Init("ToolkitCore");
}
if (toolkitCore) {
toolkitCore.ShowWindow("resource:/res/samples/printsetup.html", window);
}
@ -250,8 +222,7 @@ function EditorInsertLink()
function EditorTestSelection()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null)
if (appCore)
{
dump("Testing selection\n");
var selection = appCore.editorSelection;
@ -266,17 +237,12 @@ function EditorInsertLink()
}
}
}
else
{
dump("EditorAppCore has not been created!\n");
}
}
function EditorTestDocument()
{
appCore = XPAppCoresManager.Find(editorName);
if (appCore != null)
if (appCore)
{
dump("Getting document\n");
var theDoc = appCore.editorDocument;
@ -290,10 +256,6 @@ function EditorInsertLink()
{
dump("Failed to get the doc\n");
}
}
else
{
dump("EditorAppCore has not been created!\n");
}
}
@ -319,12 +281,3 @@ function EditorInsertLink()
}
}
function GetToolkitCore() {
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore)
toolkitCore.Init("ToolkitCore");
}
return toolkitCore;
}

View File

@ -19,7 +19,7 @@ the writings of my later "hard-livin" years. It's titled "Reruns":
<blockquote>
<h4>Reruns</h4>
Reruns are about as much fun,<br>
as your dad taking all your mon,<br>
as your dad taking all your money,<br>
and giving it to a nun,<br>
as a contribution.
</blockquote>

View File

@ -0,0 +1,40 @@
/* These are critical - should be in xul.css */
window#main-window {
width: 100%;
height: 100%;
}
box#outer-box {
width: 100%;
height: 100%;
}
select#paraFormat {
}
select#fontFace {
}
select#fontSize {
}
select.combobox {
font-family: Sans-Serif;
font-size: 8pt;
border-top: 3px;
border-left: 4px;
border-right: 4px;
border-style: outset;
//background: silver;
}
select[pseudoclass~="hover"] {
/* NOT WORKING */
background: red;
}
p, br, td {
font-color: red;
background-color: #ffffcc
}

View File

@ -20,6 +20,7 @@ DEPTH=..\..\..\..
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) Editor.css $(DIST)\bin\chrome\editor\composer\skin\default
$(MAKE_INSTALL) images\ED_Bold.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_Bullets.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
$(MAKE_INSTALL) images\ED_Center.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
@ -45,6 +46,7 @@ install:: $(DLL)
$(MAKE_INSTALL) images\ED_Undo.gif $(DIST)\bin\chrome\editor\composer\skin\default\images
clobber::
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\Editor.css
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_Bold.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_Bullets.gif
rm -f $(DIST)\bin\chrome\editor\composer\skin\default\images\ED_Center.gif

View File

@ -7,87 +7,6 @@
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload = "Startup()">
<html:script>
// dialog initialization code
function Startup()
{
dump("Doing Startup...\n");
appCore = XPAppCoresManager.Find("EditorAppCore");
dump("Looking up EditorAppCore...\n");
if (appCore == null) {
dump("Creating EditorAppCore...\n");
appCore = new EditorAppCore();
if (appCore != null) {
dump("EditorAppCore has been created.\n");
appCore.Init("EditorAppCore");
// appCore.setContentWindow(window.frames[0]);
// appCore.setWebShellWindow(window);
// appCore.setToolbarWindow(window);
dump("Adding EditorAppCore to AppCoreManager...\n");
XPAppCoresManager.Add(appCore);
}
} else {
dump("EditorAppCore has already been created! Why?\n");
}
}
function EditorCut()
{
appCore = XPAppCoresManager.Find("EditorAppCore");
if (appCore != null) {
dump("Cutting\n");
appCore.cut();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorCopy()
{
appCore = XPAppCoresManager.Find("EditorAppCore");
if (appCore != null) {
dump("Copying\n");
appCore.copy();
} else {
dump("EditorAppCore has not been created!\n");
}
}
function EditorPaste()
{
appCore = XPAppCoresManager.Find("EditorAppCore");
if (appCore != null) {
dump("Pasting\n");
appCore.paste();
} else {
dump("EditorAppCore has not been created!\n");
}
}
// find and return the DOM element with the given ID
// the equivalent of document.getElementById(), but also
// works for XML documents (unused in the example)
function ElementByID(id) {
var element;
var ctr;
var taglist = document.getElementsByTagName("*");
element = null;
for (ctr = 0; ctr < taglist.length; ctr++)
if (taglist[ctr].getAttribute("id") == id) {
element = taglist[ctr];
break;
}
return element;
}
<html:script language="JavaScript" src="chrome://editordlgs/content/EdCharacterProps.js">
</html:script>
<table xmlns="http://www.w3.org/TR/REC-html40">
<tr>
<td><button onclick="EditorCopy()">Copy</button></td>
<td><button onclick="EditorCut()">Cut</button></td>
<td><button onclick="EditorPaste()">Paste</button></td>
</tr>
</table>
</xul:window>

View File

@ -1,57 +1,51 @@
<?xml version="1.0"?>
<?xml-stylesheet href="xul.css" type="text/css"?>
<?xml-stylesheet href="EditorDialog.css" type="text/css"?>
<?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="200" height="200"
xmlns:html="http://www.w3.org/TR/REC-html40"
<xul:window width="370" height="255" title="Image Properties"
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.w3.org/TR/REC-html40"
onload = "Startup()">
<html:script>
// dialog initialization code
function Startup()
{
dump("Doing Startup...\n");
appCore = XPAppCoresManager.Find("EditorAppCore");
if (appCore == null) {
dump("EditorAppCore has NOT been created!\n");
} else {
dump("EditorAppCore was found\n");
}
}
// find and return the DOM element with the given ID
// the equivalent of document.getElementById(), but also
// works for XML documents (unused in the example)
function ElementByID(id) {
var element;
var ctr;
var taglist = document.getElementsByTagName("*");
element = null;
for (ctr = 0; ctr < taglist.length; ctr++)
if (taglist[ctr].getAttribute("id") == id) {
element = taglist[ctr];
break;
}
return element;
}
</html:script>
<table xmlns="http://www.w3.org/TR/REC-html40">
<script language="JavaScript" src="chrome://editordlgs/content/EdImageProps.js">
</script>
<table>
<tr>
<td width="500">
<fieldset><legend align="left"> <xul:checkbox value="Image Location and Name"/>Image Location and Name </legend>
<td>
<fieldset><legend align="left">Image Information </legend>
<input type="file" value=" Choose File... " size="50" length="50" maxlength="255" id="image.url" />
<br/>
<p class="smallmargin">Alternative Text</p>
<input type="text" size="30" length="30" maxlength="255" id="image.AltText" />
</fieldset>
</td>
</tr>
<tr>
<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>
</td>
</tr>
</table>
</xul:window>
<!-- The old stuff:
<table>
<tr>
<td>
<fieldset><legend align="left">Image Location and Name </legend>
<input type="file" value=" Choose File... " size="50" length="50" maxlength="255" name="image.url" />
<br/>
<xul:checkbox value="Leave Image at Original Location" disabled />
<xul:checkbox value="1"/>
Leave Image at Original Location
<xul:checkbox value="Page Background" disabled />
<xul:checkbox value="1"/>
Page Background
<input type="button" value=" Edit Image " disabled />
<input type="button" value=" Edit Image "/>
<br/>
Alternative Text
<input type="text" size="30" length="30" maxlength="255" name="image.alttext" />
@ -67,13 +61,13 @@
<xul:radio name="image.dimensionType" value="Custom Size" />
Custom Size
<table cellspacing="0" cellpadding="2" width="100%" valign="top">
<table>
<tr>
<td width="8"></td>
<td width="40" valign="middle" align="right">
<p>Height</p>
</td>
<td valign="middle">
<td>
<input type="text" size="4" length="4" maxlength="4" name="image.height" />
<select size="1" name="image.heightType">
<optgroup label="pixels">
@ -100,8 +94,6 @@
</tr>
<tr>
<td/>
<td/>
<td>
<p>
<xul:checkbox value="Constrain" disabled />
@ -141,7 +133,7 @@
</td>
</tr>
<tr valign="middle">
<tr>
<td>
<p>Top and Bottom</p>
</td>
@ -153,7 +145,7 @@
</td>
</tr>
<tr valign="middle">
<tr>
<td align="right">
<p>Solid Border</p>
</td>
@ -187,5 +179,5 @@
</td>
</tr>
</table>
-->
</xul:window>

View File

@ -1,106 +1,157 @@
var appCore;
var toolkitCore;
var appCore;
var toolkitCore;
var anchorElement = null;
var insertNew = true;
var needLinkText = false;
var selectionIsCollapsed = false;
var undoCount = 0;
var editElement = null;
var insertNew = true;
// NOTE: Use "HREF" instead of "A" to distinguish from Named Anchor
// The returned node is has an "A" tagName
var tagName = "HREF";
var data;
var dialog;
// NOTE: Use "HREF" instead of "A" to distinguish from Named Anchor
// The returned nodes will have the "A" tagName
var tagName = "HREF";
// dialog initialization code
function Startup() {
dump("Doing Startup...\n");
toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore)
toolkitCore.Init("ToolkitCore");
}
if(!toolkitCore) {
dump("toolkitCore not found!!! And we can't close the dialog!\n");
}
// dialog initialization code
function Startup() {
dump("Doing Startup...\n");
toolkitCore = GetToolkitCore();
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
appCore = XPAppCoresManager.Find("EditorAppCoreHTML");
if(!appCore || !toolkitCore) {
dump("EditorAppCore not found!!!\n");
toolkitCore.CloseWindow();
}
dump("EditorAppCore found for Link Properties dialog\n");
// Get a single selected element and edit its properites
editElement = appCore.getSelectedElement(tagName);
// NEVER create an appcore here - we must find parent editor's
appCore = XPAppCoresManager.Find("EditorAppCoreHTML");
if(!appCore || !toolkitCore) {
dump("EditorAppCore not found!!!\n");
toolkitCore.CloseWindow(window);
}
dump("EditorAppCore found for Link Properties dialog\n");
// Create dialog object to store controls for easy access
dialog = new Object;
dialog.linkTextInput = document.getElementById("linkTextInput");
dialog.hrefInput = document.getElementById("hrefInput");
dialog.linkMessage = document.getElementById("linkMessage");
dialog.ok = document.getElementById("OK");
if (editElement) {
// We found an element and don't need to insert it
insertNew = false;
} else {
// We don't have an element selected,
// so create one with default attributes
dump("Element not selected - calling createElementWithDefaults\n");
editElement = appCore.createElementWithDefaults(tagName);
}
if (null == dialog.linkTextInput ||
null == dialog.hrefInput ||
null == dialog.linkMessage ||
null == dialog.ok )
{
dump("Not all dialog controls were found!!!\n");
}
if(!editElement)
{
dump("Failed to get selected element or create a new one!\n");
toolkitCore.CloseWindow(window);
}
dump("GetSelectedElement...\n");
hrefInput = document.getElementById("textHREF");
// Set the input element value to current HREF
if (hrefInput)
{
dump("Setting HREF editbox value\n");
hrefInput.value = editNode.href;
}
}
function applyChanges() {
// Set the input element value to current HREF
hrefInput = document.getElementById("textHREF");
if (hrefInput)
{
dump("Copying edit field HREF value to node attribute\n");
editElement.setAttribute("href",hrefInput.value);
}
// Get text to use for a new link
if (insertNew)
{
textLink = document.getElementById("textLink");
if (textLink)
{
// Append the link text as the last child node
// of the docFrag
textNode = appCore.editorDocument.createTextNode(textLink.value);
if (textNode)
{
editElement.appendChild(textNode);
dump("Text for new link appended to HREF node\n");
newElement = appCore.insertElement(editElement, true);
if (newElement != editElement)
{
dump("Returned element from insertElement is different from orginal element.\n");
}
}
}
// Once inserted, we can modify properties, but don't insert again
insertNew = false;
}
if (!insertNew)
{
var parent = dialog.linkTextInput.parentNode;
if (parent) {
parent.removeChild(dialog.linkTextInput);
dialog.linkTextInput = null;
// TODO: Replace the text with the currently-selected text
}
}
initDialog();
}
function onOK() {
applyChanges();
toolkitCore.CloseWindow(window);
}
function initDialog() {
// Get a single selected anchor element
anchorElement = appCore.getSelectedElement(tagName);
function onCancel() {
dump("Calling CloseWindow...\n");
toolkitCore.CloseWindow(window);
}
selection = appCore.editorSelection;
if (selection)
{
selectionIsCollapsed = selection.selectionIsCollapsed;
dump("There is a selection: collapsed = "+selectionIsCollapsed+"\n");
} else {
dump("Failed to get selection\n");
}
function GetToolkitCore() {
var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
if (!toolkitCore) {
toolkitCore = new ToolkitCore();
if (toolkitCore)
toolkitCore.Init("ToolkitCore");
}
return toolkitCore;
if (anchorElement) {
// We found an element and don't need to insert one
insertNew = false;
// BUT href is a weird case: If selection extends beyond
// the link, user probably wants to extend link to
// entire selection. We do this by "inserting" the link
// (actually does the appropriate reparenting)
if (!selectionIsCollapsed)
{
insertNew = true;
}
} else {
insertNew = true;
// We don't have an element selected,
// so create one with default attributes
dump("Element not selected - calling createElementWithDefaults\n");
anchorElement = appCore.createElementWithDefaults(tagName);
}
if(!anchorElement)
{
dump("Failed to get selected element or create a new one!\n");
toolkitCore.CloseWindow(window);
}
}
function applyChanges()
{
// Coalesce into one undo transaction
appCore.beginBatchChanges();
// Set the HREF directly on the editor document's anchor node
// or on the newly-created node if insertNew is true
anchorElement.setAttribute("href",dialog.hrefInput.value);
// Get text to use for a new link
if (insertNew)
{
// Append the link text as the last child node
// of the anchor node
textNode = appCore.editorDocument.createTextNode(dialog.linkTextInput.value);
if (textNode)
{
anchorElement.appendChild(textNode);
}
newElement = appCore.insertElement(anchorElement, true);
if (newElement != anchorElement)
{
dump("Returned element from insertElement is different from orginal element.\n");
}
}
undoCount = undoCount + 1;
appCore.endBatchChanges();
// Reinitialize dialog data
initDialog();
}
function onUndo() {
if (undoCount > 0)
{
dump("Undo count = "+undoCount+"\n");
undoCount = undoCount - 1;
appCore.undo();
}
}
function onOK() {
applyChanges();
//toolkitCore.CloseWindow(window);
}
function onCancel() {
// Undo all actions performed within the dialog
// TODO: We need to suppress reflow/redraw untill all levels are undone
while (undoCount > 0) {
appCore.undo();
}
//toolkitCore.CloseWindow(window);
}

View File

@ -2,40 +2,38 @@
<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>
<?xml-stylesheet href="chrome://editordlgs/skin/EditorDialog.css" type="text/css"?>
<!DOCTYPE window>
<xul:window width="380" height="240"
xmlns:html="http://www.w3.org/TR/REC-html40"
<xul:window width="320" height="255" title="Link Properties"
xmlns:xul ="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.w3.org/TR/REC-html40"
onload = "Startup()">
<html:script>
</html:script>
<html:script language="JavaScript" src="chrome://editordlgs/content/EdLinkProps.js">
</html:script>
<html:table>
<html:tr>
<html:td>
<html:fieldset><html:legend align="left">Link source </html:legend>
Enter text to display for a new link:<html:br/>
<html:input type="text" size="25" length="25" maxlength="100" name="textLink" html:id="textLink"></html:input>
</html:fieldset>
</html:td>
</html:tr>
<html:tr>
<html:td>
<html:fieldset><html:legend align="left">Link to </html:legend>
Enter a web page location or local file:<html:br/>
<html:input type="text" size="25" length="25" maxlength="100" name="textHREF" html:id="textHREF"></html:input>
</html:fieldset>
</html:td>
</html:tr>
<html:tr>
<html:td align = "right">
<html:button onclick="onOK();">OK</html:button>
<html:button onclick="onCancel();">Cancel</html:button>
</html:td>
</html:tr>
</html:table>
<script language="JavaScript" src="chrome://editordlgs/content/EdLinkProps.js">
</script>
<table>
<tr>
<td>
<fieldset><legend align="left">Link source </legend>
<p class="smallmargin" id="linkMessage"> Enter text to display for a new link:</p>
<input type="text" size="25" length="25" maxlength="100" id="linkTextInput"></input>
</fieldset>
</td>
</tr>
<tr>
<td>
<fieldset><legend align="left">Link to </legend>
<p class="smallmargin">Enter a web page location or local file:
<button class="ChooseFile" id="ChooseFile" align="top">Choose File</button></p>
<input type="text" size="25" length="25" maxlength="100" id="hrefInput"></input>
</fieldset>
</td>
</tr>
<tr>
<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>
</td>
</tr>
</table>
</xul:window>

View File

@ -31,6 +31,8 @@ EXPORT_RESOURCE_CONTENT = \
$(srcdir)/EdImageProps.xul \
$(srcdir)/EdCharacterProps.xul \
$(srcdir)/EdLinkProps.js \
$(srcdir)/EdImageProps.js \
$(srcdir)/EdCharacterProps.js \
$(NULL)
install::

View File

@ -23,10 +23,14 @@ install::
$(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) EdCharacterProps.xul $(DIST)\bin\chrome\editor\dialogs\content\default
$(MAKE_INSTALL) EdCharacterProps.js $(DIST)\bin\chrome\editor\dialogs\content\default
clobber::
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdLinkProps.xul
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdLinkProps.js
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdImageProps.xul
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdImageProps.js
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdCharacterProps.xul
rm -f $(DIST)\bin\chrome\editor\dialogs\content\default\EdCharacterProps.js

View File

@ -9,15 +9,40 @@ window, WINDOW {
font-size: 8pt;
}
/* Defeat the default behavior of borderless until rollover */
button { border: 2px outset }
/* values = margin, padding. Padding doesn't work yet */
checkbox, CHECKBOX { margin: 5px 3px }
checkbox { margin: 5px 3px }
radio, RADIO { margin: 5px 3px }
tristatecheckbox {
/* DOESN'T WORK! */
margin-top: 3px;
margin-bottom:3px;
margin-left: 2px;
margin-right: 2px;
border-style: inset;
background-color: #ffffff;
valign: center;
align: center;
}
tree, TREE {
select.combobox {
font-family: Sans-Serif;
font-size: 8pt;
border-top: 2px;
border-left: 4px;
border-right: 2px;
border-style: outset;
}
.checkboxtext {
margin-top: -9px;
margin-left: 3px;
margin-right: 5px;
margin-bottom: 2px;
}
radio { margin: 5px 3px }
tree {
display: table;
background-color: #000000;
border: none;
@ -30,10 +55,8 @@ tree, TREE {
/* Force all rows to line up cell contents at the top */
tr, TR { vertical-align: top }
/* FOR DEBUG PURPOSE -- SHOW CELL BORDER */
td, TD { border-width: 0px; border-style: inset }
table, TABLE { border-width: 0px }
/* FOR DEBUG PURPOSE -- use border-width: 1px */
td, table { border-width: 0px; }
p, br, td {
font-family: Sans-Serif;
@ -42,15 +65,18 @@ p, br, td {
margin-bottom: 4px
}
fieldset, FIELDSET {
border-width: 3px;
p.smallmargin { margin-bottom: 2px }
fieldset {
border-width: 2px;
border-style: groove;
padding: 3px;
margin: 5px;
padding: 5px;
/* BUG: If this is set, border is chopped off at the right */
/* margin: 5px; */
text-align: left;
}
legend, LEGEND {
legend {
font-family: Sans-Serif;
font-size: 10pt;
border-width: 0;
@ -58,14 +84,27 @@ legend, LEGEND {
}
/* CLASSES */
[CLASS~=GrooveBorder] { border: 2px groove; padding: 3px }
/* Use these primarily with TD to create 3D "panels" */
.GrooveBorder { border: 2px groove; padding: 5px }
[CLASS~=RidgeBorder] { border: 2px ridge; padding: 3px }
.RidgeBorder { border: 2px ridge; padding: 5px }
[CLASS~=OutsetBorder] { border: 1px outset; padding: 3px }
.OutsetBorder { border: 1px outset; padding: 5px }
[CLASS~=InsetBorder] { border: 1px inset; padding: 3px }
.InsetBorder { border: 1px inset; padding: 5px }
button.spaced {
/* BUG - Setting size doesn't work?
width: 80px;
height: 20px;
*/
margin: 5px;
}
button.ChooseFile {
margin-bottom: 3px;
margin-right: 5px;
}
.tableCenterAlign {
vertical-align: middle;
@ -78,6 +117,14 @@ legend, LEGEND {
margin-bottom: 5px;
}
.spacedtext {
margin-top: 0px;
margin-left: 3px;
margin-right: 5px;
margin-bottom: 2px;
}
/* IDs only one button per dialog */
#okbutton {
width: 80px;

View File

@ -19,7 +19,7 @@ the writings of my later "hard-livin" years. It's titled "Reruns":
<blockquote>
<h4>Reruns</h4>
Reruns are about as much fun,<br>
as your dad taking all your mon,<br>
as your dad taking all your money,<br>
and giving it to a nun,<br>
as a contribution.
</blockquote>