Strings and menu items for 'Revert' and 'Recent pages'. Preliminary UI for HTML Source editor (not activated).

This commit is contained in:
cmanske%netscape.com 2000-05-03 05:17:43 +00:00
parent e22440d244
commit eec2372c22
4 changed files with 119 additions and 15 deletions

View File

@ -402,7 +402,7 @@ var nsInsertHTMLCommand =
},
doCommand: function(aCommand)
{
window.openDialog("chrome://editor/content/EdInsSrc.xul","_blank", "chrome,close,titlebar,modal,resizeable", "");
window.openDialog("chrome://editor/content/EdInsSrc.xul","_blank", "chrome,close,titlebar,modal,resizable", "");
}
};

View File

@ -36,11 +36,14 @@ var DisplayModePreview = 0;
var DisplayModeNormal = 1;
var DisplayModeAllTags = 2;
var DisplayModeSource = 3;
var PreviousNonSourceDisplayMode = 1;
var EditorDisplayMode = 1; // Normal Editor mode
var WebCompose = false; // Set true for Web Composer, leave false for Messenger Composer
var docWasModified = false; // Check if clean document, if clean then unload when user "Opens"
var contentWindow = 0;
var sourceContentWindow = 0;
var ContentWindowDeck;
var EditorMenuAndToolbars;
var gPrefs;
// These must be kept in synch with the XUL <options> lists
@ -122,6 +125,10 @@ function EditorStartup(editorType, editorElement)
{
contentWindow = window.content;
sourceContentWindow = document.getElementById("HTMLSourceWindow");
// XUL elements we use when switching from normal editor to edit source
ContentWindowDeck = document.getElementById("ContentWindowDeck");
EditorMenuAndToolbars = document.getElementById("EditorMenuAndToolbars");
// store the editor shell in the window, so that child windows can get to it.
editorShell = editorElement.editorShell;
@ -881,11 +888,42 @@ function EditorAlign(commandID, alignType)
goDoCommand(commandID);
}
function EditorSetDisplayMode(mode)
function SetEditMode(mode)
{
SetDisplayMode(mode);
if (mode == DisplayModeSource)
{
// Get the current doc and output into the SourceWindow
sourceContentWindow.value = "this is sample text. We will insert current page source here";
contentWindow.blur();
sourceContentWindow.focus();
}
else
{
// Get the Source Window contents and paste into the HTML editor
contentWindow.focus();
}
}
function CancelSourceEditing()
{
// Empty the source window
sourceContentWindow.value="";
SetDisplayMode(PreviousNonSourceDisplayMode);
}
function SetDisplayMode(mode)
{
EditorDisplayMode = mode;
// Save the last non-source mode so we can cancel source editing easily
if (mode != DisplayModeSource)
PreviousNonSourceDisplayMode = mode;
// Editor does the style sheet loading/unloading
// Editorshell does the style sheet loading/unloading
editorShell.SetDisplayMode(mode);
// Set the UI states
@ -895,11 +933,38 @@ function EditorSetDisplayMode(mode)
var HTMLButton = document.getElementById("SourceModeButton");
if (HTMLButton)
HTMLButton.setAttribute("selected", Number(mode == DisplayModeSource));
dump(sourceContentWindow+"=SourceWindow\n");
if (mode == DisplayModeSource)
{
// Switch to the sourceWindow (second in the deck)
ContentWindowDeck.setAttribute("index","1");
// Get the current doc and output into the SourceWindow
// Hide normal chrome
EditorMenuAndToolbars.setAttribute("style", "display:none");
// THIS DOESN'T WORK!?
//EditorMenuAndToolbars.setAttribute("collapsed", "true");
// TODO: WE MUST DISABLE ALL KEYBOARD COMMANDS!
contentWindow.blur();
sourceContentWindow.focus();
}
else
{
// Switch to the normal editor (first in the deck)
ContentWindowDeck.setAttribute("index","0");
// Show normal chrome
EditorMenuAndToolbars.setAttribute("style", "display:inherit");
//EditorMenuAndToolbars.removeAttribute("collapsed");
// TODO: WE MUST ENABLE ALL KEYBOARD COMMANDS!
contentWindow.focus();
}
}
function EditorToggleParagraphMarks()
@ -964,6 +1029,23 @@ function EditorInitEditMenu()
// We will be modifying the Paste menuitem in the future
}
function InitRecentFilesMenu()
{
//Build submenu of
var popup = document.getElementById("menupopup_RecentFiles");
if (popup)
{
// Delete existing menu
while (popup.firstChild)
popup.removeChild(popup.firstChild);
// Rebuild from values in prefs (use gPrefs)
// but be sure to exclude the current page from the list!
//TODO: Kathy will do this
}
}
function EditorInitFormatMenu()
{
// Set the string for the background color menu item
@ -1549,8 +1631,11 @@ function HideInapplicableUIElements()
}
function onEditorFocus()
{
dump("onEditorFocus called\n");
}
//-----------------------------------------------------------------------------------
function GetPrefsService()
{
// Store the prefs object

View File

@ -86,6 +86,7 @@
<!-- keys are appended from the overlay -->
<keyset id="defaultKeySet"/>
<box orient="vertical" id="EditorMenuAndToolbars" collapsed="true">
<menubar id="main-menubar" class="chromeclass-menubar">
<menu id="fileMenu"/>
<menu id="editMenu"/>
@ -184,6 +185,8 @@
<spring flex="1"/>
</toolbar>
</toolbox>
</box> <!-- EditorMenuAndToolbars -->
<!-- sidebar/toolbar/content/status -->
<box id="sidebar-parent" flex="1">
@ -194,12 +197,19 @@
<box id="appcontent" orient="vertical" flex="1">
<deck id="ContentWindowDeck" index="0" flex="1">
<editor type="content-primary" id="content-frame" src="about:blank" flex="1"/>
<!-- DAMN! This worked for a few minutes on 5/1/00, but after updating tree, it crashes creating the textarea editor! -->
<!-- <textfield id="HTMLSourceWindow" multiline="true" rows="2" flex="1" style="width:10em; height:10em;"/> -->
<box orient="vertical" flex="1">
<box id="source-editor-label" autostretch="never" valign="middle">
<text class="label bold" value="&sourceEditor.label;"/>
<spring flex="1"/>
<button value="&sourceEditorCancelButton.label;" oncommand="CancelSourceEditing()"/>
</box>
<textfield class="source-editor" id="HTMLSourceWindow" multiline="true" rows="1"
flex="1" style="width:1em; height:1em;"/>
</box>
</deck>
<toolbar id="EditModeToolbar" chromeclass="extrachrome" collapsed="true" persist="collapsed">
<!-- TODO: Set collapsed="true" so default is to not show the editmode toolbar -->
<toolbar id="EditModeToolbar" chromeclass="extrachrome" persist="collapsed">
<text class="margin-left-right" value="&editMode.label;"/>
<!-- From editorOverlay.xul -->
<text id="NormalModeButton"/>
@ -229,5 +239,5 @@
</box><!-- status-bar -->
</box> <!-- appcontent -->
</box><!-- sidebar-parent -->
<toolbar id="taskbar" chromeclass="extrachrome" />
<toolbar id="taskbar" chromeclass="extrachrome" style="min-width: 1px" />
</window>

View File

@ -226,16 +226,25 @@
<menu id="menu_New" value="&newMenu.label;" accesskey="&newMenu.accesskey;">
<menupopup id="menu_NewPopup">
<!-- From globalOverlay.xul -->
<!-- Probably won't implement these
<menuitem id="menu_newEditorTemplate" observes="cmd_newEditorTemplate"/>
<menuitem id="menu_newEditorDraft" observes="cmd_newEditorDraft"/>
<menuseparator/>
-->
<menuitem id="menu_newNavigator" observes="cmd_newNavigator"/>
<menuitem id="menu_newMessage" observes="cmd_newMessage"/>
<menuitem id="menu_newCard" observes="cmd_newCard"/>
</menupopup>
</menu>
<menuitem accesskey="&fileopenremote.accesskey;" key="openremoteeditorkb" observes="cmd_openRemote"/>
<menuitem accesskey="&fileopen.accesskey;" key="openeditorkb" observes="cmd_open" value="&openFileCmd.label;"/>
<menuitem accesskey="&fileopen.accesskey;" key="openeditorkb" observes="cmd_open" value="&openFileCmd.label;"/>
<menu accesskey="&filerecentmenu.accesskey;" value="&fileRecentMenu.label;" oncreate="InitRecentFilesMenu()">
<!-- Items appended at runtime -->
<menupopup id="menupopup_RecentFiles">
<menuitem value="(recent file menu)"/>
</menupopup>
</menu>
<menuitem accesskey="&filerevert.accesskey;" value="&fileRevert.label;"/>
<menuseparator />
<menuitem accesskey="&fileclose.accesskey;" key="closekb" observes="cmd_close"/>
<menuitem accesskey="&filesave.accesskey;" key="savekb" observes="cmd_save"/>
@ -788,10 +797,10 @@
<button class="button-toolbar format popup" id="AlignPopupButton" disabled="true"/>
<!-- Edit Mode toolbar -->
<text id="NormalModeButton" class="EditModeButton" selected="1" value="&normalMode.label;" onclick="EditorSetDisplayMode(1)"/>
<text id="TagModeButton" class="EditModeButton" selected="0" value="&showAllTags.label;" onclick="EditorSetDisplayMode(2)"/>
<text id="SourceModeButton" class="EditModeButton" selected="0" value="&sourceMode.label;" onclick="EditorSetDisplayMode(3)"/>
<text id="PreviewModeButton" class="EditModeButton" selected="0" value="&previewMode.label;" onclick="EditorSetDisplayMode(0)"/>
<text id="NormalModeButton" class="EditModeButton" selected="1" value="&normalMode.label;" onclick="SetEditMode(1)"/>
<text id="TagModeButton" class="EditModeButton" selected="0" value="&showAllTags.label;" onclick="SetEditMode(2)"/>
<text id="SourceModeButton" class="EditModeButton" selected="0" value="&sourceMode.label;" onclick="SetEditMode(3)"/>
<text id="PreviewModeButton" class="EditModeButton" selected="0" value="&previewMode.label;" onclick="SetEditMode(0)"/>
<!-- InsertPopupButton is used by messengercompose.xul -->
<button class="button-toolbar format popup" id="InsertPopupButton"/>