Fixed nsbeta3 UI bugs for Composer: List proerties (45407), Context menus (43307), many fixes for strict JS warnings. r=sfraser, hyatt

This commit is contained in:
cmanske%netscape.com 2000-09-05 23:21:22 +00:00
Родитель 65ebab34f8
Коммит 145e0993e9
17 изменённых файлов: 660 добавлений и 610 удалений

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

@ -280,6 +280,7 @@ var nsSaveCommand =
var doSaveAs = window.editorShell.editorDocument.location == "about:blank";
return window.editorShell.saveDocument(doSaveAs, false);
}
return false;
}
}
@ -297,6 +298,7 @@ var nsSaveAsCommand =
FinishHTMLSource();
return window.editorShell.saveDocument(true, false);
}
return false;
}
}
@ -585,8 +587,6 @@ var nsSpellingCommand =
}
catch(ex) {
dump("*** Exception error: SpellChecker Dialog Closing\n");
window._content.focus();
return;
}
}
}
@ -635,11 +635,6 @@ var nsHLineCommand =
// We change the default attributes to those saved in the user prefs
if (gPrefs) {
var percent;
var height;
var shading;
var ud = "undefined";
try {
var align = gPrefs.GetIntPref("editor.hrule.align");
if (align == 0 ) {
@ -799,20 +794,15 @@ var nsObjectPropertiesCommand =
var isEnabled = false;
if (window.editorShell && window.editorShell.documentEditable)
{
try {
// Launch Object properties for appropriate selected element
isEnabled = (GetSelectedElementOrParentCellOrLink() != null ||
window.editorShell.GetSelectedElement("href") != null);
} catch(e)
{
}
isEnabled = (GetObjectForProperties() != null ||
window.editorShell.GetSelectedElement("href") != null);
}
return isEnabled;
},
doCommand: function(aCommand)
{
// Launch Object properties for appropriate selected element
var element = GetSelectedElementOrParentCellOrLink();
var element = GetObjectForProperties();
if (element)
{
var name = element.nodeName.toLowerCase();
@ -828,8 +818,14 @@ var nsObjectPropertiesCommand =
EditorInsertOrEditTable(false);
break;
case 'td':
case 'th':
EditorTableCellProperties();
break;
case 'ol':
case 'ul':
case 'dl':
goDoCommand("cmd_listProperties");
break;
case 'a':
if (element.name)
{
@ -886,7 +882,9 @@ var nsColorPropertiesCommand =
},
doCommand: function(aCommand)
{
window.openDialog("chrome://editor/content/EdColorProps.xul","_blank", "chrome,close,titlebar,modal", "");
window.openDialog("chrome://editor/content/EdColorProps.xul","_blank", "chrome,close,titlebar,modal", "",
GetDefaultBrowserColors());
window._content.focus();
}
};
@ -996,7 +994,6 @@ var nsSelectTableCommand =
},
doCommand: function(aCommand)
{
//dump("nsSelectTableCommand\n");
window.editorShell.SelectTable();
window._content.focus();
}
@ -1010,7 +1007,6 @@ var nsSelectTableRowCommand =
},
doCommand: function(aCommand)
{
//dump("nsSelectTableRowCommand\n");
window.editorShell.SelectTableRow();
window._content.focus();
}
@ -1024,7 +1020,6 @@ var nsSelectTableColumnCommand =
},
doCommand: function(aCommand)
{
//dump("nsSelectTableColumnCommand\n");
window.editorShell.SelectTableColumn();
window._content.focus();
}
@ -1038,7 +1033,6 @@ var nsSelectTableCellCommand =
},
doCommand: function(aCommand)
{
//dump("nsSelectTableCellCommand\n");
window.editorShell.SelectTableCell();
window._content.focus();
}
@ -1169,7 +1163,6 @@ var nsDeleteTableRowCommand =
},
doCommand: function(aCommand)
{
//dump("nsDeleteTableRowCommand: doCommand\n");
window.editorShell.DeleteTableRow(1);
window._content.focus();
}
@ -1328,6 +1321,7 @@ var nsPreferencesCommand =
doCommand: function(aCommand)
{
goPreferences('navigator.xul', 'chrome://editor/content/pref-composer.xul','editor');
window._content.focus();
}
};

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

@ -27,7 +27,7 @@
<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" oncommandupdate="goUpdateTableMenuItems(this)">
<command id="cmd_SelectTable" oncommand="goDoCommand('cmd_SelectTable')"/>
<command id="cmd_SelectRow" oncommand="goDoCommand('cmd_SelectRow')"/>
@ -52,65 +52,31 @@
<command id="cmd_TableOrCellColor" oncommand="goDoCommand('cmd_TableOrCellColor')"/>
<command id="cmd_editTable" oncommand="goDoCommand('cmd_editTable')"/>
</commandset>
<menuitem id="removeLinksMenuitem" value="&removeLinksCmd.label;"
accesskey="&formatremovelinks.accesskey;"
observes="cmd_RemoveLinks"/>
<menuitem id="menu_preview" value="&previewCmd.label;"
accesskey="&filepreview.accesskey;"
observes="cmd_preview"/>
<menuitem id="objectProperties" value="&properties.label;"
accesskey="&properties.accesskey;"
observes="cmd_objectProperties"/>
<menu id="tableMenu" value="&tableMenu.label;" accesskey="&tablemenu.accesskey;">
<menupopup oncreate="EditorInitTableMenu()">
<menu id="tableSelectMenu" value="&tableSelectMenu.label;"
accesskey="&tableselectmenu.accesskey;">
<menupopup>
<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;" observes="cmd_InsertTable"/>
<menuseparator />
<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;" observes="cmd_InsertColumnBefore"/>
<menuitem value="&tableColumnAfter.label;" accesskey="&tablecolumnafter.accesskey;" observes="cmd_InsertColumnAfter"/>
<menuseparator />
<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 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="menu_NormalizeTable" value="&tableFix.label;" accesskey="&tablefix.accesskey;" observes="cmd_NormalizeTable"/>
<!-- menu value is set in InitTableMenu -->
-->
<menuitem id="menu_JoinTableCells" accesskey="&tablejoincells.accesskey;" observes="cmd_JoinTableCells"/>
<menuitem id="menu_SlitTableCell" value="&tableSplitCell.label;" accesskey="&tablesplitcell.accesskey;" observes="cmd_SplitTableCell"/>
<!-- this is shared with Format Menu -->
<menuitem id="menu_TableOrCellColor" value="&tableOrCellColor.label;" accesskey="&formatbkgdcolormenu.accesskey;" observes="cmd_TableOrCellColor"/>
<menuitem id="menu_tableProperties" value="&tableProperties.label;" accesskey="&properties.accesskey;" observes="cmd_editTable"/>
</menupopup>
</menu>
</overlay>
<menupopup id="tableInsertPopup">
<menuitem value="&insertTableCmd.label;" accesskey="&tabletable.accesskey;" observes="cmd_InsertTable"/>
<menuseparator />
<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;" observes="cmd_InsertColumnBefore"/>
<menuitem value="&tableColumnAfter.label;" accesskey="&tablecolumnafter.accesskey;" observes="cmd_InsertColumnAfter"/>
<menuseparator />
<menuitem value="&tableCellBefore.label;" accesskey="&tablecell.accesskey;" observes="cmd_InsertCellBefore"/>
<menuitem value="&tableCellAfter.label;" accesskey="&tablecellafter.accesskey;" observes="cmd_InsertCellAfter"/>
</menupopup>
<menupopup id="tableSelectPopup">
<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>
<menupopup id="tableDeletePopup">
<menuitem id="menu_DeleteTable" value="&tableTable.label;" accesskey="&tabletable.accesskey;" observes="cmd_DeleteTable"/>
<menuitem id="menu_DeleteRow" value="&tableRows.label;" accesskey="&tablerow.accesskey;" observes="cmd_DeleteRow"/>
<menuitem id="menu_DeleteColumn" value="&tableColumns.label;" accesskey="&tablecolumn.accesskey;" observes="cmd_DeleteColumn"/>
<menuitem id="menu_DeleteCell" value="&tableCells.label;" accesskey="&tablecell.accesskey;" observes="cmd_DeleteCell"/>
<menuitem id="menu_DeleteCellContents" value="&tableCellContents.label;" accesskey="&tablecellcontents.accesskey;" observes="cmd_DeleteCellContents"/>
</menupopup>
</overlay>

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

