UI work: Implemented table commands (part of 20973), fixed Plain Text editor, don't remove toolbars for HTML Source editmode, helped ftang with new 'Save As Charset' dialog (moved methods shared with Page Properties dialog to common file)

This commit is contained in:
cmanske%netscape.com 2000-05-12 02:37:40 +00:00
Родитель 8af8a29270
Коммит 7eedb58c10
13 изменённых файлов: 820 добавлений и 505 удалений

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

@ -28,6 +28,110 @@ var gComposerCommandManager = null;
var commonDialogsService = Components.classes["component://netscape/appshell/commonDialogs"].getService();
commonDialogsService = commonDialogsService.QueryInterface(Components.interfaces.nsICommonDialogs);
//-----------------------------------------------------------------------------------
function SetupControllerCommands()
{
gComposerCommandManager = GetComposerController();
if (!gComposerCommandManager)
return;
dump("Registering commands\n");
gComposerCommandManager.registerCommand("cmd_newEditor", nsNewEditorCommand);
gComposerCommandManager.registerCommand("cmd_open", nsOpenCommand);
gComposerCommandManager.registerCommand("cmd_saveAsCharset", nsSaveAsCharsetCommand);
gComposerCommandManager.registerCommand("cmd_revert", nsRevertCommand);
gComposerCommandManager.registerCommand("cmd_openRemote", nsOpenRemoteCommand);
gComposerCommandManager.registerCommand("cmd_preview", nsPreviewCommand);
gComposerCommandManager.registerCommand("cmd_quit", nsQuitCommand);
gComposerCommandManager.registerCommand("cmd_find", nsFindCommand);
gComposerCommandManager.registerCommand("cmd_findNext", nsFindNextCommand);
gComposerCommandManager.registerCommand("cmd_spelling", nsSpellingCommand);
gComposerCommandManager.registerCommand("cmd_editHTML", nsEditHTMLCommand);
gComposerCommandManager.registerCommand("cmd_insertChars", nsInsertCharsCommand);
gComposerCommandManager.registerCommand("cmd_preferences", nsPreferencesCommand);
gComposerCommandManager.registerCommand("cmd_listProperties", nsListPropertiesCommand);
gComposerCommandManager.registerCommand("cmd_pageProperties", nsPagePropertiesCommand);
gComposerCommandManager.registerCommand("cmd_colorProperties", nsColorPropertiesCommand);
gComposerCommandManager.registerCommand("cmd_advancedProperties", nsAdvancedPropertiesCommand);
gComposerCommandManager.registerCommand("cmd_image", nsImageCommand);
gComposerCommandManager.registerCommand("cmd_hline", nsHLineCommand);
gComposerCommandManager.registerCommand("cmd_table", nsTableCommand); // insert or edit
gComposerCommandManager.registerCommand("cmd_editTable", nsEditTableCommand); // edit
gComposerCommandManager.registerCommand("cmd_link", nsLinkCommand);
gComposerCommandManager.registerCommand("cmd_anchor", nsAnchorCommand);
gComposerCommandManager.registerCommand("cmd_insertHTML", nsInsertHTMLCommand);
gComposerCommandManager.registerCommand("cmd_insertBreak", nsInsertBreakCommand);
gComposerCommandManager.registerCommand("cmd_insertBreakAll",nsInsertBreakAllCommand);
gComposerCommandManager.registerCommand("cmd_SelectTable", nsSelectTableCommand);
gComposerCommandManager.registerCommand("cmd_SelectRow", nsSelectTableRowCommand);
gComposerCommandManager.registerCommand("cmd_SelectColumn", nsSelectTableColumnCommand);
gComposerCommandManager.registerCommand("cmd_SelectCell", nsSelectTableCellCommand);
gComposerCommandManager.registerCommand("cmd_SelectAllCells", nsSelectAllTableCellsCommand);
gComposerCommandManager.registerCommand("cmd_InsertTable", nsInsertTableCommand);
gComposerCommandManager.registerCommand("cmd_InsertRowAbove", nsInsertTableRowAboveCommand);
gComposerCommandManager.registerCommand("cmd_InsertRowBelow", nsInsertTableRowBelowCommand);
gComposerCommandManager.registerCommand("cmd_InsertColumnBefore", nsInsertTableColumnBeforeCommand);
gComposerCommandManager.registerCommand("cmd_InsertColumnAfter", nsInsertTableColumnAfterCommand);
gComposerCommandManager.registerCommand("cmd_InsertCellBefore", nsInsertTableCellBeforeCommand);
gComposerCommandManager.registerCommand("cmd_InsertCellAfter", nsInsertTableCellAfterCommand);
gComposerCommandManager.registerCommand("cmd_DeleteTable", nsDeleteTableCommand);
gComposerCommandManager.registerCommand("cmd_DeleteRow", nsDeleteTableRowCommand);
gComposerCommandManager.registerCommand("cmd_DeleteColumn", nsDeleteTableColumnCommand);
gComposerCommandManager.registerCommand("cmd_DeleteCell", nsDeleteTableCellCommand);
gComposerCommandManager.registerCommand("cmd_DeleteCellContents", nsDeleteTableCellContentsCommand);
gComposerCommandManager.registerCommand("cmd_NormalizeTable", nsNormalizeTableCommand);
}
//-----------------------------------------------------------------------------------
function GetComposerController()
{
var numControllers = window.content.controllers.getControllerCount();
// count down to find a controller that supplies a nsIControllerCommandManager interface
for (var i = numControllers; i >= 0 ; i --)
{
var commandManager = null;
try {
var controller = window.content.controllers.getControllerAt(i);
var interfaceRequestor = controller.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
if (!interfaceRequestor) continue;
commandManager = interfaceRequestor.getInterface(Components.interfaces.nsIControllerCommandManager);
} catch(ex) {
dump("failed to get command manager number "+i+"\n");
}
if (commandManager)
return commandManager;
}
dump("Failed to find a controller to register commands with\n");
return null;
}
//-----------------------------------------------------------------------------------
function goUpdateComposerMenuItems(commandset)
{
// dump("Updating commands for " + commandset.id + "\n");
for (var i = 0; i < commandset.childNodes.length; i++)
{
var commandID = commandset.childNodes[i].getAttribute("id");
if (commandID)
{
goUpdateCommand(commandID);
}
}
}
//-----------------------------------------------------------------------------------
function PrintObject(obj)
{
@ -598,11 +702,373 @@ var nsEditHTMLCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return false;
return (window.editorShell && window.editorShell.documentEditable);
},
doCommand: function(aCommand)
{
_EditorNotImplemented();
_EditorNotImplemented(); //TODO: IMPLEMENT ME!
}
};
//-----------------------------------------------------------------------------------
// TABLE EDITING COMMANDS
// Command Updating Strategy:
// Don't update
function EditorInitTableMenu()
{
// Change text on the "Join..." item depending if we
// are joining selected cells or just cell to right
// TODO: What to do about normal selection that crosses
// table border? Try to figure out all cells
// included in the selection?
var menuText;
if (editorShell.GetFirstSelectedCell())
menuText = GetString("JoinSelectedCells");
else
menuText = GetString("JoinCellToRight");
document.getElementById("menu_tableJoinCells").setAttribute("value",menuText);
// Set platform-specific hints for how to select cells
if (gIsWin) osKey = "XulKeyWin";
if (gIsMac) osKey = "XulKeyMac";
if (gIsUNIX) osKey = "XulKeyUnix";
var DragStr = GetString(osKey)+GetString("Drag");
var ClickStr = GetString(osKey)+GetString("Click");
var DelStr = GetString(gIsMac ? "Clear" : "Del");
document.getElementById("menu_DeleteCell").setAttribute("acceltext",ClickStr);
document.getElementById("menu_SelectRow").setAttribute("acceltext",DragStr);
document.getElementById("menu_SelectColumn").setAttribute("acceltext",DragStr);
document.getElementById("menu_SelectAllCells").setAttribute("acceltext",DragStr);
// And add "Del" or "Clear"
document.getElementById("menu_DeleteCellContents").setAttribute("acceltext",DelStr);
dump("*** commandset id=composerTableMenuItems:"+document.getElementById('composerTableMenuItems')+"\n");
goUpdateTableMenuItems(document.getElementById("composerTableMenuItems"));
}
function goUpdateTableMenuItems(commandset)
{
dump(" **** goUpdateTableMenuItems: commandset="+commandset+"\n");
// Insert table can be done any time (if editable document)
goUpdateCommand("cmd_InsertTable");
var enabled = false;
var enabledIfTable = false;
if (window.editorShell && window.editorShell.documentEditable)
{
var selectedCountObj = new Object();
var tagNameObj = new Object();
var element = editorShell.GetSelectedOrParentTableElement(tagNameObj, selectedCountObj);
if (element)
{
// We can delete or normalize table if inside a table
// or any table element is selected
enabledIfTable = true;
// All others require being inside a cell or selected cell
enable = (tagNameObj.value == "td");
}
}
goSetCommandEnabled("cmd_DeleteTable", enabledIfTable);
goSetCommandEnabled("cmd_NormalizeTable", enabledIfTable);
// Loop through command nodes to set all the others
for (var i = 0; i < commandset.childNodes.length; i++)
{
var commandID = commandset.childNodes[i].getAttribute("id");
if (commandID &&
commandID != "cmd_InsertTable" &&
commandID != "cmd_DeleteTable" &&
commandID != "cmd_NormalizeTable")
{
goSetCommandEnabled(commandID, enabled);
}
}
}
var nsSelectTableCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("table"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.SelectTable();
}
};
var nsSelectTableRowCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.SelectTableRow();
}
};
var nsSelectTableColumnCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
dump("nsSelectTableColumnCommand\n");
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.SelectTableColumn();
}
};
var nsSelectTableCellCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.SelectTableCell();
}
};
var nsSelectAllTableCellsCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.SelectAllTableCells();
}
};
var nsInsertTableCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable);
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.InsertTable();
}
};
var nsInsertTableRowAboveCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.InsertTableRow(false);
}
};
var nsInsertTableRowBelowCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.InsertTableRow(true);
}
};
var nsInsertTableColumnBeforeCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.InsertTableColumn(false);
}
};
var nsInsertTableColumnAfterCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.InsertTableColumn(true);
}
};
var nsInsertTableCellBeforeCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.InsertTableCell(false);
}
};
var nsInsertTableCellAfterCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.InsertTableCell(true);
}
};
var nsDeleteTableCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("table"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.DeleteTable();
}
};
var nsDeleteTableRowCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.DeleteTableRow(1);
}
};
var nsDeleteTableColumnCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.DeleteTableColumn(1);
}
};
var nsDeleteTableCellCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.DeleteTableCell(1);
}
};
var nsDeleteTableCellContentsCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.DeleteTableCellContents();
}
};
var nsNormalizeTableCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("table"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.NormalizeTable();
}
};
var nsJoinTableCellsCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.JoinTableCells();
}
};
var nsSplitTableCellCommand =
{
isCommandEnabled: function(aCommand, dummy)
{
return (window.editorShell && window.editorShell.documentEditable &&
null != window.editorShell.GetElementOrParentByTagName("td"));
},
doCommand: function(aCommand)
{
if (isCommandEnabled)
window.editorShell.SplitTableCell();
}
};
@ -621,91 +1087,3 @@ var nsPreferencesCommand =
};
//-----------------------------------------------------------------------------------
function GetComposerController()
{
var numControllers = window.content.controllers.getControllerCount();
// count down to find a controller that supplies a nsIControllerCommandManager interface
for (var i = numControllers; i >= 0 ; i --)
{
var commandManager = null;
try {
var controller = window.content.controllers.getControllerAt(i);
var interfaceRequestor = controller.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
if (!interfaceRequestor) continue;
commandManager = interfaceRequestor.getInterface(Components.interfaces.nsIControllerCommandManager);
} catch(ex) {
}
if (commandManager)
return commandManager;
}
dump("Failed to find a controller to register commands with\n");
return null;
}
//-----------------------------------------------------------------------------------
function SetupControllerCommands()
{
gComposerCommandManager = GetComposerController();
if (!gComposerCommandManager)
return;
dump("Registering commands\n");
gComposerCommandManager.registerCommand("cmd_newEditor", nsNewEditorCommand);
gComposerCommandManager.registerCommand("cmd_open", nsOpenCommand);
gComposerCommandManager.registerCommand("cmd_saveAsCharset", nsSaveAsCharsetCommand);
gComposerCommandManager.registerCommand("cmd_revert", nsRevertCommand);
gComposerCommandManager.registerCommand("cmd_openRemote", nsOpenRemoteCommand);
gComposerCommandManager.registerCommand("cmd_preview", nsPreviewCommand);
gComposerCommandManager.registerCommand("cmd_quit", nsQuitCommand);
gComposerCommandManager.registerCommand("cmd_find", nsFindCommand);
gComposerCommandManager.registerCommand("cmd_findNext", nsFindNextCommand);
gComposerCommandManager.registerCommand("cmd_spelling", nsSpellingCommand);
gComposerCommandManager.registerCommand("cmd_editHTML", nsEditHTMLCommand);
gComposerCommandManager.registerCommand("cmd_insertChars", nsInsertCharsCommand);
gComposerCommandManager.registerCommand("cmd_preferences", nsPreferencesCommand);
gComposerCommandManager.registerCommand("cmd_listProperties", nsListPropertiesCommand);
gComposerCommandManager.registerCommand("cmd_pageProperties", nsPagePropertiesCommand);
gComposerCommandManager.registerCommand("cmd_colorProperties", nsColorPropertiesCommand);
gComposerCommandManager.registerCommand("cmd_advancedProperties", nsAdvancedPropertiesCommand);
gComposerCommandManager.registerCommand("cmd_image", nsImageCommand);
gComposerCommandManager.registerCommand("cmd_hline", nsHLineCommand);
gComposerCommandManager.registerCommand("cmd_table", nsTableCommand); // insert or edit
gComposerCommandManager.registerCommand("cmd_editTable", nsEditTableCommand); // edit
gComposerCommandManager.registerCommand("cmd_link", nsLinkCommand);
gComposerCommandManager.registerCommand("cmd_anchor", nsAnchorCommand);
gComposerCommandManager.registerCommand("cmd_insertHTML", nsInsertHTMLCommand);
gComposerCommandManager.registerCommand("cmd_insertBreak", nsInsertBreakCommand);
gComposerCommandManager.registerCommand("cmd_insertBreakAll", nsInsertBreakAllCommand);
}
//-----------------------------------------------------------------------------------
function goUpdateComposerMenuItems(commandset)
{
// dump("Updating commands for " + commandset.id + "\n");
for (var i = 0; i < commandset.childNodes.length; i++)
{
var commandID = commandset.childNodes[i].getAttribute("id");
if (commandID)
{
goUpdateCommand(commandID);
}
}
}

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

