rem
stringlengths
0
126k
add
stringlengths
0
441k
context
stringlengths
15
136k
editorShell.InsertElement(hLine, true);
try { editorShell.InsertElementAtSelection(hLine, true); } catch (e) { dump("Exception occured in InsertElementAtSelection\n"); }
function EditorInsertHLine(){ // Inserting an HLine is different in that we don't use properties dialog // unless we are editing an existing line's attributes // We get the last-used attributes from the prefs and insert immediately tagName = "hr"; hLine = editorShell.GetSelectedElement(tagName); if (hLine) { // We only open the dialog for an existing HRule window.openDialog("chrome://editor/content/EdHLineProps.xul", "_blank", "chrome,close,titlebar,modal"); } else { hLine = editorShell.CreateElementWithDefaults(tagName); if (hLine) { // We change the default attributes to those saved in the user prefs var prefs = Components.classes['component://netscape/preferences']; if (prefs) { prefs = prefs.getService(); } if (prefs) { prefs = prefs.QueryInterface(Components.interfaces.nsIPref); } if (prefs) { dump(" We found the Prefs Service\n"); var percent; var height; var shading; var ud = "undefined"; try { var align = prefs.GetIntPref("editor.hrule.align"); dump("Align pref: "+align+"\n"); if (align == 0 ) { hLine.setAttribute("align", "left"); } else if (align == 2) { hLine.setAttribute("align", "right"); } else { // Default is center hLine.setAttribute("align", "center"); } var width = prefs.GetIntPref("editor.hrule.width"); var percent = prefs.GetBoolPref("editor.hrule.width_percent"); dump("Width pref: "+width+", percent:"+percent+"\n"); if (percent) width = width +"%"; hLine.setAttribute("width", width); var height = prefs.GetIntPref("editor.hrule.height"); dump("Size pref: "+height+"\n"); hLine.setAttribute("size", String(height)); var shading = prefs.GetBoolPref("editor.hrule.shading"); dump("Shading pref:"+shading+"\n"); if (shading) { hLine.removeAttribute("noshade"); } else { hLine.setAttribute("noshade", ""); } } catch (ex) { dump("failed to get HLine prefs\n"); } } editorShell.InsertElement(hLine, true); } } contentWindow.focus();}
window.openDialog("chrome: contentWindow.focus();
return _EditorObsolete();
function EditorInsertHTML(){ // Resizing doesn't work! window.openDialog("chrome://editor/content/EdInsSrc.xul","_blank", "chrome,close,titlebar,modal,resizable"); contentWindow.focus();}
top.editorShell.InsertElement(scriptElement,true);
try { top.editorShell.InsertElementAtSelection(scriptElement,true); } catch (e) { dump("Exception occured in InsertElementAtSelection\n"); }
function EditorInsertJSFile(url){ var scriptElement = top.editorShell.CreateElementWithDefaults("script"); // TODO: do some smartass string parsing to find relative file // location so we don't need this big chunky URLs.. // must utilize document dirty flag. scriptElement.setAttribute("src",url); scriptElement.setAttribute("language","JavaScript"); top.editorShell.InsertElement(scriptElement,true);}
tagName = "hr"; hLine = editorShell.GetSelectedElement(tagName); if (hLine) { dump("HLine was found -- opening dialog...!\n"); window.openDialog("chrome: } else { hLine = editorShell.CreateElementWithDefaults(tagName); if (hLine) { var prefs = Components.classes['component: if (prefs) { prefs = prefs.getService(); } if (prefs) { prefs = prefs.QueryInterface(Components.interfaces.nsIPref); } if (prefs) { dump(" We found the Prefs Service\n"); var percent; var height; var shading; var ud = "undefined"; try { var align = prefs.GetIntPref("editor.hrule.align"); dump("Align pref: "+align+"\n"); if (align == 0 ) { hLine.setAttribute("align", "left"); } else if (align == 2) { hLine.setAttribute("align", "right"); } else { hLine.setAttribute("align", "center"); } var width = prefs.GetIntPref("editor.hrule.width"); var percent = prefs.GetBoolPref("editor.hrule.width_percent"); dump("Width pref: "+width+", percent:"+percent+"\n"); if (percent) width = width +"%"; hLine.setAttribute("width", width); var height = prefs.GetIntPref("editor.hrule.height"); dump("Size pref: "+height+"\n"); hLine.setAttribute("size", String(height)); var shading = prefs.GetBoolPref("editor.hrule.shading"); dump("Shading pref:"+shading+"\n"); if (shading) { hLine.removeAttribute("noshade"); } else { hLine.setAttribute("noshade", ""); } } catch (ex) { dump("failed to get HLine prefs\n"); } } try { editorShell.InsertElementAtSelection(hLine, true); } catch (e) { dump("Exception occured in InsertElementAtSelection\n"); } } } contentWindow.focus(); }
return _EditorObsolete();}
function EditorInsertOrEditHLine(){ // Inserting an HLine is different in that we don't use properties dialog // unless we are editing an existing line's attributes // We get the last-used attributes from the prefs and insert immediately tagName = "hr"; hLine = editorShell.GetSelectedElement(tagName); if (hLine) { dump("HLine was found -- opening dialog...!\n"); // We only open the dialog for an existing HRule window.openDialog("chrome://editor/content/EdHLineProps.xul", "_blank", "chrome,close,titlebar,modal"); } else { hLine = editorShell.CreateElementWithDefaults(tagName); if (hLine) { // We change the default attributes to those saved in the user prefs var prefs = Components.classes['component://netscape/preferences']; if (prefs) { prefs = prefs.getService(); } if (prefs) { prefs = prefs.QueryInterface(Components.interfaces.nsIPref); } if (prefs) { dump(" We found the Prefs Service\n"); var percent; var height; var shading; var ud = "undefined"; try { var align = prefs.GetIntPref("editor.hrule.align"); dump("Align pref: "+align+"\n"); if (align == 0 ) { hLine.setAttribute("align", "left"); } else if (align == 2) { hLine.setAttribute("align", "right"); } else { // Default is center hLine.setAttribute("align", "center"); } var width = prefs.GetIntPref("editor.hrule.width"); var percent = prefs.GetBoolPref("editor.hrule.width_percent"); dump("Width pref: "+width+", percent:"+percent+"\n"); if (percent) width = width +"%"; hLine.setAttribute("width", width); var height = prefs.GetIntPref("editor.hrule.height"); dump("Size pref: "+height+"\n"); hLine.setAttribute("size", String(height)); var shading = prefs.GetBoolPref("editor.hrule.shading"); dump("Shading pref:"+shading+"\n"); if (shading) { hLine.removeAttribute("noshade"); } else { hLine.setAttribute("noshade", ""); } } catch (ex) { dump("failed to get HLine prefs\n"); } } try { editorShell.InsertElementAtSelection(hLine, true); } catch (e) { dump("Exception occured in InsertElementAtSelection\n"); } } } contentWindow.focus();}
window.openDialog("chrome: contentWindow.focus();
return _EditorObsolete();
function EditorInsertOrEditImage(){ window.openDialog("chrome://editor/content/EdImageProps.xul","_blank", "chrome,close,titlebar,modal"); contentWindow.focus();}
window.openDialog("chrome: contentWindow.focus();
return _EditorObsolete();
function EditorInsertOrEditLink(){ window.openDialog("chrome://editor/content/EdLinkProps.xul","_blank", "chrome,close,titlebar,modal"); contentWindow.focus();}
window.openDialog("chrome: contentWindow.focus();
return _EditorObsolete();
function EditorInsertOrEditNamedAnchor(){ window.openDialog("chrome://editor/content/EdNamedAnchorProps.xul", "_blank", "chrome,close,titlebar,modal", ""); contentWindow.focus();}
dump("Function not implemented\n"); return;
function EditorInsertOrEditTable(insertAllowed){ var table = editorShell.GetElementOrParentByTagName("table", null); if (table) { //TEMP FOR BETA1: Disable item - dialog not working dump("Function not implemented\n"); return; // Edit properties of existing table dump("Existing table found ... Editing its properties\n"); window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "","TablePanel"); contentWindow.focus(); } else if(insertAllowed) { EditorInsertTable(); }}
if (IsInTableCell()) window.openDialog("chrome: else window.openDialog("chrome:
window.openDialog("chrome:
function EditorInsertOrEditTable(insertAllowed){ if (IsInTable()) { // Edit properties of existing table if (IsInTableCell()) window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "","CellPanel"); else window.openDialog("chrome://editor/content/EdTableProps.xul", "_blank", "chrome,close,titlebar,modal", "","TablePanel"); window._content.focus(); } else if(insertAllowed) { EditorInsertTable(); }}
dump("EditorInsertTableColumn, after="+after+"\n");
function EditorInsertTableColumn(after){ editorShell.InsertTableColumn(1,after); contentWindow.focus();}
dump("EditorInsertTableRow, below="+below+"\n");
function EditorInsertTableRow(below){ editorShell.InsertTableRow(1,below); contentWindow.focus();}
if (event.shiftKey) {
if (event.shiftKey && !event.getPreventDefault()) {
function editorKeyPress(event){ if (event.keyCode == 9) { if (event.shiftKey) { document.getElementById('msgSubject').focus(); event.preventDefault(); } }}
window.openDialog("chrome: contentWindow.focus();
return _EditorObsolete();
function EditorListProperties(){ window.openDialog("chrome://editor/content/EdListProps.xul","_blank", "chrome,close,titlebar,modal"); contentWindow.focus();}
var theButton = document.getElementById(listType + "Button"); if (theButton) { var buttonFormat = theButton.getAttribute("format"); var isOn = (listType == buttonFormat); if (isOn == 1) { editorShell.RemoveList(listType); } else { editorShell.MakeOrChangeList(listType); } contentWindow.focus(); } else { dump("No button found for the " + listType + " style\n"); }
return _EditorObsolete();
function EditorMakeOrChangeList(listType){ // check the observer node, // which is the appropriate button var theButton = document.getElementById(listType + "Button"); if (theButton) { var buttonFormat = theButton.getAttribute("format"); var isOn = (listType == buttonFormat); if (isOn == 1) { editorShell.RemoveList(listType); } else { editorShell.MakeOrChangeList(listType); } contentWindow.focus(); } else { dump("No button found for the " + listType + " style\n"); }}
dump("In EditorNewPlaintext..\n");
function EditorNewPlaintext(){ dump("In EditorNewPlaintext..\n"); window.openDialog( "chrome://editor/content/TextEditorAppShell.xul", "_blank", "chrome,dialog=no,all", "chrome://editor/content/EditorInitPagePlain.html" );}
dump("EditorObjectProperties: element="+element+"\n");
function EditorObjectProperties(){ var element = GetSelectedElementOrParentCell(); dump("EditorObjectProperties: element="+element+"\n"); if (element) { dump("TagName="+element.nodeName+"\n"); switch (element.nodeName) { case 'IMG': EditorInsertOrEditImage(); break; case 'HR': EditorInsertOrEditHLine(); break; case 'TABLE': EditorInsertOrEditTable(false); break; case 'TD': EditorTableCellProperties(); break; case 'A': if(element.href) EditorInsertOrEditLink(); else if (element.name) EditorInsertOrEditNamedAnchor(); break; } } else { // We get a partially-selected link if asked for specifically element = editorShell.GetSelectedElement("href"); if (element) EditorInsertOrEditLink(); }}
dump("TagName="+element.nodeName+"\n");
function EditorObjectProperties(){ var element = GetSelectedElementOrParentCell(); dump("EditorObjectProperties: element="+element+"\n"); if (element) { dump("TagName="+element.nodeName+"\n"); switch (element.nodeName) { case 'IMG': EditorInsertOrEditImage(); break; case 'HR': EditorInsertOrEditHLine(); break; case 'TABLE': EditorInsertOrEditTable(false); break; case 'TD': EditorTableCellProperties(); break; case 'A': if(element.href) EditorInsertOrEditLink(); else if (element.name) EditorInsertOrEditNamedAnchor(); break; } } else { // We get a partially-selected link if asked for specifically element = editorShell.GetSelectedElement("href"); if (element) EditorInsertOrEditLink(); }}
EditorInsertOrEditImage();
goDoCommand("cmd_image");
function EditorObjectProperties(){ var element = GetSelectedElementOrParentCell(); dump("EditorObjectProperties: element="+element+"\n"); if (element) { dump("TagName="+element.nodeName+"\n"); switch (element.nodeName) { case 'IMG': EditorInsertOrEditImage(); break; case 'HR': EditorInsertOrEditHLine(); break; case 'TABLE': EditorInsertOrEditTable(false); break; case 'TD': EditorTableCellProperties(); break; case 'A': if(element.href) EditorInsertOrEditLink(); else if (element.name) EditorInsertOrEditNamedAnchor(); break; } } else { // We get a partially-selected link if asked for specifically element = editorShell.GetSelectedElement("href"); if (element) EditorInsertOrEditLink(); }}
EditorInsertOrEditHLine();
goDoCommand("cmd_hline");
function EditorObjectProperties(){ var element = GetSelectedElementOrParentCell(); dump("EditorObjectProperties: element="+element+"\n"); if (element) { dump("TagName="+element.nodeName+"\n"); switch (element.nodeName) { case 'IMG': EditorInsertOrEditImage(); break; case 'HR': EditorInsertOrEditHLine(); break; case 'TABLE': EditorInsertOrEditTable(false); break; case 'TD': EditorTableCellProperties(); break; case 'A': if(element.href) EditorInsertOrEditLink(); else if (element.name) EditorInsertOrEditNamedAnchor(); break; } } else { // We get a partially-selected link if asked for specifically element = editorShell.GetSelectedElement("href"); if (element) EditorInsertOrEditLink(); }}
EditorInsertOrEditLink();
goDoCommand("cmd_link");
function EditorObjectProperties(){ var element = GetSelectedElementOrParentCell(); dump("EditorObjectProperties: element="+element+"\n"); if (element) { dump("TagName="+element.nodeName+"\n"); switch (element.nodeName) { case 'IMG': EditorInsertOrEditImage(); break; case 'HR': EditorInsertOrEditHLine(); break; case 'TABLE': EditorInsertOrEditTable(false); break; case 'TD': EditorTableCellProperties(); break; case 'A': if(element.href) EditorInsertOrEditLink(); else if (element.name) EditorInsertOrEditNamedAnchor(); break; } } else { // We get a partially-selected link if asked for specifically element = editorShell.GetSelectedElement("href"); if (element) EditorInsertOrEditLink(); }}
EditorInsertOrEditNamedAnchor();
goDoCommand("cmd_anchor");
function EditorObjectProperties(){ var element = GetSelectedElementOrParentCell(); dump("EditorObjectProperties: element="+element+"\n"); if (element) { dump("TagName="+element.nodeName+"\n"); switch (element.nodeName) { case 'IMG': EditorInsertOrEditImage(); break; case 'HR': EditorInsertOrEditHLine(); break; case 'TABLE': EditorInsertOrEditTable(false); break; case 'TD': EditorTableCellProperties(); break; case 'A': if(element.href) EditorInsertOrEditLink(); else if (element.name) EditorInsertOrEditNamedAnchor(); break; } } else { // We get a partially-selected link if asked for specifically element = editorShell.GetSelectedElement("href"); if (element) EditorInsertOrEditLink(); }}
var styleMenu = document.getElementById("stylesheetMenu") if (styleMenu) styleMenu.removeAttribute("hidden"); WebCompose = true;
function EditorOnLoad() { // See if argument was passed. if ( window.arguments && window.arguments[0] ) { // Opened via window.openDialog with URL as argument. // Put argument where EditorStartup expects it. document.getElementById( "args" ).setAttribute( "value", window.arguments[0] ); } // Continue with normal startup. EditorStartup( 'html', document.getElementById("content-frame")); window.tryToClose = EditorClose;}
if (fp.file) {
if (fp.file && fp.file.path.length > 0) {
function EditorOpen(){ dump("In EditorOpen..\n"); var fp = Components.classes["component://mozilla/filepicker"].createInstance(nsIFilePicker); fp.init(window, editorShell.GetString("OpenHTMLFile"), nsIFilePicker.modeOpen); // While we include "All", include filters that prefer HTML and Text files fp.setFilters(nsIFilePicker.filterText | nsIFilePicker.filterHTML | nsIFilePicker.filterAll); /* doesn't handle *.shtml files */ try { fp.show(); /* need to handle cancel (uncaught exception at present) */ } catch (ex) { dump("filePicker.chooseInputFile threw an exception\n"); } /* check for already open window and activate it... */ if (fp.file) { var found = FindAndSelectEditorWindowWithURL(fp.fileURL.spec); if (!found) { /* open new window */ window.openDialog("chrome://editor/content", "_blank", "chrome,dialog=no,all", fp.fileURL.spec); } }}
dump("In EditorOpen..\n"); var fp = Components.classes["component: fp.init(window, editorShell.GetString("OpenHTMLFile"), nsIFilePicker.modeOpen); fp.setFilters(nsIFilePicker.filterText | nsIFilePicker.filterHTML | nsIFilePicker.filterAll); /* doesn't handle *.shtml files */ try { fp.show(); /* need to handle cancel (uncaught exception at present) */ } catch (ex) { dump("filePicker.chooseInputFile threw an exception\n"); } /* check for already open window and activate it... * note that we have to test the native path length * since fileURL.spec will be "file: */ if (fp.file && fp.file.path.length > 0) { var found = FindAndSelectEditorWindowWithURL(fp.fileURL.spec); if (!found) { if (PageIsEmptyAndUntouched()) { editorShell.LoadUrl(fp.fileURL.spec); } else { /* open new window */ window.openDialog("chrome: "_blank", "chrome,dialog=no,all", fp.fileURL.spec); } } }
return _EditorObsolete();
function EditorOpen(){ dump("In EditorOpen..\n"); var fp = Components.classes["component://mozilla/filepicker"].createInstance(nsIFilePicker); fp.init(window, editorShell.GetString("OpenHTMLFile"), nsIFilePicker.modeOpen); // While we include "All", include filters that prefer HTML and Text files fp.setFilters(nsIFilePicker.filterText | nsIFilePicker.filterHTML | nsIFilePicker.filterAll); /* doesn't handle *.shtml files */ try { fp.show(); /* need to handle cancel (uncaught exception at present) */ } catch (ex) { dump("filePicker.chooseInputFile threw an exception\n"); } /* check for already open window and activate it... * note that we have to test the native path length * since fileURL.spec will be "file:///" if no filename picked (Cancel button used) */ if (fp.file && fp.file.path.length > 0) { var found = FindAndSelectEditorWindowWithURL(fp.fileURL.spec); if (!found) { // if the existing window is untouched, just load there if (PageIsEmptyAndUntouched()) { editorShell.LoadUrl(fp.fileURL.spec); } else { /* open new window */ window.openDialog("chrome://editor/content", "_blank", "chrome,dialog=no,all", fp.fileURL.spec); } } }}
filePicker.chooseInputFile(editorShell.GetString("OpenHTMLFile"), filePicker.eHTMLFiles+filePicker.eTextFiles+filePicker.eAllFiles, 0, 0);
try { filePicker.chooseInputFile(editorShell.GetString("OpenHTMLFile"), filePicker.eHTMLFiles+filePicker.eTextFiles+filePicker.eAllFiles, 0, 0); } catch (ex) { dump("filePicker.chooseInputFile threw an exception\n"); }
function EditorOpen(){ dump("In EditorOpen..\n"); var filePicker = Components.classes["component://netscape/filespecwithui"].createInstance(); filePicker = filePicker.QueryInterface(Components.interfaces.nsIFileSpecWithUI); /* doesn't handle *.shtml files */ filePicker.chooseInputFile(editorShell.GetString("OpenHTMLFile"), filePicker.eHTMLFiles+filePicker.eTextFiles+filePicker.eAllFiles, 0, 0); /* need to handle cancel (uncaught exception at present) */ /* check for already open window and activate it... */ var found = FindAndSelectEditorWindowWithURL(filePicker.URLString); if (!found) { /* open new window */ window.openDialog( "chrome://editor/content", "_blank", "chrome,dialog=no,all", filePicker.URLString ); }}
window.openDialog( "chrome:
return _EditorObsolete();
function EditorOpenRemote(){ /* The last parameter is the current browser window. Use 0 and the default checkbox will be to load into an editor and loading into existing browser option is removed */ window.openDialog( "chrome://navigator/content/openLocation.xul", "_blank", "chrome,modal", 0);}
if (IsInHTMLSourceMode()) FinishHTMLSource();
function EditorOpenUrl(url){ if (!url) return; // if the existing window is untouched, just load there if (!FindAndSelectEditorWindowWithURL(url)) { if (PageIsEmptyAndUntouched()) { window.editorShell.LoadUrl(url); } else { // open new window window.openDialog("chrome://editor/content", "_blank", "chrome,dialog=no,all", url); } }}
window.openDialog("chrome: contentWindow.focus();
return _EditorObsolete();
function EditorPageProperties(){ window.openDialog("chrome://editor/content/EdPageProps.xul","_blank", "chrome,close,titlebar,modal,resizable", ""); contentWindow.focus();}
if (!editorShell.CheckAndSaveDocument(editorShell.GetString("BeforePreview"))) return; fileurl = ""; try { fileurl = window.content.location; } catch (e) { return; } if (fileurl != "" && fileurl != "about:blank") { window.openDialog(getBrowserURL(), "EditorPreview", "chrome,all,dialog=no", fileurl ); }
return _EditorObsolete();
function EditorPreview(){ if (!editorShell.CheckAndSaveDocument(editorShell.GetString("BeforePreview"))) return; fileurl = ""; try { fileurl = window.content.location; } catch (e) { return; } // CheckAndSave doesn't tell us if the user said "Don't Save", // so make sure we have a url: if (fileurl != "" && fileurl != "about:blank") { window.openDialog(getBrowserURL(), "EditorPreview", "chrome,all,dialog=no", fileurl ); }}
dump("In EditorPrint..\n"); editorShell.Print(); contentWindow.focus();
return _EditorObsolete();
function EditorPrint(){ dump("In EditorPrint..\n"); editorShell.Print(); contentWindow.focus();}
_EditorNotImplemented(); contentWindow.focus();
return _EditorObsolete();
function EditorPrintPreview(){ _EditorNotImplemented(); contentWindow.focus();}
window.openDialog("resource:/res/samples/printsetup.html", "_blank", "chrome,close,titlebar", "");
_EditorNotImplemented();
function EditorPrintPreview(){ window.openDialog("resource:/res/samples/printsetup.html", "_blank", "chrome,close,titlebar", ""); contentWindow.focus();}
_EditorNotImplemented(); contentWindow.focus();
return _EditorObsolete();
function EditorPrintSetup(){ // Old code? Browser no longer is doing this //window.openDialog("resource:/res/samples/printsetup.html", "_blank", "chrome,close,titlebar", ""); _EditorNotImplemented(); contentWindow.focus();}
if (ColorWellID) { var menupopup = document.getElementById("BackColorPopup"); if (menupopup) menupopup.closePopup(); }
function EditorRemoveBackColor(ColorWellID){ //TODO: Set colorwell to browser's default color editorShell.SetBackgroundColor(""); contentWindow.focus();}
gContentWindow.focus();
window.content.focus();
function EditorRemoveBackColor(ColorWellID){ if (ColorWellID) { var menupopup = document.getElementById("BackColorPopup"); if (menupopup) menupopup.closePopup(); } //TODO: Set colorwell to browser's default color editorShell.SetBackgroundColor(""); gContentWindow.focus();}
editorShell.RemoveTextProperty("a", "");
editorShell.RemoveTextProperty("href", "");
function EditorRemoveLinks(){ editorShell.RemoveTextProperty("a", ""); contentWindow.focus();}
gContentWindow.focus();
window.content.focus();
function EditorRemoveLinks(){ editorShell.RemoveTextProperty("href", ""); gContentWindow.focus();}
editorShell.RemoveTextProperty(tagName, ""); contentWindow.focus();
return _EditorObsolete();
function EditorRemoveStyle(tagName){ editorShell.RemoveTextProperty(tagName, ""); contentWindow.focus();}
if (ColorWellID) { var menupopup = document.getElementById("TextColorPopup"); if (menupopup) menupopup.closePopup(); }
function EditorRemoveTextColor(ColorWellID){ //TODO: Set colorwell to browser's default color editorShell.SetTextProperty("font", "color", ""); contentWindow.focus();}
bodyelement.removeAttribute("text"); bodyelement.removeAttribute("bgcolor");
gEditor.removeAttributeOrEquivalent(bodyelement, "text", true); gEditor.removeAttributeOrEquivalent(bodyelement, "bgcolor", true);
function EditorResetFontAndColorAttributes(){ document.getElementById("cmd_fontFace").setAttribute("state", ""); EditorRemoveTextProperty("font", "color"); EditorRemoveTextProperty("font", "bgcolor"); EditorRemoveTextProperty("font", "size"); EditorRemoveTextProperty("small", ""); EditorRemoveTextProperty("big", ""); var bodyelement = GetBodyElement(); if (bodyelement) { bodyelement.removeAttribute("text"); bodyelement.removeAttribute("bgcolor"); bodyelement.removeAttribute("link"); bodyelement.removeAttribute("alink"); bodyelement.removeAttribute("vlink"); bodyelement.removeAttribute("background"); } gColorObj.LastTextColor = ""; gColorObj.LastBackgroundColor = ""; gColorObj.LastHighlightColor = ""; document.getElementById("cmd_fontColor").setAttribute("state", ""); document.getElementById("cmd_backgroundColor").setAttribute("state", ""); UpdateDefaultColors();}
bodyelement.removeAttribute("background");
gEditor.removeAttributeOrEquivalent(bodyelement, "background", true);
function EditorResetFontAndColorAttributes(){ document.getElementById("cmd_fontFace").setAttribute("state", ""); EditorRemoveTextProperty("font", "color"); EditorRemoveTextProperty("font", "bgcolor"); EditorRemoveTextProperty("font", "size"); EditorRemoveTextProperty("small", ""); EditorRemoveTextProperty("big", ""); var bodyelement = GetBodyElement(); if (bodyelement) { bodyelement.removeAttribute("text"); bodyelement.removeAttribute("bgcolor"); bodyelement.removeAttribute("link"); bodyelement.removeAttribute("alink"); bodyelement.removeAttribute("vlink"); bodyelement.removeAttribute("background"); } gColorObj.LastTextColor = ""; gColorObj.LastBackgroundColor = ""; gColorObj.LastHighlightColor = ""; document.getElementById("cmd_fontColor").setAttribute("state", ""); document.getElementById("cmd_backgroundColor").setAttribute("state", ""); UpdateDefaultColors();}
dump("In EditorSave...\n"); EditorSaveDocument(false, false) contentWindow.focus();
return _EditorObsolete();
function EditorSave(){ dump("In EditorSave...\n"); EditorSaveDocument(false, false) contentWindow.focus();}
EditorSaveDocument(true, false); contentWindow.focus();
return _EditorObsolete();
function EditorSaveAs(){ EditorSaveDocument(true, false); contentWindow.focus();}
editorShell.SelectAllTableCells();
function EditorSelectAllTableCells(){//TEMP FOR BETA1: Disable item - dialog not working// editorShell.SelectAllTableCells(); contentWindow.focus();}
dump("EditorSelectBackColor: "+color+"\n");
dump("EditorSelectBackColor: "+color+"\n"); var menupopup; if (ColorPickerID == "menuBackCP") menupopup = document.getElementById("formatMenuPopup"); else if (ColorPickerID == "BackColorPicker") menupopup = document.getElementById("BackColorPopup"); if (menupopup) menupopup.closePopup();
function EditorSelectBackColor(ColorPickerID, ColorWellID){ var color = getColorAndSetColorWell(ColorPickerID, ColorWellID); dump("EditorSelectBackColor: "+color+"\n"); EditorSetBackgroundColor(color);}
contentWindow.focus();
function EditorSelectBackColor(ColorPickerID, ColorWellID){ var color = getColorAndSetColorWell(ColorPickerID, ColorWellID); dump("EditorSelectBackColor: "+color+"\n"); EditorSetBackgroundColor(color);}
gContentWindow.focus();
window.content.focus();
function EditorSelectBackColor(ColorPickerID, ColorWellID){ var color = getColorAndSetColorWell(ColorPickerID, ColorWellID);dump("EditorSelectBackColor: "+color+"\n"); // Close appropriate menupopup var menupopup; if (ColorPickerID == "menuBackCP") menupopup = document.getElementById("formatMenuPopup"); else if (ColorPickerID == "BackColorPicker") menupopup = document.getElementById("BackColorPopup"); if (menupopup) menupopup.closePopup(); EditorSetBackgroundColor(color); gContentWindow.focus();}
contentWindow.focus();
function EditorSelectFontFace() { var select = document.getElementById("FontFaceSelect");//dump("EditorSelectFontFace: "+gFontFaceNames[select.selectedIndex]+"\n"); if (select) { if (select.selectedIndex == -1) return; EditorSetFontFace(gFontFaceNames[select.selectedIndex]); }}
dump("EditorSelectFontSize: "+gFontSizeNames[select.selectedIndex]+"\n");
function EditorSelectFontSize(){ var select = document.getElementById("FontSizeSelect");dump("EditorSelectFontSize: "+gFontSizeNames[select.selectedIndex]+"\n"); if (select) { if (select.selectedIndex == -1) return; EditorSetFontSize(gFontSizeNames[select.selectedIndex]); }}
contentWindow.focus();
function EditorSelectParagraphFormat(){ var select = document.getElementById("ParagraphSelect"); if (select) { if (select.selectedIndex == -1) return; editorShell.SetParagraphFormat(gParagraphTagNames[select.selectedIndex]); }}
editorShell.SelectTableCell();
function EditorSelectTable(){//TEMP FOR BETA1: Disable item - dialog not working// editorShell.SelectTableCell(); contentWindow.focus();}
var selection = editorShell.editorSelection; if (selection) { var tableNode = editorShell.GetElementOrParentByTagName("table",selection.anchorNode); if (tableNode) { selection.clearSelection(); AppendNodeToSelection(selection, tableNode); } }
editorShell.SelectTableCell();
function EditorSelectTable(){ var selection = editorShell.editorSelection; if (selection) { var tableNode = editorShell.GetElementOrParentByTagName("table",selection.anchorNode); if (tableNode) { selection.clearSelection(); AppendNodeToSelection(selection, tableNode); } } contentWindow.focus();}
editorShell.SelectTableCell();
function EditorSelectTableCell(){//TEMP FOR BETA1: Disable item - dialog not working// editorShell.SelectTableCell(); contentWindow.focus();}
var selection = editorShell.editorSelection; if (selection) { var cellNode = editorShell.GetElementOrParentByTagName("td",selection.anchorNode); if (cellNode) { selection.clearSelection(); AppendNodeToSelection(selection, cellNode); } }
editorShell.SelectTableCell();
function EditorSelectTableCell(){ var selection = editorShell.editorSelection; if (selection) { var cellNode = editorShell.GetElementOrParentByTagName("td",selection.anchorNode); if (cellNode) { selection.clearSelection(); AppendNodeToSelection(selection, cellNode); } } contentWindow.focus();}
editorShell.SelectTableColumn();
function EditorSelectTableColumn(){//TEMP FOR BETA1: Disable item - dialog not working// editorShell.SelectTableColumn(); contentWindow.focus();}
editorShell.SelectTableColumn();
function EditorSelectTableColumn(){ //TODO: FINISH THIS! contentWindow.focus();}
editorShell.SelectTableRow();
function EditorSelectTableRow(){//TEMP FOR BETA1: Disable item - dialog not working// editorShell.SelectTableRow(); contentWindow.focus();}
var tagNameObj = new Object(); var isSelectedObj = new Object(); var tagName; var isSelected; var tableElement = editorShell.GetSelectedOrParentTableElement(tagNameObj,isSelectedObj); tagName = tagNameObj.value; isSelected = isSelectedObj.value; dump("Table element="+tableElement+" Tagname="+tagName+" IsSelected="+isSelected+"\n");
editorShell.SelectTableRow();
function EditorSelectTableRow(){ var tagNameObj = new Object(); var isSelectedObj = new Object(); var tagName; var isSelected; var tableElement = editorShell.GetSelectedOrParentTableElement(tagNameObj,isSelectedObj); tagName = tagNameObj.value; isSelected = isSelectedObj.value;dump("Table element="+tableElement+" Tagname="+tagName+" IsSelected="+isSelected+"\n"); //TODO: FINISH THIS! contentWindow.focus();}
contentWindow.focus();
function EditorSelectTextColor(ColorPickerID, ColorWellID){ var color = getColorAndSetColorWell(ColorPickerID, ColorWellID); dump("EditorSelectTextColor: "+color+"\n"); EditorSetFontColor(color);}
dump("EditorSelectTextColor: "+color+"\n");
function EditorSelectTextColor(ColorPickerID, ColorWellID){ var color = getColorAndSetColorWell(ColorPickerID, ColorWellID);dump("EditorSelectTextColor: "+color+"\n"); // Close appropriate menupopup var menupopup; if (ColorPickerID == "menuTextCP") menupopup = document.getElementById("formatMenuPopup"); else if (ColorPickerID == "TextColorPicker") menupopup = document.getElementById("TextColorPopup"); if (menupopup) menupopup.closePopup(); EditorSetFontColor(color); contentWindow.focus();}
gContentWindow.focus();
window.content.focus();
function EditorSetBackgroundColor(color){ editorShell.SetBackgroundColor(color); gContentWindow.focus();}
var prefAuthorString = prefs.CopyCharPref("editor.author");
prefAuthorString = prefs.CopyCharPref("editor.author");
function EditorSetDefaultPrefs(){ /* only set defaults for new documents */ var url = document.getElementById("args").getAttribute("value"); if ( url != "about:blank" ) return; var domdoc; try { domdoc = window.editorShell.editorDocument; } catch (e) { dump( e + "\n"); } if ( !domdoc ) return; // try to get preferences service var prefs = null; try { prefs = Components.classes['component://netscape/preferences']; prefs = prefs.getService(); prefs = prefs.QueryInterface(Components.interfaces.nsIPref); } catch (ex) { dump("failed to get prefs service!\n"); prefs = null; } // search for author meta tag. // if one is found, don't do anything. // if not, create one and make it a child of the head tag // and set its content attribute to the value of the editor.author preference. var prefAuthorString = prefs.CopyCharPref("editor.author"); if ( prefAuthorString && prefAuthorString != 0) { var nodelist = domdoc.getElementsByTagName("meta"); if ( nodelist ) { var found = false; var node = 0; var listlength = nodelist.length; for (var i = 0; i < listlength && !found; i++) { node = nodelist.item(i); if ( node ) { var value = node.getAttribute("name"); if (value == "author") { found = true; } } } if ( !found ) { /* create meta tag with 2 attributes */ var element = domdoc.createElement("meta"); if ( element ) { AddAttrToElem(domdoc, "name", "Author", element); AddAttrToElem(domdoc, "content", prefs.CopyCharPref("editor.author"), element); var headelement = 0; var headnodelist = domdoc.getElementsByTagName("head"); if (headnodelist) { var sz = headnodelist.length; if ( sz >= 1 ) { headelement = headnodelist.item(0); } } if ( headelement ) { headelement.appendChild( element ); } } } } } // color prefs var use_custom_colors = false; try { use_custom_colors = prefs.GetBoolPref("editor.use_custom_colors"); dump("pref use_custom_colors:" + use_custom_colors + "\n"); } catch (ex) { dump("problem getting use_custom_colors as bool, hmmm, still confused about its identity?!\n"); } if ( use_custom_colors ) { // find body node var bodyelement = null; var bodynodelist = null; try { bodynodelist = domdoc.getElementsByTagName("body"); bodyelement = bodynodelist.item(0); } catch (ex) { dump("no body tag found?!\n"); // better have one, how can we blow things up here? } // try to get the default color values. ignore them if we don't have them. var text_color = link_color = active_link_color = followed_link_color = background_color = ""; try { text_color = prefs.CopyCharPref("editor.text_color"); } catch (e) {} try { link_color = prefs.CopyCharPref("editor.link_color"); } catch (e) {} try { active_link_color = prefs.CopyCharPref("editor.active_link_color"); } catch (e) {} try { followed_link_color = prefs.CopyCharPref("editor.followed_link_color"); } catch (e) {} try { background_color = prefs.CopyCharPref("editor.background_color"); } catch(e) {} // add the color attributes to the body tag. // FIXME: use the check boxes for each color somehow.. if (text_color != "") AddAttrToElem(domdoc, "text", text_color, bodyelement); if (link_color != "") AddAttrToElem(domdoc, "link", link_color, bodyelement); if (active_link_color != "") AddAttrToElem(domdoc, "alink", active_link_color, bodyelement); if (followed_link_color != "") AddAttrToElem(domdoc, "vlink", followed_link_color, bodyelement); if (background_color != "") AddAttrToElem(domdoc, "bgcolor", background_color, bodyelement); } // auto-save???}
editButton = document.getElementById("EditModeButton"); browserButton = document.getElementById("BrowserModeButton");
var editButton = document.getElementById("EditModeButton"); var browserButton = document.getElementById("BrowserModeButton"); var showMenu = document.getElementById("ShowExtraMarkup"); var hideMenu = document.getElementById("HideExtraMarkup");
function EditorSetDisplayStyle(mode){ EditorDisplayMode = mode; editorShell.SetDisplayMode(mode); editButton = document.getElementById("EditModeButton"); browserButton = document.getElementById("BrowserModeButton"); var editSelected = 0; var browserSelected = 0; if (mode == 0) editSelected = 1; if (mode == 1) browserSelected = 1; dump(editButton+browserButton+" Display mode: EditSelected="+editSelected+" BrowserSelected="+browserSelected+"\n"); editButton.setAttribute("selected",Number(editSelected)); browserButton.setAttribute("selected",Number(browserSelected));}
if (mode == 0) editSelected = 1; if (mode == 1) browserSelected = 1; dump(editButton+browserButton+" Display mode: EditSelected="+editSelected+" BrowserSelected="+browserSelected+"\n");
if (mode == 0) { editSelected = 1; showMenu.setAttribute("hidden","true"); hideMenu.removeAttribute("hidden"); } if (mode == 1) { browserSelected = 1; showMenu.removeAttribute("hidden"); hideMenu.setAttribute("hidden","true"); }
function EditorSetDisplayStyle(mode){ EditorDisplayMode = mode; editorShell.SetDisplayMode(mode); editButton = document.getElementById("EditModeButton"); browserButton = document.getElementById("BrowserModeButton"); var editSelected = 0; var browserSelected = 0; if (mode == 0) editSelected = 1; if (mode == 1) browserSelected = 1; dump(editButton+browserButton+" Display mode: EditSelected="+editSelected+" BrowserSelected="+browserSelected+"\n"); editButton.setAttribute("selected",Number(editSelected)); browserButton.setAttribute("selected",Number(browserSelected));}
contentWindow.focus();
function EditorSetDisplayStyle(mode){ EditorDisplayMode = mode; editorShell.SetDisplayMode(mode); editButton = document.getElementById("EditModeButton"); browserButton = document.getElementById("BrowserModeButton"); var editSelected = 0; var browserSelected = 0; if (mode == 0) editSelected = 1; if (mode == 1) browserSelected = 1; dump(editButton+browserButton+" Display mode: EditSelected="+editSelected+" BrowserSelected="+browserSelected+"\n"); editButton.setAttribute("selected",Number(editSelected)); browserButton.setAttribute("selected",Number(browserSelected));}
editorShell.editorDocument.SetDocumentCharacterSet(aCharset);
editorShell.SetDocumentCharacterSet(aCharset);
function EditorSetDocumentCharacterSet(aCharset){ dump(aCharset); editorShell.editorDocument.SetDocumentCharacterSet(aCharset);}
dump(aCharset); editorShell.SetDocumentCharacterSet(aCharset);
if(window.editorShell && (! window.editorShell.documentModified) && editorShell.editorDocument.locatoin != "about:blank") { dump(aCharset); editorShell.SetDocumentCharacterSet(aCharset); editorShell.LoadUrl(editorShell.editorDocument.location); }
function EditorSetDocumentCharacterSet(aCharset){ dump(aCharset); editorShell.SetDocumentCharacterSet(aCharset);}
gContentWindow.focus();
window.content.focus();
function EditorSetFontColor(color){ editorShell.SetTextProperty("font", "color", color); gContentWindow.focus();}
dump("Setting focus to content window...\n");
function EditorSetFontFace(fontFace){ if( fontFace == "tt") { // The old "teletype" attribute editorShell.SetTextProperty("tt", "", ""); // Clear existing font face editorShell.RemoveTextProperty("font", "face"); } else { // Remove any existing TT nodes editorShell.RemoveTextProperty("tt", "", ""); if( fontFace == "" || fontFace == "normal") { editorShell.RemoveTextProperty("font", "face"); } else { editorShell.SetTextProperty("font", "face", fontFace); } } contentWindow.focus();}
function EditorSetFontFace(fontFace)
function EditorSetFontFace(commandID, fontFace)
function EditorSetFontFace(fontFace){ if (fontFace == "tt") { // The old "teletype" attribute editorShell.SetTextProperty("tt", "", ""); // Clear existing font face editorShell.RemoveTextProperty("font", "face"); } else { // Remove any existing TT nodes editorShell.RemoveTextProperty("tt", "", ""); if( fontFace == "" || fontFace == "normal") { editorShell.RemoveTextProperty("font", "face"); } else { editorShell.SetTextProperty("font", "face", fontFace); } } //dump("Setting focus to content window...\n"); gContentWindow.focus();}
if (fontFace == "tt") {
dump("Setting font face to " + fontFace + "\n"); var commandNode = document.getElementById(commandID); commandNode.setAttribute("state", fontFace); window.content.focus(); goDoCommand(commandID); /* if (fontFace == "tt") {
function EditorSetFontFace(fontFace){ if (fontFace == "tt") { // The old "teletype" attribute editorShell.SetTextProperty("tt", "", ""); // Clear existing font face editorShell.RemoveTextProperty("font", "face"); } else { // Remove any existing TT nodes editorShell.RemoveTextProperty("tt", "", ""); if( fontFace == "" || fontFace == "normal") { editorShell.RemoveTextProperty("font", "face"); } else { editorShell.SetTextProperty("font", "face", fontFace); } } //dump("Setting focus to content window...\n"); gContentWindow.focus();}
gContentWindow.focus();
window.content.focus(); */
function EditorSetFontFace(fontFace){ if (fontFace == "tt") { // The old "teletype" attribute editorShell.SetTextProperty("tt", "", ""); // Clear existing font face editorShell.RemoveTextProperty("font", "face"); } else { // Remove any existing TT nodes editorShell.RemoveTextProperty("tt", "", ""); if( fontFace == "" || fontFace == "normal") { editorShell.RemoveTextProperty("font", "face"); } else { editorShell.SetTextProperty("font", "face", fontFace); } } //dump("Setting focus to content window...\n"); gContentWindow.focus();}
dump("Setting focus to content window...\n");
function EditorSetFontFace(fontFace){ if( fontFace == "tt") { // The old "teletype" attribute editorShell.SetTextProperty("tt", "", ""); // Clear existing font face editorShell.RemoveTextProperty("font", "face"); } else { // Remove any existing TT nodes editorShell.RemoveTextProperty("tt", "", ""); if( fontFace == "" || fontFace == "normal") { editorShell.RemoveTextProperty("font", "face"); } else { editorShell.SetTextProperty("font", "face", fontFace); } } dump("Setting focus to content window...\n"); contentWindow.focus();}
editorShell.RemoveTextProperty("small", ""); editorShell.RemoveTextProperty("big", "");
function EditorSetFontSize(size){ if( size == "0" || size == "normal" || size == "medium" ) { editorShell.RemoveTextProperty("font", "size"); } else { // Temp: convert from new CSS size strings to old HTML size strings switch (size) { case "xx-small": case "x-small": size = "-2"; break; case "small": size = "-1"; break; case "large": size = "+1"; break; case "x-large": size = "+2"; break; case "xx-large": size = "+3"; break; } editorShell.SetTextProperty("font", "size", size); } gContentWindow.focus();}
editorShell.RemoveTextProperty("font", size);
editorShell.RemoveTextProperty("font", "size");
function EditorSetFontSize(size){ if( size == "0" || size == "normal" || size == "medium" ) { editorShell.RemoveTextProperty("font", size); dump("Removing font size\n"); } else { dump("Setting font size\n"); // Temp: convert from new CSS size strings to old HTML size strings switch (size) { case "xx-small": case "x-small": size = "-2"; break; case "small": size = "-1"; break; case "large": size = "+1"; break; case "x-large": size = "+2"; break; case "xx-large": size = "+3"; break; } editorShell.SetTextProperty("font", "size", size); }/* BIG BUG! Setting <span> tag is totally horked -- stick with <font size> for beta1 { // XXX-THIS IS DEFINITELY WRONG! // We need to parse the style tag to set/remove only the "font-size" // TODO: We need a general SetInlineStyle(), RemoveInlineStyle() interface editorShell.RemoveTextProperty("span", "style"); dump("Removing font size\n"); } else { dump("Setting font size to: "+size+"\n"); editorShell.SetTextProperty("span", "style", "font-size:"+size); }*/ gContentWindow.focus();}
dump("Saving para format state " + paraFormat + "\n");
function EditorSetParagraphFormat(commandID, paraFormat){ // editorShell.SetParagraphFormat(paraFormat); var commandNode = document.getElementById(commandID); dump("Saving para format state " + paraFormat + "\n"); commandNode.setAttribute("state", paraFormat); window.content.focus(); // needed for command dispatch to work goDoCommand(commandID);}
function EditorSetParagraphFormat(paraFormat)
function EditorSetParagraphFormat(commandID, paraFormat)
function EditorSetParagraphFormat(paraFormat){ editorShell.SetParagraphFormat(paraFormat); contentWindow.focus();}
editorShell.SetParagraphFormat(paraFormat); contentWindow.focus();
var commandNode = document.getElementById(commandID); dump("Saving para format state " + paraFormat + "\n"); commandNode.setAttribute("state", paraFormat); window.content.focus(); goDoCommand(commandID);
function EditorSetParagraphFormat(paraFormat){ editorShell.SetParagraphFormat(paraFormat); contentWindow.focus();}
selection.clearSelection();
selection.removeAllRanges();
function EditorSetSelectionFromOffsets(selRanges){ var rangeArr, start, end, node, offset; var selection = editorShell.editorSelection; selection.clearSelection(); for (var i = 0; i < selRanges.length; i++) { rangeArr = selRanges[i]; start = rangeArr[0]; end = rangeArr[1]; var range = editorShell.editorDocument.createRange(); node = EditorGetNodeFromOffsets(start[0]); offset = start[1]; range.setStart(node, offset); node = EditorGetNodeFromOffsets(end[0]); offset = end[1]; range.setEnd(node, offset); selection.addRange(range); }}
HideImage();
function EditorSharedStartup(){ // set up JS-implemented commands SetupControllerCommands(); // Just for convenience gContentWindow = window._content; gIsWin = navigator.appVersion.indexOf("Win") != -1; gIsUNIX = (navigator.appVersion.indexOf("X11") || navigator.appVersion.indexOf("nux")) != -1; gIsMac = !gIsWin && !gIsUNIX; //dump("IsWin="+gIsWin+", IsUNIX="+gIsUNIX+", IsMac="+gIsMac+"\n"); // Set platform-specific hints for how to select cells // Mac uses "Cmd", all others use "Ctrl" var tableKey = GetString(gIsMac ? "XulKeyMac" : "TableSelectKey"); var dragStr = tableKey+GetString("Drag"); var clickStr = tableKey+GetString("Click"); var delStr = GetString(gIsMac ? "Clear" : "Del"); SafeSetAttribute("menu_SelectCell", "acceltext", clickStr); SafeSetAttribute("menu_SelectRow", "acceltext", dragStr); SafeSetAttribute("menu_SelectColumn", "acceltext", dragStr); SafeSetAttribute("menu_SelectAllCells", "acceltext", dragStr); // And add "Del" or "Clear" SafeSetAttribute("menu_DeleteCellContents", "acceltext", delStr); // hide UI that we don't have components for RemoveInapplicableUIElements();}
editorShell.contentsMIMEType = "text/html";
editorShell.contentsMIMEType = kHTMLMimeType;
function EditorSharedStartup(){ // Just for convenience gContentWindow = window._content; switch (editorShell.editorType) { case "html": case "htmlmail": gIsHTMLEditor = true; break; case "text": case "textmail": gIsHTMLEditor = false; break; default: dump("INVALID EDITOR TYPE: " + editorShell.editorType + "\n"); gIsHTMLEditor = false; break; } // Set up the mime type and register the commands. // We don't have an editor yet -- in fact, this is the listener which // will tell us when it's time to create the editor. // So we can't use gEditor.AddDocumentStateListener here. if (gIsHTMLEditor) { editorShell.contentsMIMEType = "text/html"; SetupHTMLEditorCommands(); } else { editorShell.contentsMIMEType = "text/plain"; SetupTextEditorCommands(); } // add a listener to be called when document is really done loading if (editorShell.editorType == "htmlmail" || editorShell.editorType == "textmail") editorShell.RegisterDocumentStateListener( MessageComposeDocumentStateListener ); else editorShell.RegisterDocumentStateListener( DocumentStateListener ); var isMac = (GetOS() == gMac); // Set platform-specific hints for how to select cells // Mac uses "Cmd", all others use "Ctrl" var tableKey = GetString(isMac ? "XulKeyMac" : "TableSelectKey"); var dragStr = tableKey+GetString("Drag"); var clickStr = tableKey+GetString("Click"); var delStr = GetString(isMac ? "Clear" : "Del"); SafeSetAttribute("menu_SelectCell", "acceltext", clickStr); SafeSetAttribute("menu_SelectRow", "acceltext", dragStr); SafeSetAttribute("menu_SelectColumn", "acceltext", dragStr); SafeSetAttribute("menu_SelectAllCells", "acceltext", dragStr); // And add "Del" or "Clear" SafeSetAttribute("menu_DeleteCellContents", "acceltext", delStr); // Set text for indent, outdent keybinding // hide UI that we don't have components for RemoveInapplicableUIElements(); gPrefs = GetPrefs(); // Use browser colors as initial values for editor's default colors var BrowserColors = GetDefaultBrowserColors(); if (BrowserColors) { gDefaultTextColor = BrowserColors.TextColor; gDefaultBackgroundColor = BrowserColors.BackgroundColor; } // For new window, no default last-picked colors gColorObj.LastTextColor = ""; gColorObj.LastBackgroundColor = ""; gColorObj.LastHighlightColor = "";}
editorShell.contentsMIMEType = "text/plain";
editorShell.contentsMIMEType = kTextMimeType;
function EditorSharedStartup(){ // Just for convenience gContentWindow = window._content; switch (editorShell.editorType) { case "html": case "htmlmail": gIsHTMLEditor = true; break; case "text": case "textmail": gIsHTMLEditor = false; break; default: dump("INVALID EDITOR TYPE: " + editorShell.editorType + "\n"); gIsHTMLEditor = false; break; } // Set up the mime type and register the commands. // We don't have an editor yet -- in fact, this is the listener which // will tell us when it's time to create the editor. // So we can't use gEditor.AddDocumentStateListener here. if (gIsHTMLEditor) { editorShell.contentsMIMEType = "text/html"; SetupHTMLEditorCommands(); } else { editorShell.contentsMIMEType = "text/plain"; SetupTextEditorCommands(); } // add a listener to be called when document is really done loading if (editorShell.editorType == "htmlmail" || editorShell.editorType == "textmail") editorShell.RegisterDocumentStateListener( MessageComposeDocumentStateListener ); else editorShell.RegisterDocumentStateListener( DocumentStateListener ); var isMac = (GetOS() == gMac); // Set platform-specific hints for how to select cells // Mac uses "Cmd", all others use "Ctrl" var tableKey = GetString(isMac ? "XulKeyMac" : "TableSelectKey"); var dragStr = tableKey+GetString("Drag"); var clickStr = tableKey+GetString("Click"); var delStr = GetString(isMac ? "Clear" : "Del"); SafeSetAttribute("menu_SelectCell", "acceltext", clickStr); SafeSetAttribute("menu_SelectRow", "acceltext", dragStr); SafeSetAttribute("menu_SelectColumn", "acceltext", dragStr); SafeSetAttribute("menu_SelectAllCells", "acceltext", dragStr); // And add "Del" or "Clear" SafeSetAttribute("menu_DeleteCellContents", "acceltext", delStr); // Set text for indent, outdent keybinding // hide UI that we don't have components for RemoveInapplicableUIElements(); gPrefs = GetPrefs(); // Use browser colors as initial values for editor's default colors var BrowserColors = GetDefaultBrowserColors(); if (BrowserColors) { gDefaultTextColor = BrowserColors.TextColor; gDefaultBackgroundColor = BrowserColors.BackgroundColor; } // For new window, no default last-picked colors gColorObj.LastTextColor = ""; gColorObj.LastBackgroundColor = ""; gColorObj.LastHighlightColor = "";}
dump("In EditorShutdown..\n"); return editorShell.Shutdown();
function EditorShutdown(){ dump("In EditorShutdown..\n"); return editorShell.Shutdown();}
RemoveToolbarPrefListener();
gEditorToolbarPrefListener.shutdown();
function EditorShutdown(){ RemoveToolbarPrefListener(); gCSSPrefListener.shutdown(); try { var commandManager = GetCurrentCommandManager(); commandManager.removeCommandObserver(gEditorDocumentObserver, "obs_documentCreated"); commandManager.removeCommandObserver(gEditorDocumentObserver, "obs_documentWillBeDestroyed"); commandManager.removeCommandObserver(gEditorDocumentObserver, "obs_documentLocationChanged"); } catch (e) { dump (e); } }
gReturnInParagraphPrefListener.shutdown();
function EditorShutdown(){ RemoveToolbarPrefListener(); gCSSPrefListener.shutdown(); try { var commandManager = GetCurrentCommandManager(); commandManager.removeCommandObserver(gEditorDocumentObserver, "obs_documentCreated"); commandManager.removeCommandObserver(gEditorDocumentObserver, "obs_documentWillBeDestroyed"); commandManager.removeCommandObserver(gEditorDocumentObserver, "obs_documentLocationChanged"); } catch (e) { dump (e); } }
catch(ex) { dump("Can't start logging!:\n" + ex + "\n");
catch(ex) { dump("Can't start logging!:\n" + ex + "\n"); }
function EditorStartLog(){ try { var edlog = gEditor.QueryInterface(Components.interfaces.nsIEditorLogging); var fs = EditorGetScriptFileSpec(); edlog.startLogging(fs); window._content.focus(); fs = null; } catch(ex) { dump("Can't start logging!:\n" + ex + "\n");}function EditorStopLog(){ try { var edlog = gEditor.QueryInterface(Components.interfaces.nsIEditorLogging); edlog.stopLogging(); window._content.focus(); } catch(ex) { dump("Can't stop logging!:\n" + ex + "\n");}function EditorRunLog(){ var fs; fs = EditorGetScriptFileSpec(); EditorExecuteScript(fs); window._content.focus();}// --------------------------- TransactionManager ---------------------------function DumpUndoStack(){ try { var txmgr = GetCurrentEditor().transactionManager; if (!txmgr) { dump("**** Editor has no TransactionManager!\n"); return; } dump("---------------------- BEGIN UNDO STACK DUMP\n"); dump("<!-- Bottom of Stack -->\n"); PrintTxnList(txmgr.getUndoList(), ""); dump("<!-- Top of Stack -->\n"); dump("Num Undo Items: " + txmgr.numberOfUndoItems + "\n"); dump("---------------------- END UNDO STACK DUMP\n"); } catch (e) { dump("ERROR: DumpUndoStack() failed: " + e); }}function DumpRedoStack(){ try { var txmgr = GetCurrentEditor().transactionManager; if (!txmgr) { dump("**** Editor has no TransactionManager!\n"); return; } dump("---------------------- BEGIN REDO STACK DUMP\n"); dump("<!-- Bottom of Stack -->\n"); PrintTxnList(txmgr.getRedoList(), ""); dump("<!-- Top of Stack -->\n"); dump("Num Redo Items: " + txmgr.numberOfRedoItems + "\n"); dump("---------------------- END REDO STACK DUMP\n"); } catch (e) { dump("ERROR: DumpUndoStack() failed: " + e); }}function PrintTxnList(txnList, prefixStr){ var i; for (i=0 ; i < txnList.numItems; i++) { var txn = txnList.getItem(i); var desc = "TXMgr Batch"; if (txn) { txn = txn.QueryInterface(Components.interfaces.nsPIEditorTransaction); desc = txn.txnDescription; } dump(prefixStr + "+ " + desc + "\n"); PrintTxnList(txnList.getChildListForItem(i), prefixStr + "| "); }}
function EditorStopLog() { try { var edlog = gEditor.QueryInterface(Components.interfaces.nsIEditorLogging); edlog.stopLogging(); window._content.focus(); } catch(ex) { dump("Can't stop logging!:\n" + ex + "\n"); } function EditorRunLog() { var fs; fs = EditorGetScriptFileSpec(); EditorExecuteScript(fs); window._content.focus(); } function DumpUndoStack() { try { var txmgr = GetCurrentEditor().transactionManager; if (!txmgr) { dump("**** Editor has no TransactionManager!\n"); return; } dump("---------------------- BEGIN UNDO STACK DUMP\n"); dump("<!-- Bottom of Stack -->\n"); PrintTxnList(txmgr.getUndoList(), ""); dump("<!-- Top of Stack -->\n"); dump("Num Undo Items: " + txmgr.numberOfUndoItems + "\n"); dump("---------------------- END UNDO STACK DUMP\n"); } catch (e) { dump("ERROR: DumpUndoStack() failed: " + e); } } function DumpRedoStack() { try { var txmgr = GetCurrentEditor().transactionManager; if (!txmgr) { dump("**** Editor has no TransactionManager!\n"); return; } dump("---------------------- BEGIN REDO STACK DUMP\n"); dump("<!-- Bottom of Stack -->\n"); PrintTxnList(txmgr.getRedoList(), ""); dump("<!-- Top of Stack -->\n"); dump("Num Redo Items: " + txmgr.numberOfRedoItems + "\n"); dump("---------------------- END REDO STACK DUMP\n"); } catch (e) { dump("ERROR: DumpUndoStack() failed: " + e); } } function PrintTxnList(txnList, prefixStr) { var i; for (i=0 ; i < txnList.numItems; i++) { var txn = txnList.getItem(i); var desc = "TXMgr Batch"; if (txn) { txn = txn.QueryInterface(Components.interfaces.nsPIEditorTransaction); desc = txn.txnDescription; } dump(prefixStr + "+ " + desc + "\n"); PrintTxnList(txnList.getChildListForItem(i), prefixStr + "| "); } }
function EditorStartLog(){ try { var edlog = gEditor.QueryInterface(Components.interfaces.nsIEditorLogging); var fs = EditorGetScriptFileSpec(); edlog.startLogging(fs); window._content.focus(); fs = null; } catch(ex) { dump("Can't start logging!:\n" + ex + "\n");}function EditorStopLog(){ try { var edlog = gEditor.QueryInterface(Components.interfaces.nsIEditorLogging); edlog.stopLogging(); window._content.focus(); } catch(ex) { dump("Can't stop logging!:\n" + ex + "\n");}function EditorRunLog(){ var fs; fs = EditorGetScriptFileSpec(); EditorExecuteScript(fs); window._content.focus();}// --------------------------- TransactionManager ---------------------------function DumpUndoStack(){ try { var txmgr = GetCurrentEditor().transactionManager; if (!txmgr) { dump("**** Editor has no TransactionManager!\n"); return; } dump("---------------------- BEGIN UNDO STACK DUMP\n"); dump("<!-- Bottom of Stack -->\n"); PrintTxnList(txmgr.getUndoList(), ""); dump("<!-- Top of Stack -->\n"); dump("Num Undo Items: " + txmgr.numberOfUndoItems + "\n"); dump("---------------------- END UNDO STACK DUMP\n"); } catch (e) { dump("ERROR: DumpUndoStack() failed: " + e); }}function DumpRedoStack(){ try { var txmgr = GetCurrentEditor().transactionManager; if (!txmgr) { dump("**** Editor has no TransactionManager!\n"); return; } dump("---------------------- BEGIN REDO STACK DUMP\n"); dump("<!-- Bottom of Stack -->\n"); PrintTxnList(txmgr.getRedoList(), ""); dump("<!-- Top of Stack -->\n"); dump("Num Redo Items: " + txmgr.numberOfRedoItems + "\n"); dump("---------------------- END REDO STACK DUMP\n"); } catch (e) { dump("ERROR: DumpUndoStack() failed: " + e); }}function PrintTxnList(txnList, prefixStr){ var i; for (i=0 ; i < txnList.numItems; i++) { var txn = txnList.getItem(i); var desc = "TXMgr Batch"; if (txn) { txn = txn.QueryInterface(Components.interfaces.nsPIEditorTransaction); desc = txn.txnDescription; } dump(prefixStr + "+ " + desc + "\n"); PrintTxnList(txnList.getChildListForItem(i), prefixStr + "| "); }}
window.focus();
contentWindow.focus();
function EditorStartup(editorType){ dump("Doing Startup...\n"); contentWindow = window.frames[0]; dump("Trying to make an editor appcore through the component manager...\n"); var editorShell = Components.classes["component://netscape/editor/editorshell"].createInstance(); editorShell = editorShell.QueryInterface(Components.interfaces.nsIEditorShell); if (!editorShell) { dump("Failed to create editor shell\n"); window.close(); return; } // store the editor shell in the window, so that child windows can get to it. window.editorShell = editorShell; window.editorShell.Init(); window.editorShell.SetWebShellWindow(window); window.editorShell.SetToolbarWindow(window) window.editorShell.SetEditorType(editorType); window.editorShell.SetContentWindow(contentWindow); // Get url for editor content and load it. // the editor gets instantiated by the editor shell when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); window.editorShell.LoadUrl(url); dump("EditorAppCore windows have been set.\n"); SetupToolbarElements(); // Set focus to the edit window window.focus();}
EditorSetup(editorName, appCore)
EditorSetup(editorName, appCore); window.focus();
function EditorStartup(){ 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) { dump(editorName + " has been created.\n"); appCore.Init(editorName); appCore.setWebShellWindow(window); appCore.setToolbarWindow(window) appCore.setEditorType("html"); appCore.setContentWindow( window.frames[0] ); // Get url for editor content var url = document.getElementById("args").getAttribute("value"); // Load the source (the app core will magically know what to do). appCore.loadUrl(url); // the editor gets instantiated by the appcore when the URL has finished loading. dump("EditorAppCore windows have been set.\n"); } } else { dump("EditorAppCore has already been created! Why?\n"); } EditorSetup(editorName, appCore)}
ToggleEditModeType(gNormalModeButton.getAttribute("type"));
function EditorStartup(editorType, editorElement){ gIsHTMLEditor = (editorType == "html"); if (gIsHTMLEditor) { gSourceContentWindow = document.getElementById("content-source"); gEditModeBar = document.getElementById("EditModeToolbar"); gEditModeLabel = document.getElementById("EditModeLabel"); gNormalModeButton = document.getElementById("NormalModeButton"); gTagModeButton = document.getElementById("TagModeButton"); gSourceModeButton = document.getElementById("SourceModeButton"); gPreviewModeButton = document.getElementById("PreviewModeButton"); // The "type" attribute persists, so use that value // to setup edit mode buttons ToggleEditModeType(gNormalModeButton.getAttribute("type")); // XUL elements we use when switching from normal editor to edit source gContentWindowDeck = document.getElementById("ContentWindowDeck"); gFormatToolbar = document.getElementById("FormatToolbar"); } // store the editor shell in the window, so that child windows can get to it. editorShell = editorElement.editorShell; // this pattern exposes a JS/XBL bug that causes leaks// editorShell = editorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).editorShell; editorShell.Init(); editorShell.SetEditorType(editorType); editorShell.webShellWindow = window; editorShell.contentWindow = window._content; // add a listener to be called when document is really done loading editorShell.RegisterDocumentStateListener( DocumentStateListener ); // Startup also used by other editor users, such as Message Composer EditorSharedStartup() // set up our global prefs object GetPrefsService(); // Get url for editor content and load it. // the editor gets instantiated by the editor shell when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); editorShell.LoadUrl(url);}
EditorSharedStartup()
EditorSharedStartup(); SetupHTMLSourceController();
function EditorStartup(editorType, editorElement){ gIsHTMLEditor = (editorType == "html"); if (gIsHTMLEditor) { gSourceContentWindow = document.getElementById("content-source"); gEditModeBar = document.getElementById("EditModeToolbar"); gEditModeLabel = document.getElementById("EditModeLabel"); gNormalModeButton = document.getElementById("NormalModeButton"); gTagModeButton = document.getElementById("TagModeButton"); gSourceModeButton = document.getElementById("SourceModeButton"); gPreviewModeButton = document.getElementById("PreviewModeButton"); // The "type" attribute persists, so use that value // to setup edit mode buttons ToggleEditModeType(gNormalModeButton.getAttribute("type")); // XUL elements we use when switching from normal editor to edit source gContentWindowDeck = document.getElementById("ContentWindowDeck"); gFormatToolbar = document.getElementById("FormatToolbar"); } // store the editor shell in the window, so that child windows can get to it. editorShell = editorElement.editorShell; // this pattern exposes a JS/XBL bug that causes leaks// editorShell = editorElement.boxObject.QueryInterface(Components.interfaces.nsIEditorBoxObject).editorShell; editorShell.Init(); editorShell.SetEditorType(editorType); editorShell.webShellWindow = window; editorShell.contentWindow = window._content; // add a listener to be called when document is really done loading editorShell.RegisterDocumentStateListener( DocumentStateListener ); // Startup also used by other editor users, such as Message Composer EditorSharedStartup() // set up our global prefs object GetPrefsService(); // Get url for editor content and load it. // the editor gets instantiated by the editor shell when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); editorShell.LoadUrl(url);}
editorShell.Init();
function EditorStartup(editorType, editorElement){ gIsHTMLEditor = (editorType == "html"); if (gIsHTMLEditor) { gSourceContentWindow = document.getElementById("content-source"); gEditModeBar = document.getElementById("EditModeToolbar"); gNormalModeButton = document.getElementById("NormalModeButton"); gTagModeButton = document.getElementById("TagModeButton"); gSourceModeButton = document.getElementById("SourceModeButton"); gPreviewModeButton = document.getElementById("PreviewModeButton"); // mark first tab as selected document.getElementById("EditModeTabbox").selectedTab = gNormalModeButton; // XUL elements we use when switching from normal editor to edit source gContentWindowDeck = document.getElementById("ContentWindowDeck"); gFormatToolbar = document.getElementById("FormatToolbar"); } // store the editor shell in the window, so that child windows can get to it. editorShell = editorElement.editorShell; // this pattern exposes a JS/XBL bug that causes leaks editorShell.Init(); editorShell.editorType = editorType; editorShell.webShellWindow = window; editorShell.contentWindow = window._content; // add a listener to be called when document is really done loading editorShell.RegisterDocumentStateListener( DocumentStateListener ); // set up our global prefs object GetPrefsService(); // Startup also used by other editor users, such as Message Composer EditorSharedStartup(); // Commands specific to the Composer Application window, // (i.e., not embeded editors) // such as file-related commands, HTML Source editing, Edit Modes... SetupComposerWindowCommands(); // Get url for editor content and load it. // the editor gets instantiated by the editor shell when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); editorShell.LoadUrl(url);}
editorShell.SetWebShellWindow(window); editorShell.SetToolbarWindow(window)
function EditorStartup(editorType, editorElement){ contentWindow = window.content; // store the editor shell in the window, so that child windows can get to it. editorShell = editorElement.editorShell; editorShell.Init(); editorShell.SetWebShellWindow(window); editorShell.SetToolbarWindow(window) editorShell.SetEditorType(editorType); editorShell.SetContentWindow(contentWindow); // add a listener to be called when document is really done loading editorShell.RegisterDocumentStateListener( DocumentStateListener ); // Get url for editor content and load it. // the editor gets instantiated by the editor shell when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); editorShell.LoadUrl(url); // Set focus to the edit window // This still doesn't work! // It works after using a toolbar button, however! contentWindow.focus();}
editorShell.SetContentWindow(contentWindow);
function EditorStartup(editorType, editorElement){ contentWindow = window.content; // store the editor shell in the window, so that child windows can get to it. editorShell = editorElement.editorShell; editorShell.Init(); editorShell.SetWebShellWindow(window); editorShell.SetToolbarWindow(window) editorShell.SetEditorType(editorType); editorShell.SetContentWindow(contentWindow); // add a listener to be called when document is really done loading editorShell.RegisterDocumentStateListener( DocumentStateListener ); // Get url for editor content and load it. // the editor gets instantiated by the editor shell when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); editorShell.LoadUrl(url); // Set focus to the edit window // This still doesn't work! // It works after using a toolbar button, however! contentWindow.focus();}
window.updateCommands("create");
function EditorStartup(editorType, editorElement){ contentWindow = window.content; // store the editor shell in the window, so that child windows can get to it. editorShell = editorElement.editorShell; editorShell.Init(); editorShell.SetWebShellWindow(window); editorShell.SetToolbarWindow(window) editorShell.SetEditorType(editorType); editorShell.SetContentWindow(contentWindow); // add a listener to be called when document is really done loading editorShell.RegisterDocumentStateListener( DocumentStateListener ); // Get url for editor content and load it. // the editor gets instantiated by the editor shell when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); editorShell.LoadUrl(url); // Set focus to the edit window // This still doesn't work! // It works after using a toolbar button, however! contentWindow.focus();}
window.addEventListener("load", EditorDocumentLoaded, true, false); dump("Trying to make an Editor Shell through the component manager...\n");
function EditorStartup(editorType, editorElement){ dump("Doing Editor Startup...\n"); contentWindow = window.content; // set up event listeners window.addEventListener("load", EditorDocumentLoaded, true, false); dump("Trying to make an Editor Shell through the component manager...\n"); // store the editor shell in the window, so that child windows can get to it. var editorShell = window.editorShell = editorElement.editorShell; editorShell.Init(); editorShell.SetWebShellWindow(window); editorShell.SetToolbarWindow(window) editorShell.SetEditorType(editorType); editorShell.SetContentWindow(contentWindow); // add a listener to be called when document is really done loading editorShell.RegisterDocumentStateListener( DocumentStateListener ); // Get url for editor content and load it. // the editor gets instantiated by the editor shell when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); editorShell.LoadUrl(url); dump("EditorAppCore windows have been set.\n"); // Set focus to the edit window // This still doesn't work! // It works after using a toolbar button, however! contentWindow.focus();}
AddToolbarPrefListener();
gEditorToolbarPrefListener = new nsPrefListener(kEditorToolbarPrefs);
function EditorStartup(){ var ds = GetCurrentEditorElement().docShell; var root = ds.QueryInterface(Components.interfaces.nsIDocShellTreeItem). rootTreeItem.QueryInterface(Components.interfaces.nsIDocShell); root.QueryInterface(Components.interfaces.nsIDocShell).appType = Components.interfaces.nsIDocShell.APP_TYPE_EDITOR; var is_HTMLEditor = IsHTMLEditor(); if (is_HTMLEditor) { // XUL elements we use when switching from normal editor to edit source gContentWindowDeck = document.getElementById("ContentWindowDeck"); gFormatToolbar = document.getElementById("FormatToolbar"); gViewFormatToolbar = document.getElementById("viewFormatToolbar"); } // set up our global prefs object GetPrefsService(); // Startup also used by other editor users, such as Message Composer EditorSharedStartup(); // Commands specific to the Composer Application window, // (i.e., not embedded editors) // such as file-related commands, HTML Source editing, Edit Modes... SetupComposerWindowCommands(); ShowHideToolbarButtons(); AddToolbarPrefListener(); gCSSPrefListener = new nsButtonPrefListener(); // hide Highlight button if we are in an HTML editor with CSS mode off var cmd = document.getElementById("cmd_highlight"); if (cmd) { var prefs = GetPrefs(); var useCSS = prefs.getBoolPref("editor.use_css"); if (!useCSS && is_HTMLEditor) { cmd.collapsed = true; } } // Get url for editor content and load it. // the editor gets instantiated by the edittingSession when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); try { var charset = document.getElementById("args").getAttribute("charset"); var contentViewer = GetCurrentEditorElement().docShell.contentViewer; contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer); contentViewer.defaultCharacterSet = charset; contentViewer.forceCharacterSet = charset; } catch (e) {} EditorLoadUrl(url);}
gCSSPrefListener = new nsButtonPrefListener();
gCSSPrefListener = new nsPrefListener(kUseCssPref); gReturnInParagraphPrefListener = new nsPrefListener(kCRInParagraphsPref);
function EditorStartup(){ var ds = GetCurrentEditorElement().docShell; var root = ds.QueryInterface(Components.interfaces.nsIDocShellTreeItem). rootTreeItem.QueryInterface(Components.interfaces.nsIDocShell); root.QueryInterface(Components.interfaces.nsIDocShell).appType = Components.interfaces.nsIDocShell.APP_TYPE_EDITOR; var is_HTMLEditor = IsHTMLEditor(); if (is_HTMLEditor) { // XUL elements we use when switching from normal editor to edit source gContentWindowDeck = document.getElementById("ContentWindowDeck"); gFormatToolbar = document.getElementById("FormatToolbar"); gViewFormatToolbar = document.getElementById("viewFormatToolbar"); } // set up our global prefs object GetPrefsService(); // Startup also used by other editor users, such as Message Composer EditorSharedStartup(); // Commands specific to the Composer Application window, // (i.e., not embedded editors) // such as file-related commands, HTML Source editing, Edit Modes... SetupComposerWindowCommands(); ShowHideToolbarButtons(); AddToolbarPrefListener(); gCSSPrefListener = new nsButtonPrefListener(); // hide Highlight button if we are in an HTML editor with CSS mode off var cmd = document.getElementById("cmd_highlight"); if (cmd) { var prefs = GetPrefs(); var useCSS = prefs.getBoolPref("editor.use_css"); if (!useCSS && is_HTMLEditor) { cmd.collapsed = true; } } // Get url for editor content and load it. // the editor gets instantiated by the edittingSession when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); try { var charset = document.getElementById("args").getAttribute("charset"); var contentViewer = GetCurrentEditorElement().docShell.contentViewer; contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer); contentViewer.defaultCharacterSet = charset; contentViewer.forceCharacterSet = charset; } catch (e) {} EditorLoadUrl(url);}
var prefs = GetPrefs(); var useCSS = prefs.getBoolPref("editor.use_css");
var useCSS = prefs.getBoolPref(kUseCssPref);
function EditorStartup(){ var ds = GetCurrentEditorElement().docShell; var root = ds.QueryInterface(Components.interfaces.nsIDocShellTreeItem). rootTreeItem.QueryInterface(Components.interfaces.nsIDocShell); root.QueryInterface(Components.interfaces.nsIDocShell).appType = Components.interfaces.nsIDocShell.APP_TYPE_EDITOR; var is_HTMLEditor = IsHTMLEditor(); if (is_HTMLEditor) { // XUL elements we use when switching from normal editor to edit source gContentWindowDeck = document.getElementById("ContentWindowDeck"); gFormatToolbar = document.getElementById("FormatToolbar"); gViewFormatToolbar = document.getElementById("viewFormatToolbar"); } // set up our global prefs object GetPrefsService(); // Startup also used by other editor users, such as Message Composer EditorSharedStartup(); // Commands specific to the Composer Application window, // (i.e., not embedded editors) // such as file-related commands, HTML Source editing, Edit Modes... SetupComposerWindowCommands(); ShowHideToolbarButtons(); AddToolbarPrefListener(); gCSSPrefListener = new nsButtonPrefListener(); // hide Highlight button if we are in an HTML editor with CSS mode off var cmd = document.getElementById("cmd_highlight"); if (cmd) { var prefs = GetPrefs(); var useCSS = prefs.getBoolPref("editor.use_css"); if (!useCSS && is_HTMLEditor) { cmd.collapsed = true; } } // Get url for editor content and load it. // the editor gets instantiated by the edittingSession when the URL has finished loading. var url = document.getElementById("args").getAttribute("value"); try { var charset = document.getElementById("args").getAttribute("charset"); var contentViewer = GetCurrentEditorElement().docShell.contentViewer; contentViewer.QueryInterface(Components.interfaces.nsIMarkupDocumentViewer); contentViewer.defaultCharacterSet = charset; contentViewer.forceCharacterSet = charset; } catch (e) {} EditorLoadUrl(url);}
catch(ex) { dump("Can't stop logging!:\n" + ex + "\n");
catch(ex) { dump("Can't stop logging!:\n" + ex + "\n"); }
function EditorStopLog(){ try { var edlog = gEditor.QueryInterface(Components.interfaces.nsIEditorLogging); edlog.stopLogging(); window._content.focus(); } catch(ex) { dump("Can't stop logging!:\n" + ex + "\n");}function EditorRunLog(){ var fs; fs = EditorGetScriptFileSpec(); EditorExecuteScript(fs); window._content.focus();}// --------------------------- TransactionManager ---------------------------function DumpUndoStack(){ try { var txmgr = GetCurrentEditor().transactionManager; if (!txmgr) { dump("**** Editor has no TransactionManager!\n"); return; } dump("---------------------- BEGIN UNDO STACK DUMP\n"); dump("<!-- Bottom of Stack -->\n"); PrintTxnList(txmgr.getUndoList(), ""); dump("<!-- Top of Stack -->\n"); dump("Num Undo Items: " + txmgr.numberOfUndoItems + "\n"); dump("---------------------- END UNDO STACK DUMP\n"); } catch (e) { dump("ERROR: DumpUndoStack() failed: " + e); }}function DumpRedoStack(){ try { var txmgr = GetCurrentEditor().transactionManager; if (!txmgr) { dump("**** Editor has no TransactionManager!\n"); return; } dump("---------------------- BEGIN REDO STACK DUMP\n"); dump("<!-- Bottom of Stack -->\n"); PrintTxnList(txmgr.getRedoList(), ""); dump("<!-- Top of Stack -->\n"); dump("Num Redo Items: " + txmgr.numberOfRedoItems + "\n"); dump("---------------------- END REDO STACK DUMP\n"); } catch (e) { dump("ERROR: DumpUndoStack() failed: " + e); }}function PrintTxnList(txnList, prefixStr){ var i; for (i=0 ; i < txnList.numItems; i++) { var txn = txnList.getItem(i); var desc = "TXMgr Batch"; if (txn) { txn = txn.QueryInterface(Components.interfaces.nsPIEditorTransaction); desc = txn.txnDescription; } dump(prefixStr + "+ " + desc + "\n"); PrintTxnList(txnList.getChildListForItem(i), prefixStr + "| "); }}