@ -20,47 +20,91 @@
*
*/
function fillContentContextMenu(event, contextMenuNode)
{
if ( event.target != contextMenuNode )
return;
HideDisabledItem("menu_undo_cm");
HideDisabledItem("menu_redo_cm");
HideDisabledItem("menu_cut_cm");
HideDisabledItem("menu_copy_cm");
HideDisabledItem("menu_paste_cm");
HideDisabledItem("menu_delete_cm");
HideDisabledItem("menu_selectAll_cm");
HideDisabledItem("removeLinksMenuitem");
ShowMenuItem("undoredo-separator", ShowUndoRedoSeparator());
ShowMenuItem("menu_edit-separator", ShowCCPSeparator());
ShowMenuItem("menu_selectAll-separator", ShowSelectAllSeparator());
ShowMenuItem("menu_link-separator", ShowLinkSeparator());
ShowMenuItem("tableMenu-separator", ShowTableMenuSeparator());
}
function cleanupContextMenu( event, contextMenuNode )
function EditorFillContextMenu(event, contextMenuNode)
{
if ( event.target != contextMenuNode )
return;
ShowHiddenItemOnCleanup("menu_undo_cm");
ShowHiddenItemOnCleanup("menu_redo_cm");
ShowHiddenItemOnCleanup("menu_cut_cm");
ShowHiddenItemOnCleanup("menu_copy_cm");
ShowHiddenItemOnCleanup("menu_paste_cm");
ShowHiddenItemOnCleanup("menu_delete_cm");
ShowHiddenItemOnCleanup("menu_selectAll_cm");
ShowHiddenItemOnCleanup("removeLinksMenuitem");
// Setup object property menuitem
var objectName = InitObjectPropertiesMenuitem("objectProperties_cm");
InitRemoveStylesMenuitems("removeStylesMenuitem_cm", "removeLinksMenuitem_cm");
var inCell = IsInTableCell();
if (inCell)
{
// Set appropriate text for join cells command
InitJoinCellMenuitem("joinTableCells_cm");
// If displaying cell commands,
// these are the only commands that need enable/disabling
goUpdateCommand("cmd_JoinTableCells");
goUpdateCommand("cmd_SplitTableCell");
goUpdateCommand("cmd_TableOrCellColor");
}
// Loop through all children to hide disabled items
var children = contextMenuNode.childNodes;
if (children)
{
var count = children.length;
for (var i = 0; i < count; i++)
HideDisabledItem(children.item(i));
}
// Remove separators if all items in immediate group above are hidden
// A bit complicated to account if multiple groups are completely hidden!
var haveUndo =
IsMenuItemShowing("menu_undo_cm") ||
IsMenuItemShowing("menu_redo_cm");
var haveEdit =
IsMenuItemShowing("menu_cut_cm") ||
IsMenuItemShowing("menu_copy_cm") ||
IsMenuItemShowing("menu_paste_cm") ||
IsMenuItemShowing("menu_delete_cm");
var haveStyle =
IsMenuItemShowing("removeStylesMenuitem_cm") ||
IsMenuItemShowing("createLink_cm") ||
IsMenuItemShowing("removeLinksMenuitem_cm");
var haveProps = IsMenuItemShowing("objectProperties_cm");
ShowMenuItem("undoredo-separator", haveUndo && haveEdit);
ShowMenuItem("edit-separator", haveEdit || !haveUndo);
// Note: Item "menu_selectAll_cm" and
// folowing separator are ALWAYS enabled,
// so there will always be 1 separator here
ShowMenuItem("styles-separator", haveStyle && (haveProps || inCell));
ShowMenuItem("property-separator", (haveProps && inCell) || !haveStyle);
// Remove table submenus if not in table
ShowMenuItem("tableInsertMenu_cm", inCell);
ShowMenuItem("tableSelectMenu_cm", inCell);
ShowMenuItem("tableDeleteMenu_cm", inCell);
}
function HideDisabledItem( id )
function EditorCleanupContextMenu( event, contextMenuNode )
{
var item = document.getElementById(id);
if (!item)
return false;
if ( event.target != contextMenuNode )
return;
var children = contextMenuNode.childNodes;
if (children)
{
var count = children.length;
for (var i = 0; i < count; i++)
ShowHiddenItemOnCleanup(children.item(i));
}
}
function HideDisabledItem( item )
{
if (!item) return false;
var enabled = (item.getAttribute('disabled') !='true');
if (!enabled)
@ -69,15 +113,12 @@ function HideDisabledItem( id )
item.setAttribute('contexthidden', 'true');
return true;
}
return false;
}
function ShowHiddenItemOnCleanup( id )
function ShowHiddenItemOnCleanup( item )
{
var item = document.getElementById(id);
if (!item)
return false;
if (!item) return false;
var isHidden = (item.getAttribute('contexthidden') == 'true');
if (isHidden)
@ -86,7 +127,6 @@ function ShowHiddenItemOnCleanup( id )
item.removeAttribute('contexthidden');
return true;
}
return false;
}
@ -112,55 +152,3 @@ function IsMenuItemShowing(menuID)
}
return false;
}
function ShowUndoRedoSeparator()
{
return(IsMenuItemShowing("menu_undo_cm")
|| IsMenuItemShowing("menu_redo_cm")
);
}
function ShowCCPSeparator()
{
return(IsMenuItemShowing("menu_cut_cm")
|| IsMenuItemShowing("menu_copy_cm")
|| IsMenuItemShowing("menu_paste_cm")
|| IsMenuItemShowing("menu_delete_cm")
);
}
function ShowSelectAllSeparator()
{
return(IsMenuItemShowing("menu_selectAll_cm")
);
}
function ShowLinkSeparator()
{
return(IsMenuItemShowing("menu_preview_cm")
|| IsMenuItemShowing("removeLinksMenuitem_cm")
);
}
function ShowTableMenuSeparator()
{
return(IsMenuItemShowing("tableMenu_cm")
|| IsMenuItemShowing("tableProperties_cm")
);
}
function EnableMenuItem(id, enableItem)
{
var item = document.getElementById(id);
var enabled = (item.getAttribute('disabled') !='true');
if(item && (enableItem != enabled))
{
item.setAttribute('disabled', enableItem ? '' : 'true');
}
}
function SetupCopyMenuItem(menuID, numSelected, forceHide)
{
ShowMenuItem(menuID, !forceHide);
EnableMenuItem(menuID, (numSelected > 0));
}

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

@ -23,6 +23,7 @@
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<?xul-overlay href="chrome://editor/content/EditorCommandsOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://editor/locale/editorOverlay.dtd">
@ -33,38 +34,72 @@
<popupset id="editorContentContextSet">
<popup id="editorContentContext"
oncreate="return fillContentContextMenu(event, this);"
ondestroy="cleanupContextMenu(event, this);">
<menuitem id="menu_undo_cm" observes="cmd_undo"/>
<menuitem id="menu_redo_cm" observes="cmd_redo"/>
<menuseparator id="undoredo-separator"/>
<menuitem id="menu_cut_cm" observes="cmd_cut"/>
<menuitem id="menu_copy_cm" observes="cmd_copy"/>
<menuitem id="menu_paste_cm" observes="cmd_paste"/>
<menuitem id="menu_delete_cm" observes="cmd_delete"/>
<menuseparator id="menu_edit-separator"/>
<menuitem id="menu_selectAll_cm" observes="cmd_selectAll"/>
<menuseparator id="menu_selectAll-separator"/>
oncreate="EditorFillContextMenu(event, this);"
ondestroy="EditorCleanupContextMenu(event, this);">
<menuitem id="menu_undo" observes="cmd_undo"/>
<menuitem id="menu_redo" observes="cmd_redo"/>
<menuseparator id="undoredo-separator"/>
<menuitem id="menu_cut" observes="cmd_cut"/>
<menuitem id="menu_copy" observes="cmd_copy"/>
<menuitem id="menu_paste" observes="cmd_paste"/>
<menuitem id="menu_delete" observes="cmd_delete"/>
<menuseparator id="edit-separator"/>
<menuitem id="menu_preview_cm" observes="cmd_preview" value="&previewCmd.label;"/>
<menuitem id="removeLinksMenuitem_cm" value="&removeLinksCmd.label;"
accesskey="&formatremovelinks.accesskey;" observes="cmd_RemoveLinks"/>
<menuseparator id="menu_link-separator"/>
<!--
<menuitem id="menu_openURL_cm" value="open url in Composer"/>
<menuitem id="menu_addBookmark_cm" value="add bookmark"/>
<menuitem id="menu_copyURL_cm" value="copy link location"/>
<menuitem id="menu_saveImageAs_cm" value="save image as"/>
<menuitem id="menu_createLinkOnImage_cm" value="create link using image"/>
<menuseparator id="menu_image-separator"/>
-->
<menu id="tableMenu_cm" value="&tableMenu.label;"/>
<menuitem id="tableProperties_cm" value="&tableProperties.label;"/>
<menuseparator id="tableMenu-separator"/>
<menuitem id="objectProperties_cm" value="&properties.label;" observes="cmd_objectProperties"/>
<menuitem id="menu_selectAll_cm" observes="cmd_selectAll"/>
<menuseparator id="selectAll-separator"/>
<!-- Value and accesskey set at runtime from strings -->
<menuitem id="removeStylesMenuitem_cm"
observes="cmd_removeStyles"/>
<menuitem id="createLink_cm" value="&createLinkCmd.label;" accesskey="&insertlink.accesskey;"
observes="cmd_link" />
<!-- Value and accesskey set at runtime from strings -->
<menuitem id="removeLinksMenuitem_cm"
observes="cmd_RemoveLinks"/>
<menuseparator id="styles-separator"/>
<!-- Value and accesskey are set in InitObjectProperties -->
<menuitem id="objectProperties_cm" observes="cmd_objectProperties"/>
<menuseparator id="property-separator"/>
<!-- Can't get submenus to load from a shared overlay -->
<menu id="tableInsertMenu_cm" value="&tableInsertMenu2.label;" accesskey="&tableinsertmenu.accesskey;">
<menupopup>
<menuitem value="&insertTableCmd.label;" accesskey="&tabletable.accesskey;" observes="cmd_InsertTable"/>
<menuseparator />
<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;" observes="cmd_InsertColumnBefore"/>
<menuitem value="&tableColumnAfter.label;" accesskey="&tablecolumnafter.accesskey;" observes="cmd_InsertColumnAfter"/>
<menuseparator />
<menuitem value="&tableCellBefore.label;" accesskey="&tablecell.accesskey;" observes="cmd_InsertCellBefore"/>
<menuitem value="&tableCellAfter.label;" accesskey="&tablecellafter.accesskey;" observes="cmd_InsertCellAfter"/>
</menupopup>
</menu>
<menu id="tableSelectMenu_cm" value="&tableSelectMenu2.label;" accesskey="&tableselectmenu.accesskey;">
<menupopup>
<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="tableDeleteMenu_cm" value="&tableDeleteMenu2.label;" accesskey="&tabledeletemenu.accesskey;">
<menupopup>
<menuitem id="menu_DeleteTable" value="&tableTable.label;" accesskey="&tabletable.accesskey;" observes="cmd_DeleteTable"/>
<menuitem id="menu_DeleteRow" value="&tableRows.label;" accesskey="&tablerow.accesskey;" observes="cmd_DeleteRow"/>
<menuitem id="menu_DeleteColumn" value="&tableColumns.label;" accesskey="&tablecolumn.accesskey;" observes="cmd_DeleteColumn"/>
<menuitem id="menu_DeleteCell" value="&tableCells.label;" accesskey="&tablecell.accesskey;" observes="cmd_DeleteCell"/>
<menuitem id="menu_DeleteCellContents" value="&tableCellContents.label;" accesskey="&tablecellcontents.accesskey;" observes="cmd_DeleteCellContents"/>
</menupopup>
</menu>
<!-- menu value is set in InitTableMenu -->
<menuitem id="joinTableCells_cm" value="&tableJoinCells.label;" accesskey="&tablejoincells.accesskey;" observes="cmd_JoinTableCells"/>
<menuitem id="splitTableCell_cm" value="&tableSplitCell.label;" accesskey="&tablesplitcell.accesskey;" observes="cmd_SplitTableCell"/>
<menuitem id="tableOrCellColor_cm" value="&tableOrCellColor.label;" accesskey="&tableOrCellColor.accesskey;" observes="cmd_TableOrCellColor"/>
</popup>
</popupset>

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