@ -27,6 +27,34 @@
<overlay id="editorCommandsOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- commands updated when the table menu gets created -->
<commandset id="composerTableMenuItems"
commandupdater="true"
events="create"
oncommandupdate="goUpdateTableMenuItems(this)"
>
<command id="cmd_SelectTable" oncommand="goDoCommand('cmd_SelectTable')"/>
<command id="cmd_SelectRow" oncommand="goDoCommand('cmd_SelectRow')"/>
<command id="cmd_SelectColumn" oncommand="goDoCommand('cmd_SelectColumn')"/>
<command id="cmd_SelectCell" oncommand="goDoCommand('cmd_SelectCell')"/>
<command id="cmd_SelectAllCells" oncommand="goDoCommand('cmd_SelectAllCells')"/>
<command id="cmd_InsertTable" oncommand="goDoCommand('cmd_InsertTable')"/>
<command id="cmd_InsertRowAbove" oncommand="goDoCommand('cmd_InsertRowAbove')"/>
<command id="cmd_InsertRowBelow" oncommand="goDoCommand('cmd_InsertRowBelow')"/>
<command id="cmd_InsertColumnBefore" oncommand="goDoCommand('cmd_InsertColumnBefore')"/>
<command id="cmd_InsertColumnAfter" oncommand="goDoCommand('cmd_InsertColumnAfter')"/>
<command id="cmd_InsertCellBefore" oncommand="goDoCommand('cmd_InsertCellBefore')"/>
<command id="cmd_InsertCellAfter" oncommand="goDoCommand('cmd_InsertCellAfter')"/>
<command id="cmd_DeleteTable" oncommand="goDoCommand('cmd_DeleteTable')"/>
<command id="cmd_DeleteRow" oncommand="goDoCommand('cmd_DeleteRow')"/>
<command id="cmd_DeleteColumn" oncommand="goDoCommand('cmd_DeleteColumn')"/>
<command id="cmd_DeleteCell" oncommand="goDoCommand('cmd_DeleteCell')"/>
<command id="cmd_DeleteCellContents" oncommand="goDoCommand('cmd_DeleteCellContents')"/>
<command id="cmd_NormalizeTable" oncommand="goDoCommand('cmd_NormalizeTable')"/>
<command id="cmd_tableJoinCells" oncommand="goDoCommand('cmd_tableJoinCells')"/>
<command id="cmd_tableSplitCell" oncommand="goDoCommand('cmd_tableSplitCell')"/>
</commandset>
<menuitem id="removeLinksMenuitem" value="&removeLinksCmd.label;"
accesskey="&formatremovelinks.accesskey;"
oncommand="EditorRemoveLinks()"/>
@ -44,41 +72,43 @@
<menu id="tableSelectMenu" value="&tableSelectMenu.label;"
accesskey="&tableselectmenu.accesskey;">
<menupopup>
<menuitem id="menu_SelectTable" value="&tableTable.label;" accesskey="&tabletable.accesskey;" oncommand="EditorSelectTable()"/>
<menuitem id="menu_SelectRow" value="&tableRow.label;" accesskey="&tablerow.accesskey;" oncommand="EditorSelectTableRow()"/>
<menuitem id="menu_SelectColumn" value="&tableColumn.label;" accesskey="&tablecolumn.accesskey;" oncommand="EditorSelectTableColumn()"/>
<menuitem id="menu_SelectCell" value="&tableCell.label;" accesskey="&tablecell.accesskey;" oncommand="EditorSelectTableCell()"/>
<menuitem id="menu_SelectAllCells" value="&tableAllCells.label;" accesskey="&tableallcells.accesskey;" oncommand="EditorSelectAllTableCells()"/>
<menuitem id="menu_SelectTable" value="&tableTable.label;" accesskey="&tabletable.accesskey;" observes="cmd_SelectTable" />
<menuitem id="menu_SelectRow" value="&tableRow.label;" accesskey="&tablerow.accesskey;" observes="cmd_SelectRow" />
<menuitem id="menu_SelectColumn" value="&tableColumn.label;" accesskey="&tablecolumn.accesskey;" observes="cmd_SelectColumn" />
<menuitem id="menu_SelectCell" value="&tableCell.label;" accesskey="&tablecell.accesskey;" observes="cmd_SelectCell" />
<menuitem id="menu_SelectAllCells" value="&tableAllCells.label;" accesskey="&tableallcells.accesskey;" observes="cmd_SelectAllCells" />
</menupopup>
</menu>
<menu id="tableInsertMenu" value="&tableInsertMenu.label;" accesskey="&tableinsertmenu.accesskey;">
<menupopup>
<menuitem value="&insertTableCmd.label;" accesskey="&tabletable.accesskey;" oncommand="EditorInsertTable()"/>
<menuitem value="&insertTableCmd.label;" accesskey="&tabletable.accesskey;" observes="cmd_InsertTable"/>
<menuseparator />
<menuitem value="&tableRowAbove.label;" accesskey="&tablerow.accesskey;" oncommand="EditorInsertTableRow(false)"/>
<menuitem value="&tableRowBelow.label;" accesskey="&tablerowbelow.accesskey;" oncommand="EditorInsertTableRow(true)"/>
<menuitem value="&tableRowAbove.label;" accesskey="&tablerow.accesskey;" observes="cmd_InsertRowAbove"/>
<menuitem value="&tableRowBelow.label;" accesskey="&tablerowbelow.accesskey;" observes="cmd_InsertRowBelow"/>
<menuseparator />
<menuitem value="&tableColumnBefore.label;" accesskey="&tablecolumn.accesskey;" oncommand="EditorInsertTableColumn(false)"/>
<menuitem value="&tableColumnAfter.label;" accesskey="&tablecolumnafter.accesskey;" oncommand="EditorInsertTableColumn(true)"/>
<menuitem value="&tableColumnBefore.label;" accesskey="&tablecolumn.accesskey;" observes="cmd_InsertColumnBefore"/>
<menuitem value="&tableColumnAfter.label;" accesskey="&tablecolumnafter.accesskey;" observes="cmd_InsertColumnAfter"/>
<menuseparator />
<menuitem value="&tableCellBefore.label;" accesskey="&tablecell.accesskey;" oncommand="EditorInsertTableCell(false)"/>
<menuitem value="&tableCellAfter.label;" accesskey="&tablecellafter.accesskey;" oncommand="EditorInsertTableCell(true)"/>
<menuitem value="&tableCellBefore.label;" accesskey="&tablecell.accesskey;" observes="cmd_InsertCellBefore"/>
<menuitem value="&tableCellAfter.label;" accesskey="&tablecellafter.accesskey;" observes="cmd_InsertCellAfter"/>
</menupopup>
</menu>
<menu id="tableDeleteMenu" value="&tableDeleteMenu.label;" accesskey="&tabledeletemenu.accesskey;">
<menupopup>
<menuitem id="menu_DeleteTable" value="&tableTable.label;" accesskey="&tabletable.accesskey;" oncommand="EditorDeleteTable()"/>
<menuitem id="menu_DeleteRow" value="&tableRow.label;" accesskey="&tablerow.accesskey;" oncommand="EditorDeleteTableRow(1)"/>
<menuitem id="menu_DeleteColumn" value="&tableColumn.label;" accesskey="&tablecolumn.accesskey;" oncommand="EditorDeleteTableColumn(1)"/>
<menuitem id="menu_DeleteCell" value="&tableCell.label;" accesskey="&tablecell.accesskey;" oncommand="EditorDeleteTableCell(1)"/>
<menuitem id="menu_DeleteCellContents" value="&tableCellContents.label;" accesskey="&tablecellcontents.accesskey;" oncommand="EditorDeleteTableCellContents()"/>
<menuitem value="&tableTable.label;" accesskey="&tabletable.accesskey;" observes="cmd_DeleteTable"/>
<menuitem value="&tableRow.label;" accesskey="&tablerow.accesskey;" observes="cmd_DeleteRow"/>
<menuitem value="&tableColumn.label;" accesskey="&tablecolumn.accesskey;" observes="cmd_DeleteColumn"/>
<menuitem id="menu_DeleteCell" value="&tableCell.label;" accesskey="&tablecell.accesskey;" observes="cmd_DeleteCell"/>
<menuitem id="menu_DeleteCellContents" value="&tableCellContents.label;" accesskey="&tablecellcontents.accesskey;" observes="cmd_DeleteCellContents"/>
</menupopup>
</menu>
<menuseparator />
<menuitem id="tableNormalizeTable" accesskey="&tablefixup.accesskey;" oncommand="EditorNormalizeTable()" value="&tableFixup.label;" />
<menuitem id="tableJoinCells" accesskey="&tablejoincells.accesskey;" oncommand="EditorJoinTableCells()"/><!-- menu text set in InitTableMenu -->
<menuitem id="tableSlitCell" accesskey="&tablesplitcell.accesskey;" oncommand="EditorSplitTableCell()" value="&tableSplitCell.label;" />
<menuitem id="tableProperties" accesskey="&properties.accesskey;" observes="cmd_editTable" value="&tableProperties.label;" />
<menuitem id="menu_NormalizeTable" value="&tableFix.label;" accesskey="&tablefix.accesskey;" observes="cmd_NormalizeTable"/>
<!-- menu value is set in InitTableMenu -->
<menuitem id="menu_tableJoinCells" accesskey="&tablejoincells.accesskey;" observes="cmd_tableJoinCells"/>
<menuitem id="menu_tableSlitCell" value="&tableSplitCell.label;" accesskey="&tablesplitcell.accesskey;" observes="cmd_tableSplitCell"/>
<!-- this is shared with Format Menu -->
<menuitem id="menu_tableProperties" value="&tableProperties.label;" accesskey="&properties.accesskey;" observes="cmd_editTable"/>
</menupopup>
</menu>

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

