diff --git a/editor/ui/composer/content/EditorAppShell.xul b/editor/ui/composer/content/EditorAppShell.xul index 808fcc940e5..c707e01de6b 100644 --- a/editor/ui/composer/content/EditorAppShell.xul +++ b/editor/ui/composer/content/EditorAppShell.xul @@ -207,6 +207,7 @@ + @@ -451,6 +452,9 @@ + + + @@ -499,8 +503,8 @@ - - + + @@ -509,7 +513,8 @@ - + + diff --git a/editor/ui/composer/content/EditorCommands.js b/editor/ui/composer/content/EditorCommands.js index 111348de97d..1d291c128b7 100644 --- a/editor/ui/composer/content/EditorCommands.js +++ b/editor/ui/composer/content/EditorCommands.js @@ -20,6 +20,7 @@ var toolbar; var documentModified; +var EditorDisplayStyle = true; function EditorStartup(editorType) { @@ -445,6 +446,26 @@ function EditorAlign(align) contentWindow.focus(); } +function EditorToggleDisplayStyle() +{ + if (EditorDisplayStyle) { + EditorDisplayStyle = false; + styleSheet = "resource:/res/ua.css"; + //TODO: Where do we store localizable JS strings? + buttonText = "Preview"; + } + else { + EditorDisplayStyle = true; + styleSheet = "chrome://editor/content/EditorContent.css" + buttonText = "Edit Mode"; + } + EditorApplyStyleSheet(styleSheet); + + button = document.getElementById("DisplayStyleButton"); + if (button) + button.setAttribute("value",buttonText); +} + function EditorPrintPreview() { window.openDialog("resource:/res/samples/printsetup.html", "PrintPreview", "chrome", ""); diff --git a/editor/ui/composer/content/EditorContent.css b/editor/ui/composer/content/EditorContent.css new file mode 100644 index 00000000000..f164edbc95e --- /dev/null +++ b/editor/ui/composer/content/EditorContent.css @@ -0,0 +1,23 @@ +/* Styles to alter look of things in the Editor content window */ + +a[name] { + display: inline; /*-block;*/ /* the new feature */ + min-width: 10px; + width: 10px; + height: 10px; + background-image: url(chrome://editor/skin/images/ED_Left.gif); + border: 1px solid blue; +} + +table { + empty-cells: show; +} + +table[empty-cells=show] { + border: 1px dotted red; +} + +td, tr { + min-height: 10px; + min-line-height: 10px; +} diff --git a/editor/ui/composer/content/MANIFEST b/editor/ui/composer/content/MANIFEST index 2d30b6dee95..8cfe61638da 100644 --- a/editor/ui/composer/content/MANIFEST +++ b/editor/ui/composer/content/MANIFEST @@ -8,3 +8,4 @@ EditorInitPage.html EditorInitPagePlain.html editor.properties EditorStyles1.css +EditorContent.css diff --git a/editor/ui/composer/content/Makefile.in b/editor/ui/composer/content/Makefile.in index 8afa08b38a0..c72112832a4 100644 --- a/editor/ui/composer/content/Makefile.in +++ b/editor/ui/composer/content/Makefile.in @@ -34,6 +34,7 @@ EXPORT_RESOURCE_CONTENT = \ $(srcdir)/EditorInitPagePlain.html \ $(srcdir)/editor.properties \ $(srcdir)/EditorStyles1.css \ + $(srcdir)/EditorContent.css \ $(NULL) install:: diff --git a/editor/ui/composer/content/makefile.win b/editor/ui/composer/content/makefile.win index 5546572708f..131d736a73a 100644 --- a/editor/ui/composer/content/makefile.win +++ b/editor/ui/composer/content/makefile.win @@ -27,6 +27,7 @@ install:: $(MAKE_INSTALL) EditorInitPagePlain.html $(DIST)\bin\chrome\editor\composer\content\default $(MAKE_INSTALL) editor.properties $(DIST)\bin\chrome\editor\composer\content\default $(MAKE_INSTALL) EditorStyles1.css $(DIST)\bin\chrome\editor\composer\content\default + $(MAKE_INSTALL) EditorContent.css $(DIST)\bin\chrome\editor\composer\content\default clobber:: rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorAppShell.xul @@ -36,3 +37,4 @@ clobber:: rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorInitPagePlain.html rm -f $(DIST)\bin\chrome\editor\composer\content\default\editor.properties rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorStyles1.css + rm -f $(DIST)\bin\chrome\editor\composer\content\default\EditorContent.css diff --git a/editor/ui/dialogs/content/EdDialogCommon.js b/editor/ui/dialogs/content/EdDialogCommon.js index 570315ddb3b..4676748eae9 100644 --- a/editor/ui/dialogs/content/EdDialogCommon.js +++ b/editor/ui/dialogs/content/EdDialogCommon.js @@ -1,6 +1,9 @@ // Each editor window must include this file // Variables shared by all dialogs: var editorShell; +var SelectionOnly=1; +var FormatedWithDoctype=2; +var FormatedWithoutDoctype=6; function InitEditorShell() { @@ -329,3 +332,7 @@ function onCancel() window.close(); } +function GetSelectionAsText() +{ + return editorShell.GetContentsAs("text/plain", SelectionOnly); +} \ No newline at end of file diff --git a/editor/ui/dialogs/content/EdLinkProps.js b/editor/ui/dialogs/content/EdLinkProps.js index ae9d81f8cf3..c6e4e9f16d6 100644 --- a/editor/ui/dialogs/content/EdLinkProps.js +++ b/editor/ui/dialogs/content/EdLinkProps.js @@ -105,7 +105,7 @@ function initDialog() } else if (!insertNew && !imageElement) { // Replace the link message with the link source string - selectedText = editorShell.selectionAsText; + selectedText = GetSelectionAsText(); if (selectedText.length > 0) { // Use just the first 50 characters and add "..." selectedText = TruncateStringAtWordEnd(selectedText, 50, true); @@ -143,29 +143,36 @@ function onOK() { // TODO: VALIDATE FIELDS BEFORE COMMITING CHANGES - // Coalesce into one undo transaction - editorShell.BeginBatchChanges(); + href = TrimString(dialog.hrefInput.value); + if (href.length > 0) { + // Coalesce into one undo transaction + editorShell.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); + // Set the HREF directly on the editor document's anchor node + // or on the newly-created node if insertNew is true + anchorElement.setAttribute("href",href); - // Get text to use for a new link - if (insertNew) { - // Append the link text as the last child node - // of the anchor node - dump("Creating text node\n"); - textNode = editorShell.editorDocument.createTextNode(dialog.linkTextInput.value); - if (textNode) { - anchorElement.appendChild(textNode); + // Get text to use for a new link + if (insertNew) { + // Append the link text as the last child node + // of the anchor node + dump("Creating text node\n"); + textNode = editorShell.editorDocument.createTextNode(dialog.linkTextInput.value); + if (textNode) { + anchorElement.appendChild(textNode); + } + dump("Inserting\n"); + editorShell.InsertElement(anchorElement, false); + } else if (insertLinkAroundSelection) { + dump("Setting link around selected text\n"); + editorShell.InsertLinkAroundSelection(anchorElement); } - dump("Inserting\n"); - editorShell.InsertElement(anchorElement, false); - } else if (insertLinkAroundSelection) { - dump("Setting link around selected text\n"); - editorShell.InsertLinkAroundSelection(anchorElement); + editorShell.EndBatchChanges(); + } else if (!insertNew) { + // We already had a link, but empty HREF means remove it + // TODO: IMPLEMENT REMOVE LINK + } - editorShell.EndBatchChanges(); window.close(); } diff --git a/editor/ui/dialogs/content/EdMessage.js b/editor/ui/dialogs/content/EdMessage.js index bda854429c1..70f22396a4a 100644 --- a/editor/ui/dialogs/content/EdMessage.js +++ b/editor/ui/dialogs/content/EdMessage.js @@ -48,10 +48,10 @@ function Startup() // We must have a message window.close(); } - title = window.arguments[2]; - if (title.length > 0) { - // BUG 9722: Not implemented yet. - //document.title = title; + titleText = window.arguments[2]; + if (titleText.length > 0) { + dump(titleText+" is the message dialog title\n"); + window.title = titleText; } button1 = document.getElementById("button1"); diff --git a/editor/ui/dialogs/content/EdNamedAnchorProps.js b/editor/ui/dialogs/content/EdNamedAnchorProps.js index 870333c1f2e..c1f2f5e2cfa 100644 --- a/editor/ui/dialogs/content/EdNamedAnchorProps.js +++ b/editor/ui/dialogs/content/EdNamedAnchorProps.js @@ -1,18 +1,17 @@ var insertNew = true; var tagName = "anchor" var anchorElement = null; +var nameInput; // dialog initialization code function Startup() { if (!InitEditorShell()) 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.nameInput = document.getElementById("name"); + dump("EditorShell found for NamedAnchor Properties dialog\n"); + dump(document+"\n"); + nameInput = document.getElementById("nameInput"); + dump(nameInput+"\n"); // Get a single selected element of the desired type anchorElement = editorShell.GetSelectedElement(tagName); @@ -21,7 +20,7 @@ function Startup() // We found an element and don't need to insert one insertNew = false; dump("Found existing anchor\n"); - dialog.nameInput.value = anchorElement.getAttribute("name"); + nameInput.value = anchorElement.getAttribute("name"); } else { insertNew = true; // We don't have an element selected, @@ -29,12 +28,13 @@ function Startup() dump("Element not selected - calling createElementWithDefaults\n"); anchorElement = editorShell.CreateElementWithDefaults(tagName); // Use the current selection as suggested name - name = editorShell.selectionAsText; + name = GetSelectionAsText(); // Get 40 characters of the selected text and don't add "..." name = TruncateStringAtWordEnd(name, 40, false); // Replace whitespace with "_" name = ReplaceWhitespace(name, "_"); - dialog.nameInput.value = name; + dump("Selection text for name: "+name+"\n"); + nameInput.value = name; } if(!anchorElement) @@ -43,12 +43,12 @@ function Startup() window.close(); } - dialog.nameInput.focus(); + nameInput.focus(); } function onOK() { - name = dialog.nameInput.value; + name = nameInput.value; name = TrimString(name); if (name.length == 0) { dump("EMPTY ANCHOR STRING\n"); diff --git a/editor/ui/dialogs/content/EdNamedAnchorProps.xul b/editor/ui/dialogs/content/EdNamedAnchorProps.xul index df7b0f395b0..5e78e6aa0da 100644 --- a/editor/ui/dialogs/content/EdNamedAnchorProps.xul +++ b/editor/ui/dialogs/content/EdNamedAnchorProps.xul @@ -6,10 +6,10 @@ - + - + ]> @@ -29,22 +29,14 @@
- - +
+
-
- +