@ -66,10 +66,11 @@ var gIsWindows;
var gIsMac;
var gIsUNIX;
var gIsHTMLEditor = false;
var gColorObj;
var gColorObj = new Object();
var gPrefs;
var gDefaultTextColor = "";
var gDefaultBackgroundColor = "";
// These must be kept in synch with the XUL <options> lists
var gFontSizeNames = new Array("xx-small","x-small","small","medium","large","x-large","xx-large");
@ -124,7 +125,6 @@ var DocumentStateListener =
// udpate menu items now that we have an editor to play with
// Note: This must be AFTER window._content.focus();
//dump("Updating 'create' commands\n");
window.updateCommands("create");
},
@ -167,7 +167,6 @@ function EditorStartup(editorType, editorElement)
// 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.editorType = editorType;
@ -232,42 +231,49 @@ function EditorSharedStartup()
// hide UI that we don't have components for
RemoveInapplicableUIElements();
// Use global prefs if exists, else get service for other editor users
var prefs = gPrefs ? gPrefs : GetPrefsService();
// If not set before, set text and background colors from browser prefs
if (gDefaultTextColor == "" || gDefaultBackgroundColor == "")
// Use global prefs if EditorStartup already run,
// else get service for other editor users
if (!gPrefs) GetPrefsService();
// Use browser colors as initial values for editor's default colors
var BrowserColors = GetDefaultBrowserColors();
if (BrowserColors)
{
var useWinColors = false;
if (gIsWindows)
{
// What a pain! In Windows, there's a pref to use system colors
// instead of pref colors
try { useWinColors = prefs.GetBoolPref("browser.display.wfe.use_windows_colors"); } catch (e) {}
// dump("Using Windows colors = "+useWinColors+"\n");
}
if (useWinColors)
{
// TODO: Get system text and windows colors HOW!
// Alternative: Can we get the actual text and background colors used by layout?
}
else
{
if (gDefaultTextColor == "")
try { gDefaultTextColor = prefs.CopyCharPref("browser.display.foreground_color"); } catch (e) {}
if (gDefaultBackgroundColor == "")
try { gDefaultBackgroundColor = prefs.CopyCharPref("browser.display.background_color"); } catch (e) {}
}
// Last resort is to assume black for text, white for background
if (gDefaultTextColor == "")
gDefaultTextColor = "#000000";
if (gDefaultBackgroundColor == "")
gDefaultBackgroundColor = "#FFFFFF";
gDefaultTextColor = BrowserColors.TextColor;
gDefaultBackgroundColor = BrowserColors.BackgroundColor;
}
dump(" *** EditorSharedStartup: gDefaultTextColor="+gDefaultTextColor+", gDefaultBackgroundColor="+gDefaultBackgroundColor+"\n");
//dump(" *** EditorShared startup: gDefaultTextColor="+gDefaultTextColor+", gDefaultBackgroundColor="+gDefaultBackgroundColor+"\n");
}
// Get these to use for initial default text and background,
// and also pass to prefs and color dialogs
function GetDefaultBrowserColors()
{
var colors = new Object();
var useWinColors = false;
if (gIsWindows)
{
// In Windows only, there's a pref to use system colors instead of pref colors
try { useWinColors = gPrefs.GetBoolPref("browser.display.wfe.use_windows_colors"); } catch (e) {}
}
if (!useWinColors)
{
try { colors.TextColor = gPrefs.CopyCharPref("browser.display.foreground_color"); } catch (e) {}
try { colors.BackgroundColor = gPrefs.CopyCharPref("browser.display.background_color"); } catch (e) {}
}
// Use OS colors for text and background if explicitly asked or pref is not set
if (!colors.TextColor)
colors.TextColor = "windowtext";
if (!colors.BackgroundColor)
colors.BackgroundColor = "window";
colors.LinkColor = gPrefs.CopyCharPref("browser.anchor_color");
colors.VisitedLinkColor = gPrefs.CopyCharPref("browser.visited_color");
return colors;
}
function _EditorNotImplemented()
@ -372,7 +378,7 @@ function CheckAndSaveDocument(reasonToSave, allowDontSave)
var title = window.editorShell.editorDocument.title;
if (!title)
var title = GetString("untitled");
title = GetString("untitled");
var dialogTitle = window.editorShell.GetString("SaveDocument");
var dialogMsg = window.editorShell.GetString("SaveFilePrompt");
@ -408,11 +414,11 @@ function CheckAndSaveDocument(reasonToSave, allowDontSave)
return success;
}
if (result.value == 1) // "Cancel"
return false;
if (result.value == 2) // "Don't Save"
return true;
// Default or result.value == 1 (Cancel)
return false;
}
// --------------------------- File menu ---------------------------
@ -440,7 +446,6 @@ function EditorNewPlaintext()
function EditorCanClose()
{
// Returns FALSE only if user cancels save action
//dump("Calling EditorCanClose\n");
// "true" means allow "Don't Save" button
var canClose = CheckAndSaveDocument(GetString("BeforeClosing"), true);
@ -498,8 +503,6 @@ function onParagraphFormatChange(paraMenuList, commandID)
var menuList = document.getElementById("ParagraphSelect");
if (!menuList) return;
//dump("Updating paragraph format with " + state + "\n");
// force match with "normal"
if (state == "body")
state = "";
@ -514,7 +517,7 @@ function onParagraphFormatChange(paraMenuList, commandID)
{
var menuPopup = document.getElementById("ParagraphPopup");
var menuItems = menuPopup.childNodes;
for (i=0; i < menuItems.length; i++)
for (var i=0; i < menuItems.length; i++)
{
var menuItem = menuItems.item(i);
if (menuItem.data == state)
@ -540,8 +543,6 @@ function onFontFaceChange(fontFaceMenuList, commandID)
var commandNode = document.getElementById(commandID);
var state = commandNode.getAttribute("state");
//dump("Updating font face with " + state + "\n");
if (state == "mixed")
{
//Selection is the "mixed" ( > 1 style) state
@ -552,7 +553,7 @@ function onFontFaceChange(fontFaceMenuList, commandID)
{
var menuPopup = document.getElementById("FontFacePopup");
var menuItems = menuPopup.childNodes;
for (i=0; i < menuItems.length; i++)
for (var i=0; i < menuItems.length; i++)
{
var menuItem = menuItems.item(i);
if (menuItem.getAttribute("value") && (menuItem.data.toLowerCase() == state.toLowerCase()))
@ -567,7 +568,6 @@ function onFontFaceChange(fontFaceMenuList, commandID)
function EditorSelectFontSize()
{
var select = document.getElementById("FontSizeSelect");
//dump("EditorSelectFontSize: "+gFontSizeNames[select.selectedIndex]+"\n");
if (select)
{
if (select.selectedIndex == -1)
@ -589,7 +589,7 @@ function onFontSizeChange(fontSizeMenulist, commandID)
}
else
{
for( var i = 0; i < gFontSizeNames.length; i++)
for (var i = 0; i < gFontSizeNames.length; i++)
{
if( gFontSizeNames[i] == size )
{
@ -663,6 +663,7 @@ function onBackgroundColorChange()
{
if (!color)
color = gDefaultBackgroundColor;
button.setAttribute("style", "background-color:"+color);
}
}
@ -670,9 +671,6 @@ function onBackgroundColorChange()
function GetBackgroundElementWithColor()
{
if (!gColorObj)
gColorObj = new Object;
gColorObj.Type = "";
gColorObj.PageColor = "";
gColorObj.TableColor = "";
@ -721,7 +719,8 @@ function EditorSelectColor(colorType)
var element;
var table;
var currentColor = "";
var commandNode;
if (!colorType)
colorType = "";
@ -730,7 +729,7 @@ function EditorSelectColor(colorType)
gColorObj.Type = colorType;
// Get color from command node state
var commandNode = document.getElementById("cmd_fontColor");
commandNode = document.getElementById("cmd_fontColor");
currentColor = commandNode.getAttribute("state");
gColorObj.TextColor = currentColor;
}
@ -777,8 +776,6 @@ function EditorSelectColor(colorType)
if (gColorObj.Cancel)
return;
var commandNode;
if (colorType == "Text")
{
if (currentColor != gColorObj.TextColor)
@ -828,16 +825,18 @@ function GetParentTable(element)
/*TODO: We need an oncreate hook to do enabling/disabling for the
Format menu. There should be code like this for the
object-specific "Properties..." item
object-specific "Properties" item
*/
// For property dialogs, we want the selected element,
// but will accept a parent table cell or link if inside one
function GetSelectedElementOrParentCellOrLink()
// but will accept a parent link, list, or table cell if inside one
function GetObjectForProperties()
{
var element = editorShell.GetSelectedElement("");
if (!element)
element = editorShell.GetElementOrParentByTagName("href",null);
if (!element)
element = editorShell.GetElementOrParentByTagName("list",null);
if (!element)
element = editorShell.GetElementOrParentByTagName("td",null);
@ -896,7 +895,6 @@ function SetEditMode(mode)
if (titleEnd > titleStart)
{
var title = source.slice(titleStart, titleEnd);
dump("Title="+title+"|\n");
editorShell.SetDocumentTitle(title);
}
}
@ -935,8 +933,6 @@ function CollapseItem(id, collapse)
if(collapse != (item.getAttribute("collapsed") == "true"))
item.setAttribute("collapsed", collapse ? "true" : "");
}
else
dump("CollapseItem: item id="+id+" not found\n");
}
function DisableItem(id, disable)
@ -947,8 +943,6 @@ function DisableItem(id, disable)
if(disable != (item.getAttribute("disabled") == "true"))
item.setAttribute("disabled", disable ? "true" : "");
}
else
dump("DisableItem: item id="+id+" not found\n");
}
function SetDisplayMode(mode)
@ -1035,6 +1029,7 @@ function SetDisplayMode(mode)
return true;
}
return false;
}
// We disable all items in View menu except Edit mode and sidebar items
@ -1162,7 +1157,7 @@ function ShuffleRecentMenu(curUrl)
try { historyCount = gPrefs.CopyUnicharPref("editor.history.url_maximum"); } catch(e) {} // Number of items in recent files menu
var titleArray = new Array(historyCount);
var urlArray = new Array(historyCount);
var i;
for (i = 0; i < historyCount; i++)
{
titleArray[i] = getUnicharPref("editor.history_title_"+i);
@ -1211,7 +1206,7 @@ function BuildRecentMenu()
try { historyCount = gPrefs.CopyUnicharPref("editor.history.url_maximum"); } catch(e) {}
var a=1; // Keeps track of which access key to use in the menuitem
for(i = 0; i < historyCount; i++)
for (var i = 0; i < historyCount; i++)
{
var title = getUnicharPref("editor.history_title_"+i);
var url = getUnicharPref("editor.history_url_"+i);
@ -1263,7 +1258,7 @@ function AppendRecentMenuitem(accessKey, menupopup, title, url)
function setUnicharPref(aPrefName, aPrefValue)
{
if (!gPrefs) return "";
if (!gPrefs) return;
try
{
gPrefs.SetUnicharPref(aPrefName, aPrefValue);
@ -1282,15 +1277,14 @@ function getUnicharPref(aPrefName, aDefVal)
}
catch(e)
{
return "";
}
return "";
}
function EditorInitFormatMenu()
{
InitObjectPropertiesMenuitem("objectProperties");
// Change text on the "Remove styles" and "Remove links"
// for better wording when
InitRemoveStylesMenuitems("removeStylesMenuitem", "removeLinksMenuitem");
}
function InitObjectPropertiesMenuitem(id)
@ -1299,49 +1293,64 @@ function InitObjectPropertiesMenuitem(id)
// Note that we directly do the enabling instead of
// using goSetCommandEnabled since we already have the menuitem
var menuItem = document.getElementById(id);
if (menuItem)
{
var element = GetSelectedElementOrParentCellOrLink();
var menuStr = GetString("ObjectProperties");
if (element && element.nodeName)
{
var objStr = "";
menuItem.setAttribute("disabled", "");
var name = element.nodeName.toLowerCase();
switch (name)
{
case "img":
objStr = GetString("Image");
break;
case "hr":
objStr = GetString("HLine");
break;
case "table":
objStr = GetString("Table");
break;
case "td":
objStr = GetString("TableCell");
break;
case "a":
if (element.name)
objStr = GetString("NamedAnchor");
else if(element.href)
objStr = GetString("Link");
break;
}
menuStr = menuStr.replace(/%obj%/,objStr);
}
else
{
// We show generic "Properties" string, but disable menu item
menuItem.setAttribute("disabled","true");
// Replace placeholder with "", then remaining space on left side
menuStr = menuStr.replace(/%obj%/,"").replace(/^\s+/, "");
if (!menuItem) return null;
var element = GetObjectForProperties();
var menuStr = GetString("ObjectProperties");
var name;
if (element && element.nodeName)
{
var objStr = "";
menuItem.setAttribute("disabled", "");
name = element.nodeName.toLowerCase();
switch (name)
{
case "img":
objStr = GetString("Image");
break;
case "hr":
objStr = GetString("HLine");
break;
case "table":
objStr = GetString("Table");
break;
case "th":
name = "td";
case "td":
objStr = GetString("TableCell");
break;
case "ol":
case "ul":
case "dl":
objStr = GetString("List");
break;
case "a":
if (element.name)
{
objStr = GetString("NamedAnchor");
name = "anchor";
}
else if(element.href)
{
objStr = GetString("Link");
name = "href";
}
break;
}
menuItem.setAttribute("value", menuStr);
menuItem.setAttribute("accesskey",GetString("ObjectPropertiesAccessKey"));
menuStr = menuStr.replace(/%obj%/,objStr);
}
else
{
// We show generic "Properties" string, but disable menu item
menuItem.setAttribute("disabled","true");
// Replace placeholder with "", then remaining space on left side
menuStr = menuStr.replace(/%obj%/,"").replace(/^\s+/, "");
}
menuItem.setAttribute("value", menuStr);
menuItem.setAttribute("accesskey",GetString("ObjectPropertiesAccessKey"));
return name;
}
function InitParagraphMenu()
@ -1359,7 +1368,13 @@ function InitParagraphMenu()
else
IDSuffix = state;
document.getElementById("menu_"+IDSuffix).setAttribute("checked", "true");
// Set "radio" check on one item, but...
var menuItem = document.getElementById("menu_"+IDSuffix);
menuItem.setAttribute("checked", "true");
// ..."bodyText" is returned if mixed selection, so remove checkmark
if (mixedObj.value)
menuItem.setAttribute("checked", "false");
}
function InitListMenu()
@ -1367,7 +1382,7 @@ function InitListMenu()
var mixedObj = new Object();
var state = editorShell.GetListState(mixedObj);
var IDSuffix = "noList";
if (state)
{
if (state == "dl")
@ -1376,8 +1391,13 @@ function InitListMenu()
if (state)
IDSuffix = state;
}
// Set "radio" check on one item, but...
var menuItem = document.getElementById("menu_"+IDSuffix);
menuItem.setAttribute("checked", "true");
document.getElementById("menu_"+IDSuffix).setAttribute("checked", "true");
// ..."noList" is returned if mixed selection, so remove checkmark
if (mixedObj.value)
menuItem.setAttribute("checked", "false");
}
function EditorInitToolbars()
@ -1392,6 +1412,7 @@ function EditorSetDefaultPrefs()
if ( url != "about:blank" )
return;
var element;
var domdoc;
try { domdoc = window.editorShell.editorDocument; } catch (e) { dump( e + "\n"); }
if ( !domdoc )
@ -1442,7 +1463,7 @@ function EditorSetDefaultPrefs()
catch (ex) {}
if ( prefCharsetString && prefCharsetString != 0)
{
var element = domdoc.createElement("meta");
element = domdoc.createElement("meta");
if ( element )
{
AddAttrToElem(domdoc, "http-equiv", "content-type", element);
@ -1480,7 +1501,7 @@ function EditorSetDefaultPrefs()
if ( !authorFound && headelement)
{
/* create meta tag with 2 attributes */
var element = domdoc.createElement("meta");
element = domdoc.createElement("meta");
if ( element )
{
AddAttrToElem(domdoc, "name", "author", element);
@ -1492,20 +1513,27 @@ function EditorSetDefaultPrefs()
}
// color prefs
// Get editor color prefs
var use_custom_colors = false;
try {
use_custom_colors = gPrefs.GetBoolPref("editor.use_custom_colors");
}
catch (ex) {}
// XXX BUG: this is always comming up TRUE even when pref panel is used to set false
dump(" *** editor.use_custom_colors="+use_custom_colors+"\n");
if ( use_custom_colors )
{
// find body node
var bodyelement = GetBodyElement();
// 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 = "";
var text_color;
var link_color;
var active_link_color;
var followed_link_color;
var background_color;
try { text_color = gPrefs.CopyCharPref("editor.text_color"); } catch (e) {}
try { link_color = gPrefs.CopyCharPref("editor.link_color"); } catch (e) {}
@ -1515,25 +1543,23 @@ function EditorSetDefaultPrefs()
// add the color attributes to the body tag.
// and use them for the default text and background colors if not empty
if (text_color != "")
if (text_color)
{
AddAttrToElem(domdoc, "text", text_color, bodyelement);
gDefaultTextColor = text_color;
}
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 != "")
if (background_color)
{
AddAttrToElem(domdoc, "bgcolor", background_color, bodyelement);
gDefaultBackgroundColor = background_color
}
dump(" *** SetDefaultPrefs: gDefaultTextColor="+gDefaultTextColor+", gDefaultBackgroundColor="+gDefaultBackgroundColor+"\n");
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);
}
@ -1574,17 +1600,7 @@ function UpdateSaveButton(modified)
} else {
saveButton.setAttribute("src", "chrome://editor/skin/images/ED_SaveFile.gif");
}
dump("updating button\n");
}
else
{
dump("could not find button\n");
}
}
function EditorDoDoubleClick()
{
dump("doing double click\n");
}
function EditorReflectDocState()
@ -1604,8 +1620,6 @@ function EditorReflectDocState()
if (oldModified != documentModified)
UpdateSaveButton(documentModified);
//dump("Updating save state " + stateString + "\n");
return true;
}
@ -1614,11 +1628,9 @@ function EditorReflectDocState()
function EditorGetNodeFromOffsets(offsets)
{
var node = null;
var i;
node = editorShell.editorDocument;
for (i = 0; i < offsets.length; i++)
for (var i = 0; i < offsets.length; i++)
{
node = node.childNodes[offsets[i]];
}
@ -1628,12 +1640,12 @@ function EditorGetNodeFromOffsets(offsets)
function EditorSetSelectionFromOffsets(selRanges)
{
var rangeArr, start, end, i, node, offset;
var rangeArr, start, end, node, offset;
var selection = editorShell.editorSelection;
selection.clearSelection();
for (i = 0; i < selRanges.length; i++)
for (var i = 0; i < selRanges.length; i++)
{
rangeArr = selRanges[i];
start = rangeArr[0];
@ -1672,7 +1684,6 @@ function initFontStyleMenu(menuPopup)
//--------------------------------------------------------------------
function onButtonUpdate(button, commmandID)
{
// dump(" === onButtonUpdate called\n");
var commandNode = document.getElementById(commmandID);
var state = commandNode.getAttribute("state");
@ -1682,7 +1693,6 @@ function onButtonUpdate(button, commmandID)
//--------------------------------------------------------------------
function onStateButtonUpdate(button, commmandID, onState)
{
// dump(" === onButtonUpdate called\n");
var commandNode = document.getElementById(commmandID);
var state = commandNode.getAttribute("state");
@ -1693,7 +1703,7 @@ function onStateButtonUpdate(button, commmandID, onState)
// --------------------------- Status calls ---------------------------
function onStyleChange(theStyle)
{
dump("in onStyleChange with " + theStyle + "\n");
//dump("in onStyleChange with " + theStyle + "\n");
var broadcaster = document.getElementById("cmd_" + theStyle);
var isOn = broadcaster.getAttribute("state");
@ -1703,14 +1713,12 @@ function onStyleChange(theStyle)
var theButton = document.getElementById(theStyle + "Button");
if (theButton)
{
// dump("setting button to " + isOn + "\n");
theButton.setAttribute("toggled", (isOn == "true") ? 1 : 0);
}
var theMenuItem = document.getElementById(theStyle + "MenuItem");
if (theMenuItem)
{
// dump("setting menuitem to " + isOn + "\n");
theMenuItem.setAttribute("checked", isOn);
}
}
@ -1742,7 +1750,6 @@ function getColorAndSetColorWell(ColorPickerID, ColorWellID)
{
// Extract color from colorPicker and assign to colorWell.
var color = colorPicker.getAttribute("color");
dump("setColor to: "+color+"\n");
if (colorWell && color)
{
@ -1794,8 +1801,6 @@ function RemoveInapplicableUIElements()
// if no find, remove find ui
if (!IsFindInstalled())
{
dump("Hiding find items\n");
var findMenuItem = document.getElementById("menu_find");
if (findMenuItem)
findMenuItem.setAttribute("hidden", "true");
@ -1812,8 +1817,6 @@ function RemoveInapplicableUIElements()
// if no spell checker, remove spell checker ui
if (!IsSpellCheckerInstalled())
{
dump("Hiding spell checker items\n");
var spellingButton = document.getElementById("spellingButton");
if (spellingButton)
spellingButton.setAttribute("hidden", "true");
@ -1828,11 +1831,6 @@ function RemoveInapplicableUIElements()
}
}
function onEditorFocus()
{
dump("onEditorFocus called\n");
}
function GetPrefsService()
{
// Store the prefs object
@ -1856,6 +1854,14 @@ function GetPrefsService()
// Don't update on on selection change, only when menu is displayed,
// with this "oncreate" hander:
function EditorInitTableMenu()
{
InitJoinCellMenuitem("menu_JoinTableCells");
// Set enable states for all table commands
goUpdateTableMenuItems(document.getElementById("composerTableMenuItems"));
}
function InitJoinCellMenuitem(id)
{
// Change text on the "Join..." item depending if we
// are joining selected cells or just cell to right
@ -1863,6 +1869,8 @@ function EditorInitTableMenu()
// table border? Try to figure out all cells
// included in the selection?
var menuText;
var menuItem = document.getElementById(id);
if (!menuItem) return;
// Use "Join selected cells if there's more than 1 cell selected
var tagNameObj = new Object;
@ -1872,11 +1880,33 @@ function EditorInitTableMenu()
else
menuText = GetString("JoinCellToRight");
document.getElementById("menu_JoinTableCells").setAttribute("value",menuText);
document.getElementById("menu_JoinTableCells").setAttribute("accesskey","j");
menuItem.setAttribute("value",menuText);
menuItem.setAttribute("accesskey",GetString("JoinCellAccesskey"));
}
// Set enable states for all table commands
goUpdateTableMenuItems(document.getElementById("composerTableMenuItems"));
function InitRemoveStylesMenuitems(removeStylesId, removeLinksId)
{
// Change wording of menuitems depending on selection
var stylesItem = document.getElementById(removeStylesId);
var linkItem = document.getElementById(removeLinksId);
var isCollapsed = editorShell.editorSelection.isCollapsed;
if (stylesItem)
{
stylesItem.setAttribute("value", isCollapsed ? GetString("StopTextStyles") : GetString("RemoveTextStyles"));
stylesItem.setAttribute("accesskey", GetString("RemoveTextStylesAccesskey"));
}
if (linkItem)
{
linkItem.setAttribute("value", isCollapsed ? GetString("StopLinks") : GetString("RemoveLinks"));
linkItem.setAttribute("accesskey", GetString("RemoveLinksAccesskey"));
// Note: disabling text style is a pain since there are so many - forget it!
// Disable if not in a link, but always allow "Remove"
// if selection isn't collapsed since we only look at anchor node
DisableItem(removeLinksId,
isCollapsed && !window.editorShell.GetElementOrParentByTagName("href", null));
}
}
function goUpdateTableMenuItems(commandset)
@ -2040,6 +2070,7 @@ function FindEditorWithInsertCharDialog()
return tempWindow;
}
}
return null;
}
function EditorFindOrCreateInsertCharWindow()

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

@ -21,9 +21,11 @@
- Contributor(s):
- Ryan Cassin (rcassin@supernova.org)
-->
<!-- Submenus shared between main window and context window -->
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
<!-- items shared between editorOverlay menus and context popups -->
<!-- Contains submenus shared by both window and popup menus -->
<!DOCTYPE window SYSTEM "chrome://editor/locale/editorOverlay.dtd">
@ -436,13 +438,12 @@
position="4"/>
<menuseparator position="5"/>
<menuitem id="removeAllStylesMenuitem" value="&removeAllStylesCmd.label;"
accesskey="&formatremovestyles.accesskey;" key="removestyleskb"
oncommand="goDoCommand('cmd_removeStyles')"
<!-- Value and accesskey set at runtime from strings -->
<menuitem id="removeStylesMenuitem" key="removestyleskb"
observes="cmd_removeStyles"
position="6"/>
<menuitem id="removeLinksMenuitem" value="&removeLinksCmd.label;"
accesskey="&formatremovelinks.accesskey;" key="removelinkskb"
oncommand="goDoCommand('cmd_removeLinks')"
<menuitem id="removeLinksMenuitem" key="removelinkskb"
observes="cmd_removeLinks"
position="7"/>
<menuseparator position="8"/>
@ -506,9 +507,11 @@
<!-- Merge property items here -->
</menupopup>
<!-- Items to append at the bottom of the formatMenuPopup -->
<menuitem id="objectProperties" value="&properties.label;" accesskey="&properties.accesskey;"
observes="cmd_objectProperties"/>
<!-- Next 3 are items to append at the bottom of the formatMenuPopup -->
<!-- Value and accesskey filled in during menu creation -->
<menuitem id="objectProperties"
oncommand="goDoCommand('cmd_objectProperties')"/>
<!-- Dont use 'observes', must call command correctly -->
<menuitem id="pageProperties" value="&pageProperties.label;"
accesskey="&pageproperties.accesskey;"
oncommand="goDoCommand('cmd_pageProperties')"/>
@ -518,50 +521,23 @@
<menu id="tableMenu" value="&tableMenu.label;" accesskey="&tablemenu.accesskey;">
<menupopup oncreate="EditorInitTableMenu()">
<!-- From EditorCommandOverlay.xul (shared with context popup) -->
<menu id="tableInsertMenu" value="&tableInsertMenu.label;" accesskey="&tableinsertmenu.accesskey;">
<menupopup>
<menuitem value="&insertTableCmd.label;" accesskey="&tabletable.accesskey;" observes="cmd_InsertTable"/>
<menuseparator />
<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;" observes="cmd_InsertColumnBefore"/>
<menuitem value="&tableColumnAfter.label;" accesskey="&tablecolumnafter.accesskey;" observes="cmd_InsertColumnAfter"/>
<menuseparator />
<menuitem value="&tableCellBefore.label;" accesskey="&tablecell.accesskey;" observes="cmd_InsertCellBefore"/>
<menuitem value="&tableCellAfter.label;" accesskey="&tablecellafter.accesskey;" observes="cmd_InsertCellAfter"/>
</menupopup>
<menupopup id="tableInsertPopup"/>
</menu>
<menu id="tableSelectMenu" value="&tableSelectMenu.label;"
accesskey="&tableselectmenu.accesskey;">
<menupopup>
<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 id="tableSelectMenu" value="&tableInsertMenu.label;" accesskey="&tableselectmenu.accesskey;">
<menupopup id="tableSelectPopup"/>
</menu>
<menu id="tableDeleteMenu" value="&tableDeleteMenu.label;" accesskey="&tabledeletemenu.accesskey;">
<menupopup>
<menuitem id="menu_DeleteTable" value="&tableTable.label;" accesskey="&tabletable.accesskey;" observes="cmd_DeleteTable"/>
<menuitem id="menu_DeleteRow" value="&tableRows.label;" accesskey="&tablerow.accesskey;" observes="cmd_DeleteRow"/>
<menuitem id="menu_DeleteColumn" value="&tableColumns.label;" accesskey="&tablecolumn.accesskey;" observes="cmd_DeleteColumn"/>
<menuitem id="menu_DeleteCell" value="&tableCells.label;" accesskey="&tablecell.accesskey;" observes="cmd_DeleteCell"/>
<menuitem id="menu_DeleteCellContents" value="&tableCellContents.label;" accesskey="&tablecellcontents.accesskey;" observes="cmd_DeleteCellContents"/>
</menupopup>
<menupopup id="tableDeletePopup"/>
</menu>
<menuseparator />
<!--
<menuitem id="menu_NormalizeTable" value="&tableFix.label;" accesskey="&tablefix.accesskey;" observes="cmd_NormalizeTable"/>
-->
<!-- menu value is set in InitTableMenu -->
<menuitem id="menu_JoinTableCells" value="&tableJoinCells.label;" accesskey="&tablejoincells.accesskey;" observes="cmd_JoinTableCells"/>
<menuitem id="menu_SlitTableCell" value="&tableSplitCell.label;" accesskey="&tablesplitcell.accesskey;" observes="cmd_SplitTableCell"/>
<menuseparator />
<menuitem id="menu_TableOrCellColor" value="&tableOrCellColor.label;" accesskey="&tableOrCellColor.accesskey;" observes="cmd_TableOrCellColor"/>
<!-- this is shared with Format Menu -->
<menuitem id="menu_tableProperties" value="&tableProperties.label;" accesskey="&properties.accesskey;" observes="cmd_editTable"/>
<menuitem id="menu_tableProperties" value="&tableProperties.label;" accesskey="&tableProperties.accesskey;" observes="cmd_editTable"/>
</menupopup>
</menu>
@ -615,7 +591,7 @@
value="&previewToolbarCmd.label;" observes="cmd_preview"
tooltip="aTooltip" tooltiptext="&previewToolbarCmd.tooltip;"/>
<menubutton class="menubutton-dual toolbar" id="printButton" value="&printToolbarCmd.label;"
<menubutton class="menubutton-dual toolbar top" id="printButton" value="&printToolbarCmd.label;"
observes="cmd_print" tooltip="aTooltip" tooltiptext="&printToolbarCmd.tooltip;"
crop="right">
<menupopup id="printMenu">

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

@ -69,11 +69,11 @@ ValidateNumber=The number you entered (%n%) is outside of the allowed range. Ple
MissingAnchorNameError=You must enter a name for this anchor.
#LOCALIZATION NOTE (DuplicateAnchorNameError): Don't translate %name%
DuplicateAnchorNameError="%name%" already exists in this page. Please enter a different name.
BulletStyle=Bullet Style:
BulletStyle=Bullet Style
SolidCircle=Solid circle
OpenCircle=Open circle
SolidSquare=Solid square
NumberStyle=Number Style:
NumberStyle=Number Style
Automatic=Automatic
Style_1=1,2,3...
Style_I=I,II,III...
@ -104,6 +104,7 @@ HLine=Horizontal Line
Link=Link
Image=Image
NamedAnchor=Named Anchor
List=List
Tag=Tag
# LOCALIZATION NOTE (ObjectProperties):Don't translate "%obj%" it will be replaced with one of above object nouns
ObjectProperties=%obj% Properties...
@ -115,6 +116,7 @@ JoinSelectedCells=Join Selected Cells
# LOCALIZATION NOTE (JoinCellToRight): This variable should contain the "tablejoincells.accesskey"
# letter as defined in editorOverlay.dtd
JoinCellToRight=Join with Cell to the Right
JoinCellAccesskey=j
# LOCALIZATION NOTE (TableSelectKey): DONT_TRANSLATE
TableSelectKey=Ctrl+
# LOCALIZATION NOTE (XulKeyDefault): DONT_TRANSLATE
@ -139,3 +141,9 @@ Close=Close
# editor.js
#
editor.throbber.url=http://www.mozilla.org/
RemoveTextStyles=Remove All Text Styles
RemoveTextStylesAccesskey=x
StopTextStyles=Discontinue Text Styles
RemoveLinks=Remove Links
StopLinks=Discontinue Link
RemoveLinksAccesskey=n

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

@ -248,6 +248,7 @@
<!ENTITY insertMenu.label "Insert">
<!ENTITY insertmenu.accesskey "i">
<!ENTITY insertLinkCmd.label "Link...">
<!ENTITY createLinkCmd.label "Create Link...">
<!ENTITY insertlink.accesskey "l">
<!ENTITY link.keybinding "l">
<!ENTITY insertAnchorCmd.label "Named Anchor...">
@ -351,12 +352,10 @@
<!ENTITY formatfontcolor.accesskey "c">
<!ENTITY tableOrCellColor.label "Table or Cell Background Color...">
<!ENTITY tableOrCellColor.accesskey "b">
<!ENTITY removeAllStylesCmd.label "Remove All Text Styles">
<!ENTITY formatremovestyles.accesskey "r">
<!ENTITY formatremovestyles.keybinding "k">
<!ENTITY removeLinksCmd.label "Remove Link(s)">
<!ENTITY formatremovelinks.accesskey "m">
<!ENTITY formatremovelinks.keybinding "l">
<!ENTITY formatindent.keybinding "=">
<!ENTITY formatoutdent.keybinding "-">
<!ENTITY paragraphMenu.label "Paragraph">
@ -403,7 +402,7 @@
<!ENTITY bodyTextCmd.label "Body Text">
<!ENTITY bodytext.accesskey "t">
<!-- isn't used in menu now, but may be added in future -->
<!ENTITY advancedPropertiesCmd.label "Advanced Properties...">
<!ENTITY advancedPropertiesCmd.label "Advanced Properties">
<!ENTITY advancedproperties.accesskey "v">
<!ENTITY NormalAbbr.label "Text">
@ -445,9 +444,9 @@
<!ENTITY decreaseindent.accesskey "d">
<!ENTITY decreaseindentkb "-">
<!ENTITY pageProperties.label "Page Title and Properties">
<!ENTITY pageProperties.label "Page Title and Properties...">
<!ENTITY pageproperties.accesskey "g">
<!ENTITY colorsAndBackground.label "Page Colors and Background">
<!ENTITY colorsAndBackground.label "Page Colors and Background...">
<!ENTITY colorsandbackground.accesskey "u">
<!-- Table Menu -->
@ -457,6 +456,10 @@
<!ENTITY tableSelectMenu.label "Select">
<!ENTITY tableselectmenu.accesskey "s">
<!ENTITY tableSelectMenu2.label "Table Select">
<!ENTITY tableInsertMenu2.label "Table Insert">
<!ENTITY tableDeleteMenu2.label "Table Delete">
<!-- Insert SubMenu -->
<!ENTITY tableInsertMenu.label "Insert">
<!ENTITY tableinsertmenu.accesskey "i">
@ -502,10 +505,8 @@
<!ENTITY tablejoincells.accesskey "j">
<!ENTITY tableSplitCell.label "Split Cell">
<!ENTITY tablesplitcell.accesskey "i">
<!ENTITY tableProperties.label "Table Properties">
<!-- These may be shared in other menus -->
<!ENTITY properties.label "Properties...">
<!ENTITY properties.accesskey "o">
<!ENTITY tableProperties.label "Table Properties...">
<!ENTITY tableProperties.accesskey "o">
<!-- Tools Menu -->
<!ENTITY toolsmenu.accesskey "l">

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

@ -236,7 +236,8 @@ function ValidateData()
function onOK()
{
if (!ValidateData()) return;
if (!ValidateData())
return false;
// Set return values and save in persistent color attributes
if (TextType)

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

@ -35,6 +35,7 @@
var BodyElement;
var prefs;
var backgroundImage;
var dialog;
// Initialize in case we can't get them from prefs???
var defaultTextColor="#000000";
@ -59,7 +60,7 @@ var bgcolorStr = "bgcolor";
var backgroundStr = "background";
var colorStyle = "color: ";
var backColorStyle = "background-color: ";
var backImageStyle = " background-image: url(";
var backImageStyle = "; background-image: url(";
// dialog initialization code
function Startup()
@ -97,31 +98,20 @@ function Startup()
// Initialize default colors from browser prefs
var prefs = GetPrefs();
if (prefs)
if (prefs && window.arguments[1])
{
// This doesn't necessarily match what appears in the page
// It is complicated by browser.display.use_document_colors
// TODO: WE MUST FORCE WINDOW TO USE DOCUMENT COLORS!!!
// How do we do that without changing browser prefs?
var useDocumentColors = prefs.GetBoolPref("browser.display.use_document_colors");
if (useDocumentColors)
{
// How do I get current colors as show in page?
} else {
try {
// Use author's browser pref colors
defaultTextColor = prefs.CopyCharPref("browser.display.foreground_color");
defaultLinkColor = prefs.CopyCharPref("browser.anchor_color");
// Note: Browser doesn't store a value for ActiveLinkColor
defaultActiveColor = defaultLinkColor;
defaultVisitedColor = prefs.CopyCharPref("browser.visited_color");
defaultBackgroundColor= prefs.CopyCharPref("browser.display.background_color");
}
catch (ex) {
dump("Failed getting browser colors from prefs\n");
}
}
// XXX TODO: This is a problem! If this is false, it overrides ability to display colors set in document!!!
// var useDocumentColors = prefs.GetBoolPref("browser.display.use_document_colors");
// Use author's browser pref colors passed into dialog
defaultTextColor = window.arguments[1].TextColor;
defaultLinkColor = window.arguments[1].LinkColor;
// Note: Browser doesn't store a value for ActiveLinkColor
defaultActiveColor = defaultLinkColor;
defaultVisitedColor = window.arguments[1].VisitedLinkColor;
defaultBackgroundColor= window.arguments[1].BackgroundColor;
}
InitDialog();
if (dialog.DefaultColorsRadio.checked)
@ -148,19 +138,22 @@ function InitDialog()
customVisitedColor = globalElement.getAttribute(vlinkStr);
customBackgroundColor = globalElement.getAttribute(bgcolorStr);
if (customTextColor ||
customLinkColor ||
customVisitedColor ||
customActiveColor ||
customBackgroundColor)
{
// Set default color explicitly for any that are missing
if (!customTextColor) customTextColor = defaultTextColor;
if (!customLinkColor) customLinkColor = defaultLinkColor;
if (!customActiveColor) customActiveColor = defaultActiveColor;
if (!customVisitedColor) customVisitedColor = defaultVisitedColor;
if (!customBackgroundColor) customBackgroundColor = defaultBackgroundColor;
var haveCustomColor =
customTextColor ||
customLinkColor ||
customVisitedColor ||
customActiveColor ||
customBackgroundColor;
// Set default color explicitly for any that are missing
if (!customTextColor) customTextColor = defaultTextColor;
if (!customLinkColor) customLinkColor = defaultLinkColor;
if (!customActiveColor) customActiveColor = defaultActiveColor;
if (!customVisitedColor) customVisitedColor = defaultVisitedColor;
if (!customBackgroundColor) customBackgroundColor = defaultBackgroundColor;
if (haveCustomColor)
{
// If any colors are set, then check the "Custom" radio button
dialog.CustomColorsRadio.checked = true;
UseCustomColors();
@ -214,7 +207,7 @@ function GetColorAndUpdate(ColorWellID)
if (colorObj.Cancel)
return;
color = "";
var color = "";
switch( ColorWellID )
{
case "textCW":
@ -259,7 +252,7 @@ function SetColorPreview(ColorWellID, color)
break;
case "backgroundCW":
// Must combine background color and image style values
styleValue = backColorStyle+color;
var styleValue = backColorStyle+color;
if (backgroundImage.length > 0)
styleValue += ";"+backImageStyle+backgroundImage+");";
@ -275,6 +268,11 @@ function UseCustomColors()
SetElementEnabledById("ActiveLinkButton", true);
SetElementEnabledById("VisitedLinkButton", true);
SetElementEnabledById("BackgroundButton", true);
SetElementEnabledById("Text", true);
SetElementEnabledById("Link", true);
SetElementEnabledById("Active", true);
SetElementEnabledById("Visited", true);
SetElementEnabledById("Background", true);
SetColorPreview("textCW", customTextColor);
SetColorPreview("linkCW", customLinkColor);
@ -304,12 +302,17 @@ function UseDefaultColors()
setColorWell("visitedCW", "");
setColorWell("backgroundCW", "");
// Disable color buttons
// Disable color buttons and labels
SetElementEnabledById("TextButton", false);
SetElementEnabledById("LinkButton", false);
SetElementEnabledById("ActiveLinkButton", false);
SetElementEnabledById("VisitedLinkButton", false);
SetElementEnabledById("BackgroundButton", false);
SetElementEnabledById("Text", false);
SetElementEnabledById("Link", false);
SetElementEnabledById("Active", false);
SetElementEnabledById("Visited", false);
SetElementEnabledById("Background", false);
}
function chooseFile()
@ -326,6 +329,7 @@ function chooseFile()
function ChangeBackgroundImage()
{
dump("***ChangeBackgroundImage\n");
// Don't show error message for image while user is typing
ValidateAndPreviewImage(false);
}
@ -336,7 +340,7 @@ function ValidateAndPreviewImage(ShowErrorMessage)
var styleValue = backColorStyle+dialog.backgroundColor+";";
var image = dialog.BackgroundImageInput.value.trimString();
if (image.length > 0)
if (image)
{
if (IsValidImage(image))
{
@ -358,6 +362,8 @@ function ValidateAndPreviewImage(ShowErrorMessage)
}
else backgroundImage = null;
dump("ValidateAndPreviewImage: styleValue ="+styleValue+"\n");
// Set style on preview (removes image if not valid)
dialog.ColorPreview.setAttribute(styleStr, styleValue);

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

@ -62,7 +62,7 @@
<columns><column/><column/></columns>
<rows>
<row>
<text class="label" value="&normalText.label;&colon.character;" />
<text class="label" id="Text" value="&normalText.label;&colon.character;" />
<stack>
<box autostretch="never" valign="middle">
<spring id="textCW" class="color-well"/>
@ -73,7 +73,7 @@
</stack>
</row>
<row>
<text class="label" value="&linkText.label;&colon.character;" />
<text class="label" id="Link" value="&linkText.label;&colon.character;" />
<stack>
<box autostretch="never" valign="middle">
<spring id="linkCW" class="color-well"/>
@ -83,7 +83,7 @@
</stack>
</row>
<row>
<text class="label" value="&activeLinkText.label;&colon.character;" />
<text class="label" id="Active" value="&activeLinkText.label;&colon.character;" />
<stack>
<box autostretch="never" valign="middle">
<spring id="activeCW" class="color-well"/>
@ -93,7 +93,7 @@
</stack>
</row>
<row>
<text class="label" value ="&visitedLinkText.label;&colon.character;" />
<text class="label" id="Visited" value ="&visitedLinkText.label;&colon.character;" />
<stack>
<box autostretch="never" valign="middle">
<spring id="visitedCW" class="color-well"/>
@ -103,7 +103,7 @@
</stack>
</row>
<row>
<text class="label" value="&background.label;" />
<text class="label" id="Background" value="&background.label;" />
<stack>
<box autostretch="never" valign="middle">
<spring id="backgroundCW" class="color-well"/>

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

@ -935,7 +935,6 @@ function SaveWindowLocation()
{
var newOffsetX = window.screenX - window.opener.screenX;
var newOffsetY = window.screenY - window.opener.screenY;
dump("*** New offsets saved: x="+newOffsetX+", y="+newOffsetY+"\n");
gLocation.setAttribute("offsetX", window.screenX - window.opener.screenX);
gLocation.setAttribute("offsetY", window.screenY - window.opener.screenY);
}

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

@ -132,7 +132,7 @@ function ValidateData()
}
// Set attributes: NOTE: These may be empty strings
borderText = TrimString(dialog.borderInput.value);
var borderText = TrimString(dialog.borderInput.value);
if (borderText)
{
// Set the other attributes on the table
@ -142,7 +142,7 @@ function ValidateData()
var maxLimit;
var isPercent = (dialog.widthPixelOrPercentMenulist.selectedIndex == 1);
widthText = TrimString(dialog.widthInput.value);
var widthText = TrimString(dialog.widthInput.value);
if (widthText.length > 0)
{
if (isPercent)
@ -161,7 +161,7 @@ function ValidateData()
}
isPercent = (dialog.heightPixelOrPercentMenulist.selectedIndex == 1);
heightText = TrimString(dialog.heightInput.value);
var heightText = TrimString(dialog.heightInput.value);
if (heightText.length > 0)
{
if (isPercent)
@ -206,7 +206,7 @@ function onOK()
tableBody.appendChild(newRow);
for (var j = 0; j < columns; j++)
{
newCell = editorShell.CreateElementWithDefaults("td");
var newCell = editorShell.CreateElementWithDefaults("td");
if (newCell)
{
newRow.appendChild(newCell);

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

@ -20,151 +20,199 @@
* Contributor(s):
*/
//Cancel() is in EdDialogCommon.js
var tagname = "TAG NAME"
var ListTypeList;
var BulletStyleList;
var BulletStyleLabel;
var StartingNumberInput;
var StartingNumberLabel;
var BulletStyleIndex = 0;
var NumberStyleIndex = 0;
var ListElement = 0;
var ListElement;
var originalListType = "";
var ListType = "";
var MixedListSelection = false;
var AdvancedEditButton;
var dialog;
// dialog initialization code
function Startup()
{
if (!InitEditorShell())
return;
dialog = new Object;
if (!dialog)
window.close();
doSetOKCancel(onOK, onCancel);
ListTypeList = document.getElementById("ListType");
BulletStyleList = document.getElementById("BulletStyle");
BulletStyleLabel = document.getElementById("BulletStyleLabel");
StartingNumberInput = document.getElementById("StartingNumber");
StartingNumberLabel = document.getElementById("StartingNumberLabel");
AdvancedEditButton = document.getElementById("AdvancedEditButton1");
dialog.ListTypeList = document.getElementById("ListType");
dialog.BulletStyleList = document.getElementById("BulletStyle");
dialog.BulletStyleLabel = document.getElementById("BulletStyleLabel");
dialog.StartingNumberInput = document.getElementById("StartingNumber");
dialog.StartingNumberLabel = document.getElementById("StartingNumberLabel");
dialog.StartExample = document.getElementById("StartExample").firstChild;
dialog.AdvancedEditButton = document.getElementById("AdvancedEditButton1");
dialog.RadioGroup = document.getElementById("RadioGroup");
dialog.ChangeAllRadio = document.getElementById("ChangeAll");
dialog.ChangeSelectedRadio = document.getElementById("ChangeSelected");
// Try to get an existing list
// Try to get an existing list(s)
var mixedObj = new Object;
ListType = editorShell.GetListState(mixedObj);
// We may have mixed list and non-list, or > 1 list type in selection
MixedListSelection = mixedObj.value;
// This gets a single list element enclosing the entire selection
ListElement = editorShell.GetSelectedElement("list");
// Get the list element at the anchor node
ListElement = editorShell.GetElementOrParentByTagName("list", null);
if (!ListElement)
{
// Get the list at the anchor node
ListElement = editorShell.GetElementOrParentByTagName("list", null);
// Remember if we have a list at anchor node, but focus node
// is not in a list or is a different type of list
if (ListElement)
MixedListSelection = true;
}
// The copy to use in AdvancedEdit
if (ListElement)
globalElement = ListElement.cloneNode(false);
//dump("List and global elements: "+ListElement+globalElement+"\n");
// Show extra options for changing entire list if we have one already.
dialog.RadioGroup.setAttribute("collapsed", ListElement ? "false" : "true");
if (ListElement)
{
// Radio button index is persistant
if (dialog.RadioGroup.getAttribute("index") == "1")
dialog.ChangeSelectedRadio.checked = true;
else
dialog.ChangeAllRadio.checked = true;
}
InitDialog();
originalListType = ListType;
ListTypeList.focus();
dialog.ListTypeList.focus();
SetWindowLocation();
}
function InitDialog()
{
// Note that if mixed, we we pay attention
// only to the anchor node's list type
// (i.e., don't confuse user with "mixed" designation)
if (ListElement)
ListType = ListElement.nodeName.toLowerCase();
else
ListType = "";
BuildBulletStyleList();
dialog.StartingNumberInput.value = "";
var type = globalElement.getAttribute("type");
var index = 0;
if (ListType == "ul")
{
if (type)
{
type = type.toLowerCase();
if (type == "circle")
index = 1;
else if (type == "square")
index = 2;
}
}
else if (ListType == "ol")
{
switch (type)
{
case "I":
index = 1;
break;
case "i":
index = 2;
break;
case "A":
index = 3;
break;
case "a":
index = 4;
break;
}
dialog.StartingNumberInput.value = globalElement.getAttribute("start");
}
dialog.BulletStyleList.selectedIndex = index;
}
function BuildBulletStyleList()
{
ClearMenulist(BulletStyleList);
var label = "";
var selectedIndex = -1;
dump("List Type: "+ListType+" globalElement: "+globalElement+"\n");
ClearMenulist(dialog.BulletStyleList);
var label;
if (ListType == "ul")
{
BulletStyleList.removeAttribute("disabled");
BulletStyleLabel.removeAttribute("disabled");
StartingNumberInput.setAttribute("disabled", "true");
StartingNumberLabel.setAttribute("disabled", "true");
dialog.BulletStyleList.removeAttribute("disabled");
dialog.BulletStyleLabel.removeAttribute("disabled");
dialog.StartingNumberInput.setAttribute("disabled", "true");
dialog.StartingNumberLabel.setAttribute("disabled", "true");
dialog.StartExample.setAttribute("disabled", "true");
label = GetString("BulletStyle");
AppendStringToMenulistById(BulletStyleList,"SolidCircle");
AppendStringToMenulistById(BulletStyleList,"OpenCircle");
AppendStringToMenulistById(BulletStyleList,"SolidSquare");
AppendStringToMenulistById(dialog.BulletStyleList,"SolidCircle");
AppendStringToMenulistById(dialog.BulletStyleList,"OpenCircle");
AppendStringToMenulistById(dialog.BulletStyleList,"SolidSquare");
BulletStyleList.selectedIndex = BulletStyleIndex;
ListTypeList.selectedIndex = 1;
dialog.BulletStyleList.selectedIndex = BulletStyleIndex;
dialog.ListTypeList.selectedIndex = 1;
}
else if (ListType == "ol")
{
BulletStyleList.removeAttribute("disabled");
BulletStyleLabel.removeAttribute("disabled");
StartingNumberInput.removeAttribute("disabled");
StartingNumberLabel.removeAttribute("disabled");
dialog.BulletStyleList.removeAttribute("disabled");
dialog.BulletStyleLabel.removeAttribute("disabled");
dialog.StartingNumberInput.removeAttribute("disabled");
dialog.StartingNumberLabel.removeAttribute("disabled");
dialog.StartExample.removeAttribute("disabled");
label = GetString("NumberStyle");
AppendStringToMenulistById(BulletStyleList,"Style_1");
AppendStringToMenulistById(BulletStyleList,"Style_I");
AppendStringToMenulistById(BulletStyleList,"Style_i");
AppendStringToMenulistById(BulletStyleList,"Style_A");
AppendStringToMenulistById(BulletStyleList,"Style_a");
AppendStringToMenulistById(dialog.BulletStyleList,"Style_1");
AppendStringToMenulistById(dialog.BulletStyleList,"Style_I");
AppendStringToMenulistById(dialog.BulletStyleList,"Style_i");
AppendStringToMenulistById(dialog.BulletStyleList,"Style_A");
AppendStringToMenulistById(dialog.BulletStyleList,"Style_a");
BulletStyleList.selectedIndex = NumberStyleIndex;
ListTypeList.selectedIndex = 2;
dialog.BulletStyleList.selectedIndex = NumberStyleIndex;
dialog.ListTypeList.selectedIndex = 2;
}
else
{
BulletStyleList.setAttribute("disabled", "true");
BulletStyleLabel.setAttribute("disabled", "true");
StartingNumberInput.setAttribute("disabled", "true");
StartingNumberLabel.setAttribute("disabled", "true");
dialog.BulletStyleList.setAttribute("disabled", "true");
dialog.BulletStyleLabel.setAttribute("disabled", "true");
dialog.StartingNumberInput.setAttribute("disabled", "true");
dialog.StartingNumberLabel.setAttribute("disabled", "true");
if (ListType == "dl")
ListTypeList.selectedIndex = 3;
dialog.ListTypeList.selectedIndex = 3;
else
ListTypeList.selectedIndex = 0;
{
// No list or mixed selection that starts outside a list
// ??? Setting index to 0 fails to draw menulist correctly!
dialog.ListTypeList.selectedIndex = 1;
dialog.ListTypeList.selectedIndex = 0;
}
}
// Disable advanced edit button if changing to "normal"
if (ListType == "")
AdvancedEditButton.setAttribute("disabled","true");
if (ListType)
dialog.AdvancedEditButton.removeAttribute("disabled");
else
AdvancedEditButton.removeAttribute("disabled");
dialog.AdvancedEditButton.setAttribute("disabled","true");
if (label)
BulletStyleLabel.setAttribute("value",label);
dialog.BulletStyleLabel.setAttribute("value",label);
}
function SelectListType()
{
//dump(ListTypeList+"ListTypeList\n");
switch (ListTypeList.selectedIndex)
var NewType;
switch (dialog.ListTypeList.selectedIndex)
{
case 1:
NewType = "ul";
break;
case 2:
NewType = "ol";
SetTextfieldFocus(dialog.StartingNumberInput);
break;
case 3:
NewType = "dl";
@ -178,7 +226,7 @@ function SelectListType()
ListType = NewType;
// Create a newlist object for Advanced Editing
if (ListType != "")
if (ListType)
globalElement = editorShell.CreateElementWithDefaults(ListType);
BuildBulletStyleList();
@ -190,41 +238,15 @@ function SelectBulletStyle()
// Save the selected index so when user changes
// list style, restore index to associated list
if (ListType == "ul")
BulletStyleIndex = BulletStyleList.selectedIndex;
BulletStyleIndex = dialog.BulletStyleList.selectedIndex;
else if (ListType == "ol")
{
if (NumberStyleIndex != BulletStyleList.selectedIndex)
StartingNumberInput.value = "";
NumberStyleIndex = BulletStyleList.selectedIndex;
}
}
function FilterStartNumber()
{
var stringIn = StartingNumberInput.value.trimString();
if (stringIn.length > 0)
{
switch (NumberStyleIndex)
var index = dialog.BulletStyleList.selectedIndex;
if (NumberStyleIndex != index)
{
case 0:
// Allow only integers
stringIn = stringIn.replace(/\D+/g,"");
break;
case 1: // "I";
stringIn = stringIn.toUpperCase().replace(/[^ICDVXL]+/g,"");
break;
case 2: // "i";
stringIn = stringIn.toLowerCase().replace(/[^icdvxl]+/g,"");
break;
case 3: // "A";
stringIn.toUpperCase();
break;
case 4: // "a";
stringIn.toLowerCase();
break;
NumberStyleIndex = index;
SetTextfieldFocus(dialog.StartingNumberInput);
}
if (!stringIn) stringIn = "";
StartingNumberInput.value = stringIn;
}
}
@ -232,13 +254,12 @@ function ValidateData()
{
var type = 0;
// globalElement should already be of the correct type
//dump("Global List element="+globalElement+" should be type: "+ListType+"\n");
if (globalElement)
{
if (ListType == "ul")
{
switch (BulletStyleList.selectedIndex)
switch (dialog.BulletStyleList.selectedIndex)
{
// Index 0 = "disc", the default, so we don't set it explicitly
case 1:
@ -253,9 +274,10 @@ function ValidateData()
else
globalElement.removeAttribute("type");
} else if (ListType == "ol")
}
else if (ListType == "ol")
{
switch (BulletStyleList.selectedIndex)
switch (dialog.BulletStyleList.selectedIndex)
{
// Index 0 = "1", the default, so we don't set it explicitly
case 1:
@ -276,7 +298,7 @@ function ValidateData()
else
globalElement.removeAttribute("type");
var startingNumber = StartingNumberInput.value.trimString();
var startingNumber = dialog.StartingNumberInput.value.trimString();
if (startingNumber)
globalElement.setAttribute("start",startingNumber);
else
@ -293,22 +315,38 @@ function onOK()
// Coalesce into one undo transaction
editorShell.BeginBatchChanges();
// We may need to create new list element(s)
// or change to a different list type.
if (!ListElement || MixedListSelection || ListType != originalListType)
// Remember which radio button was checked
if (ListElement)
dialog.RadioGroup.setAttribute("index", dialog.ChangeAllRadio.checked ? "0" : "1");
var changeList;
if (ListElement && dialog.ChangeAllRadio.checked)
{
// Select the entire list element so all items are
// changed to the requested new type
editorShell.SelectElement(ListElement);
changeList = true;
}
else
changeList = MixedListSelection || ListType != originalListType;
if (changeList)
{
editorShell.MakeOrChangeList(ListType);
// Get the new list created:
//ListElement = editorShell.GetSelectedElement("list");
ListElement = editorShell.GetElementOrParentByTagName(ListType, null);
}
// Set the list attributes
// Set the new list attributes
if (ListElement)
editorShell.CloneAttributes(ListElement, globalElement);
editorShell.EndBatchChanges();
SaveWindowLocation();
return true;
}
return false;

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

@ -43,29 +43,35 @@
<broadcaster id="args" value=""/>
<spring id="location" offsetY="50" persist="offsetX offsetY"/>
<text class="label" value="&ListType.label;"/>
<menulist flex="1" id="ListType" oncommand="SelectListType()">
<menupopup>
<menuitem value="&none.value;"/>
<menuitem value="&bulletList.value;"/>
<menuitem value="&numberList.value;"/>
<menuitem value="&definitionList.value;"/>
</menupopup>
</menulist>
<titledbox orient="vertical" flex="1"><title value="&ListType.label;"/>
<menulist flex="1" id="ListType" oncommand="SelectListType()">
<menupopup>
<menuitem value="&none.value;"/>
<menuitem value="&bulletList.value;"/>
<menuitem value="&numberList.value;"/>
<menuitem value="&definitionList.value;"/>
</menupopup>
</menulist>
<radiogroup id="RadioGroup" orient="vertical" index="0" persist="index">
<radio group="RadioGroup" id="ChangeAll" value="&changeEntireListRadio.label;"/>
<radio group="RadioGroup" id="ChangeSelected" value="&changeSelectedRadio.label;"/>
</radiogroup>
</titledbox>
<spring class="spacer"/>
<!-- message text and list items are set in JS
text value should be identical to string with id=BulletStyle in editor.properties
-->
<text class="label" id="BulletStyleLabel" value="&bulletStyle.label;"/>
<menulist flex="1" class="MinWidth10em" id="BulletStyle" oncommand="SelectBulletStyle()"/>
<spring class="spacer"/>
<box>
<text class="label" id="StartingNumberLabel" value="&startingNumber.label;"/>
<titledbox orient="vertical" flex="1"><title id="BulletStyleLabel" value="&bulletStyle.label;"/>
<menulist flex="1" class="MinWidth10em" id="BulletStyle" oncommand="SelectBulletStyle()"/>
<spring class="spacer"/>
<textfield class="narrow" id="StartingNumber" onkeyup="FilterStartNumber()"/>
<spring/>
</box>
<box>
<text class="label" id="StartingNumberLabel" value="&startingNumber.label;"/>
<textfield class="narrow" id="StartingNumber" onkeyup="forceInteger(this.id)"/>
<spring/>
</box>
<html id="StartExample" class="wrap" flex="1" style="width: 1em">&startingHelp.label;</html>
</titledbox>
<!-- from EdDialogOverlay -->
<box id="AdvancedEdit"/>
<!-- from global dialogOverlay -->

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

@ -569,8 +569,6 @@ function MoveSelection(forward)
}
// Get the cell at the new location
//dump("*** Move from row="+curRowIndex+", col="+curColIndex+" to NewRow="+newRowIndex+", NewCol="+newColIndex+"\n");
do {
if (!GetCellData(newRowIndex, newColIndex))
{

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

@ -24,11 +24,14 @@
<!-- Window title -->
<!ENTITY windowTitle.label "List Properties">
<!ENTITY ListType.label "List Type:">
<!ENTITY ListType.label "List Type">
<!ENTITY bulletStyle.label "Bullet Style:">
<!ENTITY startingNumber.label "Starting number:">
<!ENTITY none.value "None (normal paragraph)">
<!ENTITY startingNumber.label "Start at:">
<!ENTITY startingHelp.label "E.g.: use &quot;2&quot; to start at<html:br/>2, II, ii, B, or b">
<!ENTITY none.value "None">
<!ENTITY bulletList.value "Bullet (Unnumbered) List">
<!ENTITY numberList.value "Numbered List">
<!ENTITY definitionList.value "Definition List">
<!ENTITY mixedListType.value "(mixed types)">
<!ENTITY changeListMsg.label "When changing list type:">
<!ENTITY changeEntireListRadio.label "Change entire list">
<!ENTITY changeSelectedRadio.label "Change just selected items">