@ -61,7 +61,7 @@
-->
<menuitem id="tableMenu" value="&tableMenu.label;"/>
<menuitem id="tableProperties" value="&tableProperties.label;"/>
<menuitem id="menu_tableProperties" value="&tableProperties.label;"/>
<menuseparator id="tableMenu-separator"/>
<menuitem id="objectProperties" value="&properties.label;"/>

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

@ -44,7 +44,7 @@ var docWasModified = false; // Check if clean document, if clean then unload wh
var contentWindow = 0;
var sourceContentWindow = 0;
var ContentWindowDeck;
var EditorToolbox;
var FormatToolbar;
// Bummer! Can't get at enums from nsIDocumentEncoder.h
var gOutputSelectionOnly = 1;
var gOutputFormatted = 2;
@ -63,6 +63,7 @@ var gPreviewModeButton;
var gIsWindows;
var gIsMac;
var gIsUNIX;
var gIsHTMLEditor = false;
var gPrefs;
// These must be kept in synch with the XUL <options> lists
@ -99,6 +100,9 @@ function TextEditorOnLoad()
function PageIsEmptyAndUntouched()
{
dump("Editorshell="+editorShell+"\n");
dump("DocumentIsEmpty="+editorShell.documentIsEmpty+"\n");
dump("docWasModified="+docWasModified+"\n");
return (editorShell != null) && (editorShell.documentIsEmpty == true) && (docWasModified == false);
}
@ -136,26 +140,32 @@ function EditorStartup(editorType, editorElement)
{
contentWindow = window.content;
sourceContentWindow = document.getElementById("content-source");
gIsHTMLEditor = (editorType == "html");
if (gIsHTMLEditor)
{
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
dump("Edit Mode: "+gNormalModeButton.getAttribute('type')+"\n");
ToggleEditModeType(gNormalModeButton.getAttribute("type"));
// XUL elements we use when switching from normal editor to edit source
ContentWindowDeck = document.getElementById("ContentWindowDeck");
FormatToolbar = document.getElementById("FormatToolbar");
}
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");
// 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
ContentWindowDeck = document.getElementById("ContentWindowDeck");
EditorToolbox = document.getElementById("EditorToolbox");
// store the editor shell in the window, so that child windows can get to it.
editorShell = editorElement.editorShell;
@ -177,8 +187,6 @@ dump("IsWin="+gIsWin+", IsUNIX="+gIsUNIX+", IsMac="+gIsMac+"\n");
// set up our global prefs object
GetPrefsService();
// editorShell.editorDocument.onDblClick = "EditorDblClick()";
// 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");
@ -726,6 +734,8 @@ function EditorAlign(commandID, alignType)
}
function SetEditMode(mode)
{
if (gIsHTMLEditor)
{
var bodyNode = editorShell.editorDocument.getElementsByTagName("body").item(0);
if (!bodyNode)
@ -748,8 +758,9 @@ function SetEditMode(mode)
if( childCount)
{
// KLUDGE until we have an output flag that strips out <body> and </body> for us
var sourceContent = editorShell.GetContentsAs("text/html", gOutputBodyOnly);
sourceContentWindow.value = sourceContent.replace(/<body>/,"").replace(/<\/body>/,"");
//var sourceContent = editorShell.GetContentsAs("text/html", gOutputBodyOnly);
//sourceContentWindow.value = sourceContent.replace(/<body>/,"").replace(/<\/body>/,"");
sourceContentWindow.value = editorShell.GetContentsAs("text/html", gOutputBodyOnly);
sourceContentWindow.focus();
setTimeout("sourceContentWindow.focus()", 10);
return;
@ -774,6 +785,7 @@ function SetEditMode(mode)
setTimeout("contentWindow.focus()", 10);
}
}
}
function CancelSourceEditing()
{
@ -783,6 +795,8 @@ function CancelSourceEditing()
}
function SetDisplayMode(mode)
{
if (gIsHTMLEditor)
{
// Already in requested mode:
// return false to indicate we didn't switch
@ -810,9 +824,6 @@ function SetDisplayMode(mode)
// Switch to the sourceWindow (second in the deck)
ContentWindowDeck.setAttribute("index","1");
// Hide normal chrome
EditorToolbox.setAttribute("collapsed", "true");
// TODO: WE MUST DISABLE ALL KEYBOARD COMMANDS!
// THIS DOESN'T WORK!
@ -823,17 +834,17 @@ function SetDisplayMode(mode)
// Switch to the normal editor (first in the deck)
ContentWindowDeck.setAttribute("index","0");
// Show normal chrome
EditorToolbox.removeAttribute("collapsed");
// TODO: WE MUST ENABLE ALL KEYBOARD COMMANDS!
contentWindow.focus();
}
return true;
}
}
function ToggleEditModeType()
{
if (gIsHTMLEditor)
{
if (EditModeType == "text")
{
@ -860,6 +871,7 @@ function ToggleEditModeType()
gSourceModeButton.setAttribute("type",EditModeType);
gPreviewModeButton.setAttribute("type",EditModeType);
}
}
function EditorToggleParagraphMarks()
{
@ -989,38 +1001,6 @@ function EditorInitFormatMenu()
}
}
function EditorInitTableMenu()
{
// Change text on the "Join..." item depending if we
// are joining selected cells or just cell to right
// TODO: What to do about normal selection that crosses
// table border? Try to figure out all cells
// included in the selection?
var menuText;
if (editorShell.GetFirstSelectedCell())
menuText = GetString("JoinSelectedCells");
else
menuText = GetString("JoinCellToRight");
document.getElementById("tableJoinCells").setAttribute("value",menuText);
// Set platform-specific hints for how to select cells
if (gIsWin) osKey = "XulKeyWin";
if (gIsMac) osKey = "XulKeyMac";
if (gIsUNIX) osKey = "XulKeyUnix";
var DragStr = GetString(osKey)+GetString("Drag");
var ClickStr = GetString(osKey)+GetString("Click");
var DelStr = GetString(gIsMac ? "Clear" : "Del");
document.getElementById("menu_DeleteCell").setAttribute("acceltext",ClickStr);
document.getElementById("menu_SelectRow").setAttribute("acceltext",DragStr);
document.getElementById("menu_SelectColumn").setAttribute("acceltext",DragStr);
document.getElementById("menu_SelectAllCells").setAttribute("acceltext",DragStr);
// And add "Del" or "Clear"
document.getElementById("menu_DeleteCellContents").setAttribute("acceltext",DelStr);
}
function EditorInitToolbars()
{
// Nothing to do now, but we might want some state updating here
@ -1042,12 +1022,15 @@ function EditorSetDefaultPrefs()
}
// doctype
var newdoctype = domdoc.implementation.createDocumentType("html", "-//W3C//DTD HTML 4.01 Transitional//EN",
"");
var newdoctype = domdoc.implementation.createDocumentType("html", "-//W3C//DTD HTML 4.01 Transitional//EN","");
if (!domdoc.doctype)
{
domdoc.insertBefore(newdoctype, domdoc.firstChild);
}
else
{
domdoc.replaceChild(newdoctype, domdoc.doctype);
}
// search for head; we'll need this for meta tag additions
var headelement = 0;

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

