diff --git a/editor/ui/dialogs/content/EdColorPicker.js b/editor/ui/dialogs/content/EdColorPicker.js
index c950e0293e7..5458edf5249 100644
--- a/editor/ui/dialogs/content/EdColorPicker.js
+++ b/editor/ui/dialogs/content/EdColorPicker.js
@@ -19,6 +19,7 @@
*
* Contributor(s):
* Daniel Glazman (glazman@netscape.com)
+ * Charles Manske (cmanske@netscape.com)
*/
@@ -69,13 +70,10 @@ function Startup()
var prefs = GetPrefs();
var IsCSSPrefChecked = prefs.getBoolPref("editor.use_css");
- editorShell = window.opener.editorShell;
- if (editorShell)
+ if (GetCurrentEditor())
{
- editorShell = editorShell.QueryInterface(Components.interfaces.nsIEditorShell);
-
window.title = GetString(ColorType+"Color");
- if (editorShell && ColorType == "Page" && IsCSSPrefChecked && editorShell.editorType == "html")
+ if (ColorType == "Page" && IsCSSPrefChecked && isHTMLEditor())
window.title = GetString("BlockColor");
}
}
diff --git a/editor/ui/dialogs/content/EdConvertToTable.js b/editor/ui/dialogs/content/EdConvertToTable.js
index c9dbc82807c..2d1d7b1cee0 100644
--- a/editor/ui/dialogs/content/EdConvertToTable.js
+++ b/editor/ui/dialogs/content/EdConvertToTable.js
@@ -18,6 +18,7 @@
* Rights Reserved.
*
* Contributor(s):
+ * Charles Manske (cmanske@netscape.com)
*/
var gIndex;
@@ -28,8 +29,11 @@ var gOtherIndex = "2";
// dialog initialization code
function Startup()
{
- if (!InitEditorShell())
+ if (!GetCurrentEditor())
+ {
+ window.close();
return;
+ }
gDialog.sepRadioGroup = document.getElementById("SepRadioGroup");
gDialog.sepCharacterInput = document.getElementById("SepCharacterInput");
@@ -101,9 +105,18 @@ function onAccept()
break;
}
- // 1 = OutputSelectionOnly, 1024 = OutputLFLineBreak
- // 256 = OutputEncodeEntities
- var str = editorShell.GetContentsAs("text/html", 1+1024);
+ var editor = GetCurrentEditor();
+ var str;
+ try {
+ // 1 = OutputSelectionOnly, 1024 = OutputLFLineBreak
+ // 256 = OutputEncodeEntities
+ str = editor.outputToString("text/html", 1+1024);
+ } catch (e) {}
+ if (!str)
+ {
+ SaveWindowLocation();
+ return true;
+ }
// Replace nbsp with spaces:
str = str.replace(/\u00a0/g, " ");
@@ -257,31 +270,33 @@ function onAccept()
// (Default width="100%" is used in EdInsertTable.js)
str = "
\n";
- editorShell.BeginBatchChanges();
+ editor.beginTransaction();
// Delete the selection -- makes it easier to find where table will insert
- editorShell.DeleteSelection(0);
-
- var anchorNodeBeforeInsert = editorShell.editorSelection.anchorNode;
- var offset = editorShell.editorSelection.anchorOffset;
var nodeBeforeTable = null;
var nodeAfterTable = null;
- if (anchorNodeBeforeInsert.nodeType == Node.TEXT_NODE)
- {
- // Text was split. Table should be right after the first or before
- nodeBeforeTable = anchorNodeBeforeInsert.previousSibling;
- nodeAfterTable = anchorNodeBeforeInsert;
- }
- else
- {
- // Table should be inserted right after node pointed to by selection
- if (offset > 0)
- nodeBeforeTable = anchorNodeBeforeInsert.childNodes.item(offset - 1);
+ try {
+ editor.deleteSelection(0);
- nodeAfterTable = anchorNodeBeforeInsert.childNodes.item(offset);
- }
+ var anchorNodeBeforeInsert = editor.selection.anchorNode;
+ var offset = editor.selection.anchorOffset;
+ if (anchorNodeBeforeInsert.nodeType == Node.TEXT_NODE)
+ {
+ // Text was split. Table should be right after the first or before
+ nodeBeforeTable = anchorNodeBeforeInsert.previousSibling;
+ nodeAfterTable = anchorNodeBeforeInsert;
+ }
+ else
+ {
+ // Table should be inserted right after node pointed to by selection
+ if (offset > 0)
+ nodeBeforeTable = anchorNodeBeforeInsert.childNodes.item(offset - 1);
+
+ nodeAfterTable = anchorNodeBeforeInsert.childNodes.item(offset);
+ }
- editorShell.InsertSource(str);
+ editor.insertHTML(str);
+ } catch (e) {}
var table = null;
if (nodeAfterTable)
@@ -301,15 +316,15 @@ function onAccept()
{
// Fixup table only if pref is set
var prefs = GetPrefs();
+ var firstRow;
try {
if (prefs && prefs.getBoolPref("editor.table.maintain_structure") )
- editorShell.NormalizeTable(table);
- } catch(ex) {
- dump(ex);
- }
+ editor.normalizeTable(table);
+
+ firstRow = editor.getFirstRow(table);
+ } catch(e) {}
// Put caret in first cell
- var firstRow = editorShell.GetFirstRow(table);
if (firstRow)
{
var node2 = firstRow.firstChild;
@@ -317,7 +332,9 @@ function onAccept()
if (node2.nodeName.toLowerCase() == "td" ||
node2.nodeName.toLowerCase() == "th")
{
- editorShell.editorSelection.collapse(node2, 0);
+ try {
+ editor.selection.collapse(node2, 0);
+ } catch(e) {}
break;
}
node2 = node.nextSibling;
@@ -325,7 +342,7 @@ function onAccept()
}
}
- editorShell.EndBatchChanges();
+ editor.endTransaction();
// Save persisted attributes
gDialog.sepRadioGroup.setAttribute("index", gIndex);
diff --git a/editor/ui/dialogs/content/EdDialogTemplate.js b/editor/ui/dialogs/content/EdDialogTemplate.js
index c78cfbcdffa..7aea29f1fcb 100644
--- a/editor/ui/dialogs/content/EdDialogTemplate.js
+++ b/editor/ui/dialogs/content/EdDialogTemplate.js
@@ -28,9 +28,11 @@ var tagname = "TAG NAME"
// dialog initialization code
function Startup()
{
- if (!InitEditorShell())
+ if (!GetCurrentEditor())
+ {
+ window.close();
return;
-
+ }
// gDialog is declared in EdDialogCommon.js
// Set commonly-used widgets like this:
gDialog.fooButton = document.getElementById("fooButton");
diff --git a/editor/ui/dialogs/content/EdImageMap.js b/editor/ui/dialogs/content/EdImageMap.js
index 75fed4ea2b0..8960876b71f 100644
--- a/editor/ui/dialogs/content/EdImageMap.js
+++ b/editor/ui/dialogs/content/EdImageMap.js
@@ -34,9 +34,11 @@ var frameDoc = null;
var buttonArray = [];
function Startup(){
- if (!InitEditorShell())
+ if (!GetCurrentEditor())
+ {
+ window.close();
return;
-
+ }
initDialog();
}
@@ -66,18 +68,18 @@ function initDialog(){
//check for relative url
if (!((srcInput.value.indexOf("http://") != -1) || (srcInput.value.indexOf("file://") != -1))){
- if (IsUrlAboutBlank(editorShell.editorDocument.location)){
+ if (IsUrlAboutBlank(GetDocumentUrl())){
alert(GetString("SaveToUseRelativeUrl"));
window.close();
//TODO: add option to save document now
}
else{
- var edDoc = new String(editorShell.editorDocument.location);
- var imgDoc = new String(srcInput.value);
+ var edDoc = GetDocumentUrl();
+ var imgDoc = srcInput.value;
imgDoc = imgDoc.split("../");
var len = imgDoc.length;
for (var i=0; i (String(editorShell.editorDocument.location.protocol).length+2))
+ if (edDoc.length > (String(GetCurrentEditor().document.location.protocol).length+2))
edDoc = edDoc.substring(0, edDoc.lastIndexOf("/"));
}
imgDoc = edDoc+"/"+imgDoc[imgDoc.length-1];
@@ -219,17 +221,23 @@ function finishMap(){
else
createPoly(curSpot);
}
- //editorShell.editorDocument.body.appendChild(imageMap);
+ //try{
+ // GetCurrentEditor().root.appendChild(imageMap);
+ //} catch (e) {}
//returnValue = "test";
- //window.arguments[0] = "test"; //editorShell.editorDocument.body.appendChild(imageMap); //editorShell.InsertElementAtSelection(imageMap, false);
- //dump(window.arguments[0]+"\n");
+ //try{
+ // window.arguments[0] = "test"; //GetCurrentEditor().insertElementAtSelection(imageMap, false);
+ // dump(window.arguments[0]+"\n");
+ //} catch (e) {}
dump("imageMap.childNodes.length = "+imageMap.childNodes.length+"\n");
}
return true;
}
-function setMapName(){
- //imageMap = editorShell.CreateElementWithDefaults("map");
+function setMapName() {
+ //try {
+ // imageMap = GetCurrentEditor().createElementWithDefaults("map");
+ //} catch (e) {}
//dump(imageMap+"\n");
//imageMap = frameDoc.createElement("map");
@@ -250,7 +258,10 @@ function setMapName(){
}
function createRect(which){
- //newRect = editorShell.CreateElementWithDefaults("area");
+ var newRect;
+ //try {
+ // newRect = editor.createElementWithDefaults("area");
+ //} catch (e) {}
newRect = frameDoc.createElement("area");
newRect.setAttribute("shape", "rect");
coords = parseInt(which.style.left)+","+parseInt(which.style.top)+","+(parseInt(which.style.left)+parseInt(which.style.width))+","+(parseInt(which.style.top)+parseInt(which.style.height));
@@ -272,8 +283,11 @@ function createRect(which){
}
function createCir(which){
- //newCir = editorShell.CreateElementWithDefaults("area");
- var newCir = frameDoc.createElement("area");
+ var newCir;
+ //try {
+ // newCir = editor.createElementWithDefaults("area");
+ //} catch (e) {}
+ newCir = frameDoc.createElement("area");
if ( !newCir )
return;
@@ -297,8 +311,11 @@ function createCir(which){
}
function createPoly(which){
- //newPoly = editorShell.CreateElementWithDefaults("area");
- var newPoly = frameDoc.createElement("area");
+ var newPoly;
+ //try {
+ // newPoly = editor.createElementWithDefaults("area");
+ //} catch (e) {}
+ newPoly = frameDoc.createElement("area");
if ( !newPoly )
return;
diff --git a/editor/ui/dialogs/content/EdImageMapHotSpot.js b/editor/ui/dialogs/content/EdImageMapHotSpot.js
index 32dd5fae373..63487ec9330 100644
--- a/editor/ui/dialogs/content/EdImageMapHotSpot.js
+++ b/editor/ui/dialogs/content/EdImageMapHotSpot.js
@@ -24,9 +24,6 @@
// dialog initialization code
function Startup()
{
- if (!InitEditorShell())
- return;
-
gDialog.urlInput = document.getElementById("urlInput");
gDialog.targetInput = document.getElementById("targetInput");
gDialog.altInput = document.getElementById("altInput");
diff --git a/editor/ui/dialogs/content/EdInsSrc.js b/editor/ui/dialogs/content/EdInsSrc.js
index 5398eeea39a..560c25e8ff0 100644
--- a/editor/ui/dialogs/content/EdInsSrc.js
+++ b/editor/ui/dialogs/content/EdInsSrc.js
@@ -20,6 +20,8 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
+ * Akkana Peck (akkana@netscape.com)
+ * Charles Manske (cmanske@netscape.com)
*
*
* Alternatively, the contents of this file may be used under the terms of
@@ -37,13 +39,15 @@
* ***** END LICENSE BLOCK ***** */
/* Insert Source HTML dialog */
-var srcInput;
-// dialog initialization code
function Startup()
{
- if (!InitEditorShell())
+ var editor = GetCurrentEditor();
+ if (!editor)
+ {
+ window.close();
return;
+ }
var okButton = document.documentElement.getButton("accept");
if (okButton)
@@ -53,24 +57,34 @@ function Startup()
okButton.setAttribute("accesskey",GetString("InsertAccessKey"));
}
// Create dialog object to store controls for easy access
- srcInput = document.getElementById("srcInput");
-
- var selection = editorShell.GetContentsAs("text/html", 35);
- selection = (selection.replace(/]*>/,"")).replace(/<\/body>/,"");
- if (selection != "")
- srcInput.value = selection;
+ gDialog.srcInput = document.getElementById("srcInput");
+ var selection;
+ try {
+ selection = editor.outputToString("text/html", 35); // OutputWrap+OutputFormatted+OutputSelectionOnly
+ } catch (e) {}
+ if (selection)
+ {
+ selection = (selection.replace(/]*>/,"")).replace(/<\/body>/,"");
+ if (selection)
+ gDialog.srcInput.value = selection;
+ }
// Set initial focus
- srcInput.focus();
+ gDialog.srcInput.focus();
// Note: We can't set the caret location in a multiline textbox
SetWindowLocation();
}
function onAccept()
{
- if (srcInput.value != "")
- editorShell.InsertSource(srcInput.value);
- else {
+ if (gDialog.srcInput.value)
+ {
+ try {
+ GetCurrentEditor().insertHTML(gDialog.srcInput.value);
+ } catch (e) {}
+ }
+ else
+ {
dump("Null value -- not inserting in HTML Source dialog\n");
return false;
}
diff --git a/editor/ui/dialogs/content/EdLinkChecker.js b/editor/ui/dialogs/content/EdLinkChecker.js
index 880348778ad..ee46186d3b7 100644
--- a/editor/ui/dialogs/content/EdLinkChecker.js
+++ b/editor/ui/dialogs/content/EdLinkChecker.js
@@ -61,8 +61,25 @@ var gRequestObserver =
function Startup()
{
- if (!InitEditorShell())
+ var editor = GetCurrentEditor();
+ if (!editor)
+ {
+ window.close();
return;
+ }
+
+ // Get all objects that refer to other locations
+ var objects;
+ try {
+ objects = editor.getLinkedObjects();
+ } catch (e) {}
+
+ if (!objects || objects.count == 0)
+ {
+ AlertWithTitle(GetString("Alert"), GetString("NoLinksToCheck");
+ window.close();
+ return;
+ }
gDialog.LinksList = document.getElementById("LinksList");
gDialog.Close = document.documentElement.getButton("cancel");
@@ -70,11 +87,9 @@ function Startup()
// Set window location relative to parent window (based on persisted attributes)
SetWindowLocation();
- // Get all objects that refer to other locations
- var objects = editorShell.GetLinkedObjects();
// Loop over the nodes that have links:
- for (var i = 0; i < objects.Count(); i++)
+ for (var i = 0; i < objects.count; i++)
{
var refobj = objects.GetElementAt(gNumLinksToCheck).QueryInterface(Components.interfaces.nsIURIRefObject);
// Loop over the links in this node:
diff --git a/editor/ui/dialogs/content/EdLinkChecker.xul b/editor/ui/dialogs/content/EdLinkChecker.xul
index 1dd7ff54cec..72649b6ab41 100644
--- a/editor/ui/dialogs/content/EdLinkChecker.xul
+++ b/editor/ui/dialogs/content/EdLinkChecker.xul
@@ -19,6 +19,7 @@
- Rights Reserved.
-
- Contributor(s):
+ - Charles Manske (cmanske@netscape.com)
-->
@@ -44,16 +45,15 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/editor/ui/dialogs/content/EdNamedAnchorProps.js b/editor/ui/dialogs/content/EdNamedAnchorProps.js
index 7742e5095f5..b4ba9e961e4 100644
--- a/editor/ui/dialogs/content/EdNamedAnchorProps.js
+++ b/editor/ui/dialogs/content/EdNamedAnchorProps.js
@@ -20,36 +20,40 @@
* Contributor(s):
*/
-var insertNew = true;
-var tagName = "anchor";
-var anchorElement = null;
-var originalName = "";
+var gInsertNew = true;
+var gAnchorElement = null;
+var gOriginalName = "";
+const kTagName = "anchor";
// dialog initialization code
function Startup()
{
- if (!InitEditorShell())
+ var editor = GetCurrentEditor();
+ if (!editor)
+ {
+ window.close();
return;
+ }
gDialog.OkButton = document.documentElement.getButton("accept");
gDialog.NameInput = document.getElementById("nameInput");
// Get a single selected element of the desired type
- anchorElement = editorShell.GetSelectedElement(tagName);
+ gAnchorElement = editor.getSelectedElement(kTagName);
- if (anchorElement) {
+ if (gAnchorElement) {
// We found an element and don't need to insert one
- insertNew = false;
+ gInsertNew = false;
// Make a copy to use for AdvancedEdit
- globalElement = anchorElement.cloneNode(false);
- originalName = ConvertToCDATAString(anchorElement.name);
+ globalElement = gAnchorElement.cloneNode(false);
+ gOriginalName = ConvertToCDATAString(gAnchorElement.name);
} else {
- insertNew = true;
+ gInsertNew = true;
// We don't have an element selected,
// so create one with default attributes
- anchorElement = editorShell.CreateElementWithDefaults(tagName);
- if (anchorElement) {
+ gAnchorElement = editor.createElementWithDefaults(kTagName);
+ if (gAnchorElement) {
// Use the current selection as suggested name
var name = GetSelectionAsText();
// Get 40 characters of the selected text and don't add "...",
@@ -60,11 +64,11 @@ function Startup()
name += "_"
// Make a copy to use for AdvancedEdit
- globalElement = anchorElement.cloneNode(false);
+ globalElement = gAnchorElement.cloneNode(false);
globalElement.setAttribute("name",name);
}
}
- if(!anchorElement)
+ if(!gAnchorElement)
{
dump("Failed to get selected element or create a new one!\n");
window.close();
@@ -104,7 +108,11 @@ function DoEnabling()
function AnchorNameExists(name)
{
- var anchorList = editorShell.editorDocument.anchors;
+ var anchorList;
+ try {
+ anchorList = GetCurrentEditor().document.anchors;
+ } catch (e) {}
+
if (anchorList) {
for (var i = 0; i < anchorList.length; i++) {
if (anchorList[i].name == name)
@@ -130,13 +138,13 @@ function ValidateData()
// have to UnConverAndEscape beforehand - too messy!
name = ConvertToCDATAString(name);
- if (originalName != name && AnchorNameExists(name))
+ if (gOriginalName != name && AnchorNameExists(name))
{
ShowInputErrorMessage(GetString("DuplicateAnchorNameError").replace(/%name%/,name));
SetTextboxFocus(gDialog.NameInput);
return false;
}
- globalElement.setAttribute("name",name);
+ globalElement.name = name;
}
return true;
}
@@ -145,19 +153,27 @@ function onAccept()
{
if (ValidateData())
{
- if (originalName != globalElement.name)
+ if (gOriginalName != globalElement.name)
{
- // Copy attributes to element we are changing or inserting
- editorShell.CloneAttributes(anchorElement, globalElement);
+ var editor = GetCurrentEditor();
+ editor.beginTransaction();
- if (insertNew) {
- // Don't delete selected text when inserting
- try {
- editorShell.InsertElementAtSelection(anchorElement, false);
- } catch (e) {
- dump("Exception occured in InsertElementAtSelection\n");
+ try {
+ // "false" = don't delete selected text when inserting
+ if (gInsertNew)
+ {
+ // We must insert element before copying CSS style attribute,
+ // but we must set the name else it won't insert at all
+ gAnchorElement.name = globalElement.name;
+ editor.insertElementAtSelection(gAnchorElement, false);
}
- }
+
+ // Copy attributes to element we are changing or inserting
+ editor.cloneAttributes(gAnchorElement, globalElement);
+
+ } catch (e) {}
+
+ editor.endTransaction();
}
SaveWindowLocation();
return true;
diff --git a/editor/ui/dialogs/content/EdPageProps.js b/editor/ui/dialogs/content/EdPageProps.js
index 073a74041fe..0b99accb1fa 100644
--- a/editor/ui/dialogs/content/EdPageProps.js
+++ b/editor/ui/dialogs/content/EdPageProps.js
@@ -18,27 +18,33 @@
* Rights Reserved.
*
* Contributor(s):
+ * Charles Manske (cmanske@netscape.com)
*/
-var newTitle = "";
-var author = "";
-var description = "";
-var authorElement;
-var descriptionElement;
-var insertNewAuthor = false;
-var insertNewDescription = false;
-var titleWasEdited = false;
-var authorWasEdited = false;
-var descWasEdited = false;
+var gNewTitle = "";
+var gAuthor = "";
+var gDescription = "";
+var gAuthorElement;
+var gDescriptionElement;
+var gInsertNewAuthor = false;
+var gInsertNewDescription = false;
+var gTitleWasEdited = false;
+var gAuthorWasEdited = false;
+var gDescWasEdited = false;
//Cancel() is in EdDialogCommon.js
// dialog initialization code
function Startup()
{
- if (!InitEditorShell())
+ var editor = GetCurrentEditor();
+ if (!editor)
+ {
+ window.close();
return;
+ }
gDialog.PageLocation = document.getElementById("PageLocation");
+ gDialog.PageModDate = document.getElementById("PageModDate");
gDialog.TitleInput = document.getElementById("TitleInput");
gDialog.AuthorInput = document.getElementById("AuthorInput");
gDialog.DescriptionInput = document.getElementById("DescriptionInput");
@@ -55,8 +61,10 @@ function Startup()
// Get last-modified file date+time
// TODO: Convert this to local time?
- var lastmod = editorShell.editorDocument.lastModified; // get string of last modified date
-
+ var lastmod;
+ try {
+ lastmod = editor.document.lastModified; // get string of last modified date
+ } catch (e) {}
// Convert modified string to date (0 = unknown date or January 1, 1970 GMT)
if(Date.parse(lastmod))
{
@@ -80,28 +88,28 @@ function Startup()
} catch (e) {}
}
}
- document.getElementById("PageModDate").setAttribute("value", lastmodString);
+ gDialog.PageModDate.value = lastmodString;
- authorElement = GetMetaElement("author");
- if (!authorElement)
+ gAuthorElement = GetMetaElement("author");
+ if (!gAuthorElement)
{
- authorElement = CreateMetaElement("author");
- if (!authorElement)
+ gAuthorElement = CreateMetaElement("author");
+ if (!gAuthorElement)
{
window.close();
return;
}
- insertNewAuthor = true;
+ gInsertNewAuthor = true;
}
- descriptionElement = GetMetaElement("description");
- if (!descriptionElement)
+ gDescriptionElement = GetMetaElement("description");
+ if (!gDescriptionElement)
{
- descriptionElement = CreateMetaElement("description");
- if (!descriptionElement)
+ gDescriptionElement = CreateMetaElement("description");
+ if (!gDescriptionElement)
window.close();
- insertNewDescription = true;
+ gInsertNewDescription = true;
}
InitDialog();
@@ -113,17 +121,18 @@ function Startup()
function InitDialog()
{
- gDialog.TitleInput.value = editorShell.GetDocumentTitle();
- var author = TrimString(authorElement.getAttribute("content"));
- if (author.length == 0)
+ gDialog.TitleInput.value = GetDocumentTitle();
+
+ var gAuthor = TrimString(gAuthorElement.getAttribute("content"));
+ if (!gAuthor)
{
// Fill in with value from editor prefs
var prefs = GetPrefs();
if (prefs)
- author = prefs.getCharPref("editor.author");
+ gAuthor = prefs.getCharPref("editor.author");
}
- gDialog.AuthorInput.value = author;
- gDialog.DescriptionInput.value = descriptionElement.getAttribute("content");
+ gDialog.AuthorInput.value = gAuthor;
+ gDialog.DescriptionInput.value = gDescriptionElement.getAttribute("content");
}
function TextboxChanged(ID)
@@ -131,22 +140,22 @@ function TextboxChanged(ID)
switch(ID)
{
case "TitleInput":
- titleWasEdited = true;
+ gTitleWasEdited = true;
break;
case "AuthorInput":
- authorWasEdited = true;
+ gAuthorWasEdited = true;
break;
case "DescriptionInput":
- descWasEdited = true;
+ gDescWasEdited = true;
break;
}
}
function ValidateData()
{
- newTitle = TrimString(gDialog.TitleInput.value);
- author = TrimString(gDialog.AuthorInput.value);
- description = TrimString(gDialog.DescriptionInput.value);
+ gNewTitle = TrimString(gDialog.TitleInput.value);
+ gAuthor = TrimString(gDialog.AuthorInput.value);
+ gDescription = TrimString(gDialog.DescriptionInput.value);
return true;
}
@@ -154,20 +163,21 @@ function onAccept()
{
if (ValidateData())
{
- editorShell.BeginBatchChanges();
- if (titleWasEdited)
- {
- // Set title contents even if string is empty
- // because TITLE is a required HTML element
- editorShell.SetDocumentTitle(newTitle);
- }
-
- if (authorWasEdited)
- SetMetaElementContent(authorElement, author, insertNewAuthor);
- if (descWasEdited)
- SetMetaElementContent(descriptionElement, description, insertNewDescription);
+ var editor = GetCurrentEditor();
+ editor.beginTransaction();
- editorShell.EndBatchChanges();
+ // Set title contents even if string is empty
+ // because TITLE is a required HTML element
+ if (gTitleWasEdited)
+ SetDocumentTitle(gNewTitle);
+
+ if (gAuthorWasEdited)
+ SetMetaElementContent(gAuthorElement, gAuthor, gInsertNewAuthor);
+
+ if (gDescWasEdited)
+ SetMetaElementContent(gDescriptionElement, gDescription, gInsertNewDescription);
+
+ editor.endTransaction();
SaveWindowLocation();
return true; // do close the window
diff --git a/editor/ui/dialogs/content/EditConflict.js b/editor/ui/dialogs/content/EditConflict.js
index 9f1c247e5e0..c9b86c797de 100644
--- a/editor/ui/dialogs/content/EditConflict.js
+++ b/editor/ui/dialogs/content/EditConflict.js
@@ -23,16 +23,18 @@
// dialog initialization code
function Startup()
{
- if (!InitEditorShell())
+ if (!GetCurrentEditor())
+ {
+ window.close();
return;
+ }
SetWindowLocation();
}
function KeepCurrentPage()
{
-dump("KeepCurrentPage\n");
- // Simple close dialog and don't change current page
+ // Simply close dialog and don't change current page
//TODO: Should we force saving of the current page?
SaveWindowLocation();
return true;
@@ -40,8 +42,8 @@ dump("KeepCurrentPage\n");
function UseOtherPage()
{
-dump("UseOtherPage\n");
// Reload the URL -- that will get other editor's contents
+ // XXX TODO: Need to replace editorShell.LoadUrl with something in nsIEditingSession?
setTimeout("editorShell.LoadUrl(GetDocumentUrl())", 10);
SaveWindowLocation();
return true;
diff --git a/editor/ui/dialogs/content/EditorPublish.js b/editor/ui/dialogs/content/EditorPublish.js
index 6674c4d6895..1d89d4d3533 100644
--- a/editor/ui/dialogs/content/EditorPublish.js
+++ b/editor/ui/dialogs/content/EditorPublish.js
@@ -38,14 +38,12 @@ function Startup()
{
window.opener.ok = false;
- if (!InitEditorShell()) return;
-
// Element to edit is passed in
gInitialSiteName = window.arguments[1];
gReturnData = window.arguments[2];
- if (!gReturnData)
+ if (!gReturnData || !GetCurrentEditor())
{
- dump("Publish: Return data object not supplied\n");
+ dump("Publish: No editor or return data object not supplied\n");
window.close();
return;
}
@@ -155,7 +153,7 @@ function Startup()
}
}
try {
- gPreviousTitle = editorShell.GetDocumentTitle();
+ gPreviousTitle = GetDocumentTitle();
} catch (e) {}
gDialog.PageTitleInput.value = gPreviousTitle;
@@ -578,11 +576,7 @@ function onAccept()
var title = TrimString(gDialog.PageTitleInput.value);
if (title != gPreviousTitle)
- {
- try {
- editorShell.SetDocumentTitle(title);
- } catch (e) {}
- }
+ SetDocumentTitle(title);
SaveWindowLocation();
window.opener.ok = true;
diff --git a/editor/ui/dialogs/content/EditorPublishProgress.js b/editor/ui/dialogs/content/EditorPublishProgress.js
index 370faf22988..e3796a4cfa4 100644
--- a/editor/ui/dialogs/content/EditorPublishProgress.js
+++ b/editor/ui/dialogs/content/EditorPublishProgress.js
@@ -78,9 +78,6 @@ const kAccessDenied = 2152857621;
function Startup()
{
- if (!InitEditorShell())
- return;
-
gPublishData = window.arguments[0];
if (!gPublishData)
{
@@ -96,7 +93,10 @@ function Startup()
gDialog.Close = document.documentElement.getButton("cancel");
SetWindowLocation();
- window.title = GetString("PublishProgressCaption").replace(/%title%/, editorShell.GetDocumentTitle());
+ var title = GetDocumentTitle();
+ if (!title)
+ title = "("+GetString("untitled")+")";
+ window.title = GetString("PublishProgressCaption").replace(/%title%/, title);
document.getElementById("PublishToSite").value =
GetString("PublishToSite").replace(/%title%/, TruncateStringAtWordEnd(gPublishData.siteName, 25));
@@ -349,13 +349,14 @@ function onEnterKey()
function RequestCloseDialog()
{
- if (gFinished && !gDialog.KeepOpen.checked)
+ // Finish progress messages, settings buttons etc.
+ SetProgressFinished(null, 0);
+
+ if (!gDialog.KeepOpen.checked)
{
// Leave window open a minimum amount of time
gTimerID = setTimeout("CloseDialog();", 3000);
}
- // Finish progress messages, settings buttons etc.
- SetProgressFinished(null,0);
// Set "completed" message if we succeeded
// (Some image files may have failed,
diff --git a/editor/ui/dialogs/content/EditorPublishSettings.js b/editor/ui/dialogs/content/EditorPublishSettings.js
index cab741aafa5..83ad9e3fbc3 100644
--- a/editor/ui/dialogs/content/EditorPublishSettings.js
+++ b/editor/ui/dialogs/content/EditorPublishSettings.js
@@ -35,7 +35,11 @@ var gPasswordManagerOn = true;
// Dialog initialization code
function Startup()
{
- if (!InitEditorShell()) return;
+ if (!GetCurrentEditor())
+ {
+ window.close();
+ return;
+ }
gDialog.SiteList = document.getElementById("SiteList");
gDialog.SiteNameInput = document.getElementById("SiteNameInput");
diff --git a/editor/ui/dialogs/content/EditorSaveAsCharset.js b/editor/ui/dialogs/content/EditorSaveAsCharset.js
index f35c8a5796e..d1e61e23fab 100644
--- a/editor/ui/dialogs/content/EditorSaveAsCharset.js
+++ b/editor/ui/dialogs/content/EditorSaveAsCharset.js
@@ -24,19 +24,23 @@
*/
-var charset="";
-var titleWasEdited = false;
-var charsetWasChanged = false;
-var insertNewContentType = false;
-var contenttypeElement;
-var initDone = false;
+var gCharset="";
+var gTitleWasEdited = false;
+var gCharsetWasChanged = false;
+var gInsertNewContentType = false;
+var gContenttypeElement;
+var gInitDone = false;
//Cancel() is in EdDialogCommon.js
function Startup()
{
- if (!InitEditorShell())
+ var editor = GetCurrentEditor();
+ if (!editor)
+ {
+ window.close();
return;
+ }
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.notifyObservers(null, "charsetmenu-selected", "other");
@@ -45,18 +49,22 @@ function Startup()
gDialog.charsetTree = document.getElementById('CharsetTree');
gDialog.exportToText = document.getElementById('ExportToText');
- contenttypeElement = GetHTTPEquivMetaElement("content-type");
- if(!contenttypeElement && (editorShell.contentsMIMEType != 'text/plain'))
+ gContenttypeElement = GetHTTPEquivMetaElement("content-type");
+ if (!gContenttypeElement && (editor.contentsMIMEType != 'text/plain'))
{
- contenttypeElement = CreateHTTPEquivMetaElement("content-type");
- if( ! contenttypeElement )
+ gContenttypeElement = CreateHTTPEquivMetaElement("content-type");
+ if (!gContenttypeElement )
{
window.close();
return;
}
- insertNewContentType = true;
+ gInsertNewContentType = true;
}
+ try {
+ gCharset = editor.documentCharacterSet;
+ } catch (e) {}
+
InitDialog();
// Use the same text as the messagebox for getting title by regular "Save"
@@ -70,7 +78,7 @@ function Startup()
// SET FOCUS TO FIRST CONTROL
SetTextboxFocus(gDialog.TitleInput);
- initDone = true;
+ gInitDone = true;
SetWindowLocation();
}
@@ -78,10 +86,10 @@ function Startup()
function InitDialog()
{
- gDialog.TitleInput.value = editorShell.GetDocumentTitle();
- charset = editorShell.GetDocumentCharacterSet();
+ gDialog.TitleInput.value = GetDocumentTitle();
+
var RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
- var index = gDialog.charsetTree.builderView.getIndexOfResource(RDF.GetResource(charset));
+ var index = gDialog.charsetTree.builderView.getIndexOfResource(RDF.GetResource(gCharset));
if (index >= 0) {
var treeBox = gDialog.charsetTree.treeBoxObject;
treeBox.selection.select(index);
@@ -92,18 +100,21 @@ function InitDialog()
function onAccept()
{
- editorShell.BeginBatchChanges();
+ var editor = GetCurrentEditor();
+ editor.beginTransaction();
- if(charsetWasChanged)
+ if(gCharsetWasChanged)
{
- SetMetaElementContent(contenttypeElement, "text/html; charset=" + charset, insertNewContentType);
- editorShell.SetDocumentCharacterSet(charset);
+ try {
+ SetMetaElementContent(gContenttypeElement, "text/html; charset=" + gCharset, gInsertNewContentType);
+ editor.documentCharacterSet = gCharset;
+ } catch (e) {}
}
- editorShell.EndBatchChanges();
+ editor.endTransaction();
- if(titleWasEdited)
- window.opener.newTitle = TrimString(gDialog.TitleInput.value);
+ if(gTitleWasEdited)
+ SetDocumentTitle(TrimString(gDialog.TitleInput.value));
window.opener.ok = true;
window.opener.exportToText = gDialog.exportToText.checked;
@@ -124,13 +135,13 @@ function readRDFString(aDS,aRes,aProp)
function SelectCharset()
{
- if(initDone)
+ if(gInitDone)
{
try
{
- charset = gDialog.charsetTree.builderView.getResourceAtIndex(gDialog.charsetTree.currentIndex).Value;
- if (charset)
- charsetWasChanged = true;
+ gCharset = gDialog.charsetTree.builderView.getResourceAtIndex(gDialog.charsetTree.currentIndex).Value;
+ if (gCharset)
+ gCharsetWasChanged = true;
}
catch(e) {}
}
@@ -139,5 +150,5 @@ function SelectCharset()
function TitleChanged()
{
- titleWasEdited = true;
+ gTitleWasEdited = true;
}