@ -68,6 +68,10 @@
<commandset id="composerEditMenuItems"/>
<commandset id="composerSaveMenuItems"/>
<commandset id="composerStyleMenuItems"/>
<!-- Note that some commandsets (e.g.,composerTableMenuItems) are not
included because they update in menu create methods only
But if any command is placed on a toolbar, they should be included here
-->
</commands>
<!-- Use this when we abandon the default startup page -->
@ -161,7 +165,7 @@
<observes element="Editor:Throbber" attribute="busy"/>
</button>
</toolbar>
<toolbar id="FormatToolbar" class="chromeclass-toolbar" persist="collapsed">
<toolbar id="FormatToolbar" persist="collapsed">
<!-- We need this else menulists get stretched -->
<box autostretch="never" flex="1">
<!-- from editorOverlay -->
@ -213,7 +217,7 @@
<button id="SourceModeButton"/>
<button id="PreviewModeButton"/>
<spring flex="1"/>
<button id="ToggleEditModeType"/>
<image id="ToggleEditModeType"/>
</toolbar>
<!-- Some of this is from globarOverlay.xul -->

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

@ -798,7 +798,8 @@
<button id="TagModeButton" class="EditModeButton plain" type="text" selected="0" value="&showAllTags.label;" onclick="SetEditMode(2)"/>
<button id="SourceModeButton" class="EditModeButton plain" type="text" selected="0" value="&sourceMode.label;" onclick="SetEditMode(3)"/>
<button id="PreviewModeButton" class="EditModeButton plain" type="text" selected="0" value="&previewMode.label;" onclick="SetEditMode(0)"/>
<button id="ToggleEditModeType" class="plain" onclick="ToggleEditModeType()"/>
<!-- button id="ToggleEditModeType" class="plain" onclick="ToggleEditModeType()"/ -->
<image id="ToggleEditModeType" onclick="ToggleEditModeType()"/>
<!-- InsertPopupButton is used by messengercompose.xul -->
<button class="plain format popup" id="InsertPopupButton"/>

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

@ -52,7 +52,8 @@ Revert=Revert
#Don't translate %title%
AbandonChanges=Abandon unsaved changes to %title% and reload page?
DocumentTitle=Document Title
NeedDocTitle=Enter a title for the current page. The title identifies the page in the window title and bookmarks.
NeedDocTitle=Enter a title for the current page.
DocTitleHelp=The title identifies the page in the window title and bookmarks.
AttributesFor=Current attributes for:
MissingImageError=Please enter or choose an image of type gif, jpg, or png.
EmptyHREFError=You must enter or choose a location (URL) to create a new link.

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

@ -500,8 +500,8 @@ Menu item text for "[Page|Table|Cell] Background color" is filled from
<!ENTITY tableDeleteMenu.label "Delete">
<!ENTITY tabledeletemenu.accesskey "d">
<!ENTITY tableFixup.label "Fix Table Layout">
<!ENTITY tablefixup.accesskey "f">
<!ENTITY tableFix.label "Fix Table Layout">
<!ENTITY tablefix.accesskey "f">
<!-- text for "Join Cells" is in editor.properties
("JoinSelectedCells" and "JoinCellToRight")
the access key must exist in both of those strings

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

@ -753,3 +753,122 @@ dump(fs.URLString+" = URL string\n");
}
return null;
}
function GetMetaElement(name)
{
if (name)
{
name = name.toLowerCase();
if (name != "")
{
var metaNodes = editorShell.editorDocument.getElementsByTagName("meta");
if (metaNodes && metaNodes.length > 0)
{
for (var i = 0; i < metaNodes.length; i++)
{
var metaNode = metaNodes.item(i);
if (metaNode && metaNode.getAttribute("name") == name)
return metaNode;
}
}
}
}
return null;
}
function CreateMetaElement(name)
{
metaElement = editorShell.CreateElementWithDefaults("meta");
if (metaElement)
metaElement.setAttribute("name", name);
else
dump("Failed to create metaElement!\n");
return metaElement;
}
function GetHTTPEquivMetaElement(name)
{
if (name)
{
name = name.toLowerCase();
if (name != "")
{
var metaNodes = editorShell.editorDocument.getElementsByTagName("meta");
if (metaNodes && metaNodes.length > 0)
{
for (var i = 0; i < metaNodes.length; i++)
{
var metaNode = metaNodes.item(i);
if (metaNode && metaNode.getAttribute("http-equiv") == name)
return metaNode;
}
}
}
}
return null;
}
function CreateHTTPEquivMetaElement(name)
{
metaElement = editorShell.CreateElementWithDefaults("meta");
if (metaElement)
metaElement.setAttribute("http-equiv", name);
else
dump("Failed to create httpequivMetaElement!\n");
return metaElement;
}
function CreateHTTPEquivElement(name)
{
metaElement = editorShell.CreateElementWithDefaults("meta");
if (metaElement)
metaElement.setAttribute("http-equiv", name);
else
dump("Failed to create metaElement for http-equiv!\n");
return metaElement;
}
// Change "content" attribute on a META element,
// or delete entire element it if content is empty
// This uses undoable editor transactions
function SetMetaElementContent(metaElement, content, insertNew)
{
if (metaElement)
{
if(!content || content == "")
{
if (!insertNew)
editorShell.DeleteElement(metaElement);
}
else
{
if (insertNew)
{
// Don't need undo for set attribute, just for InsertElement
metaElement.setAttribute("content", content);
AppendHeadElement(metaElement);
}
else
editorShell.SetAttribute(metaElement, "content", content);
}
}
}
function GetHeadElement()
{
var headList = editorShell.editorDocument.getElementsByTagName("head");
if (headList)
return headList.item(0);
return null;
}
function AppendHeadElement(element)
{
var head = GetHeadElement();
if (head)
head.appendChild(element);
}

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

@ -105,93 +105,6 @@ function InitDialog()
dialog.HeadSrcInput.value = editorShell.GetHeadContentsAsHTML();
}
function GetMetaElement(name)
{
if (name)
{
name = name.toLowerCase();
if (name != "")
{
var metaNodes = editorShell.editorDocument.getElementsByTagName("meta");
if (metaNodes && metaNodes.length > 0)
{
for (var i = 0; i < metaNodes.length; i++)
{
var metaNode = metaNodes.item(i);
if (metaNode && metaNode.getAttribute("name") == name)
return metaNode;
}
}
}
}
return null;
}
function CreateMetaElement(name)
{
metaElement = editorShell.CreateElementWithDefaults("meta");
if (metaElement)
metaElement.setAttribute("name", name);
else
dump("Failed to create metaElement!\n");
return metaElement;
}
function CreateHTTPEquivElement(name)
{
metaElement = editorShell.CreateElementWithDefaults("meta");
if (metaElement)
metaElement.setAttribute("http-equiv", name);
else
dump("Failed to create metaElement for http-equiv!\n");
return metaElement;
}
// Change "content" attribute on a META element,
// or delete entire element it if content is empty
// This uses undoable editor transactions
function SetMetaElementContent(metaElement, content, insertNew)
{
if (metaElement)
{
if(!content || content == "")
{
if (!insertNew)
editorShell.DeleteElement(metaElement);
}
else
{
if (insertNew)
{
// Don't need undo for set attribute, just for InsertElement
metaElement.setAttribute("content", content);
AppendHeadElement(metaElement);
}
else
editorShell.SetAttribute(metaElement, "content", content);
}
}
}
function GetHeadElement()
{
var headList = editorShell.editorDocument.getElementsByTagName("head");
if (headList)
return headList.item(0);
return null;
}
function AppendHeadElement(element)
{
var head = GetHeadElement();
if (head)
head.appendChild(element);
}
function TextfieldChanged(ID)
{
switch(ID)
@ -220,23 +133,18 @@ function onOK()
{
if (ValidateData())
{
editorShell.BeginBatchChanges();
// Save only if advanced "head editing" region is open?
if (SeeMore)
{
// Delete existing children of HEAD
// Note that we must use editorShell method so this is undoable
var children = dialog.HeadSrcInput.childNodes;
if (children)
{
for(i=0; i < children.length; i++)
editorShell.DeleteElement(children.item(i));
}
// Note that we DO NOT use editorShell method
// because this is not an undoable task
while(headNode.firstChild)
headNode.removeChild(headNode.firstChild);
var headSrcString = dialog.HeadSrcInput.value;
if (headSrcString.length > 0)
editorShell.ReplaceHeadContentsWithHTML(headSrcString);
// This method does not use the transaction system:
if (dialog.HeadSrcInput.value.length > 0)
editorShell.ReplaceHeadContentsWithHTML(dialog.HeadSrcInput.value);
}
//Problem: How do we reconcile changes in same elements in
@ -256,7 +164,6 @@ function onOK()
if (descWasEdited)
SetMetaElementContent(descriptionElement, description, insertNewDescription);
editorShell.EndBatchChanges();
return true; // do close the window
}
return false;

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

@ -45,7 +45,6 @@ function Startup()
// Create dialog object to store controls for easy access
dialog = new Object;
// GET EACH CONTROL -- E.G.:
dialog.TitleInput = document.getElementById("TitleInput");
dialog.charsetTree = document.getElementById('CharsetTree');
//dialog.charsetRoot = document.getElementById('CharsetRoot');
@ -61,10 +60,16 @@ function Startup()
InitDialog();
// Use the same text as the messagebox for getting title by regular "Save"
document.getElementById("EnterTitleLabel").setAttribute("value",GetString("NeedDocTitle"));
// This is an <HTML> element so it wraps -- append a child textnode
var helpTextParent = document.getElementById("TitleHelp");
var helpText = document.createTextNode(GetString("DocTitleHelp"));
if (helpTextParent)
helpTextParent.appendChild(helpText);
// SET FOCUS TO FIRST CONTROL
//dialog.editBox.focus();
//dialog.TitleInput.focus();
dialog.charsetTree.focus();
dialog.TitleInput.focus();
LoadAvailableCharSets();
initDone = true;
}
@ -93,6 +98,7 @@ function onOK()
}
return false;
}
function LoadAvailableCharSets()
{
try {
@ -182,6 +188,7 @@ function LoadAvailableCharSets()
}
} // if
}
function SelectCharset()
{
if(initDone) {
@ -196,129 +203,14 @@ function SelectCharset()
}
}
}
function ValidateData()
{
title=dialog.TitleInput.value.trimString();
return true;
}
function TitleChanged()
{
titleWasEdited = true;
}
// copy from EdPageProps.js
function GetMetaElement(name)
{
if (name)
{
name = name.toLowerCase();
if (name != "")
{
var metaNodes = editorShell.editorDocument.getElementsByTagName("meta");
if (metaNodes && metaNodes.length > 0)
{
for (var i = 0; i < metaNodes.length; i++)
{
var metaNode = metaNodes.item(i);
if (metaNode && metaNode.getAttribute("name") == name)
return metaNode;
}
}
}
}
return null;
}
function GetHTTPEquivMetaElement(name)
{
if (name)
{
name = name.toLowerCase();
if (name != "")
{
var metaNodes = editorShell.editorDocument.getElementsByTagName("meta");
if (metaNodes && metaNodes.length > 0)
{
for (var i = 0; i < metaNodes.length; i++)
{
var metaNode = metaNodes.item(i);
if (metaNode && metaNode.getAttribute("http-equiv") == name)
return metaNode;
}
}
}
}
return null;
}
function CreateMetaElement(name)
{
metaElement = editorShell.CreateElementWithDefaults("meta");
if (metaElement)
metaElement.setAttribute("name", name);
else
dump("Failed to create metaElement!\n");
return metaElement;
}
function CreateHTTPEquivMetaElement(name)
{
metaElement = editorShell.CreateElementWithDefaults("meta");
if (metaElement)
metaElement.setAttribute("http-equiv", name);
else
dump("Failed to create httpequivMetaElement!\n");
return metaElement;
}
function CreateHTTPEquivElement(name)
{
metaElement = editorShell.CreateElementWithDefaults("meta");
if (metaElement)
metaElement.setAttribute("http-equiv", name);
else
dump("Failed to create metaElement for http-equiv!\n");
return metaElement;
}
// Change "content" attribute on a META element,
// or delete entire element it if content is empty
// This uses undoable editor transactions
function SetMetaElementContent(metaElement, content, insertNew)
{
if (metaElement)
{
if(!content || content == "")
{
if (!insertNew)
editorShell.DeleteElement(metaElement);
}
else
{
if (insertNew)
{
// Don't need undo for set attribute, just for InsertElement
metaElement.setAttribute("content", content);
AppendHeadElement(metaElement);
}
else
editorShell.SetAttribute(metaElement, "content", content);
}
}
}
function GetHeadElement()
{
var headList = editorShell.editorDocument.getElementsByTagName("head");
if (headList)
return headList.item(0);
return null;
}
function AppendHeadElement(element)
{
var head = GetHeadElement();
if (head)
head.appendChild(element);
}

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

@ -38,8 +38,7 @@
orient="vertical">
<!-- Methods common to all editor dialogs -->
<script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js">
</script>
<script language="JavaScript" src="chrome://editor/content/EdDialogCommon.js"/>
<script language="JavaScript" src="chrome://editor/content/EditorSaveAsCharset.js"/>
<script language="JavaScript" src="chrome://global/content/dialogOverlay.js" />
@ -48,13 +47,15 @@
<box orient="vertical">
<titledbox orient="vertical"><title><text align="left" value="&documentTitleTitle.label;"/></title>
<text class="label" value="&documentTitleDesc.label;"/>
<!-- Text labels filled in from editor.properties -->
<text id="EnterTitleLabel" class="label"/>
<textfield id="TitleInput" flex="1" onkeyup="TitleChanged();"/>
<html id="TitleHelp" class="label wrap" style="width:1em" flex="1"/>
</titledbox>
<titledbox orient="vertical"><title><text class="label" value="&documentCharsetTitle.label;"/></title>
<text class="label" value="&documentCharsetDesc.label;"/>
<box>
<box flex="1">
<tree class="list" id="CharsetTree" rows="10" flex="1" onselect="SelectCharset();"/>
</box>
</titledbox>

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

@ -25,9 +25,8 @@
<!-- This button is for the progressive disclosure of additional editing functionality -->
<!-- These strings are for use specifically in the editor's link dialog. -->
<!ENTITY windowTitle.label "Save As Charset...">
<!ENTITY documentTitleTitle.label "Document Title">
<!ENTITY documentTitleDesc.label "Input document title here:">
<!ENTITY windowTitle.label "Save As Charset">
<!ENTITY documentTitleTitle.label "Page Title">
<!ENTITY documentCharsetTitle.label "Document Charset">
<!ENTITY documentCharsetDesc.label "Select the charset you want to save as:">