зеркало из https://github.com/mozilla/gecko-dev.git
Make Publish command more accessible, b=146522, r=akkana/brade, sr=dveditz
This commit is contained in:
Родитель
3d7fc0af50
Коммит
40d92fcd7b
|
@ -340,10 +340,13 @@ var nsSaveCommand =
|
|||
{
|
||||
isCommandEnabled: function(aCommand, dummy)
|
||||
{
|
||||
// Always allow saving when editing a remote document,
|
||||
// otherwise the document modified state would prevent that
|
||||
// when you first open a remote file.
|
||||
var docUrl = GetDocumentUrl();
|
||||
return window.editorShell && window.editorShell.documentEditable &&
|
||||
(window.editorShell.documentModified ||
|
||||
IsUrlAboutBlank(GetDocumentUrl()) ||
|
||||
window.gHTMLSourceChanged);
|
||||
(window.editorShell.documentModified || window.gHTMLSourceChanged ||
|
||||
IsUrlAboutBlank(docUrl) || GetScheme(docUrl) != "file");
|
||||
},
|
||||
|
||||
doCommand: function(aCommand)
|
||||
|
@ -351,18 +354,8 @@ var nsSaveCommand =
|
|||
var result = false;
|
||||
if (window.editorShell)
|
||||
{
|
||||
// XXX Switching keybinding from Save to Publish isn't working now :(
|
||||
// so do publishing if editing remote url
|
||||
var docUrl = GetDocumentUrl();
|
||||
var scheme = GetScheme(docUrl);
|
||||
if (scheme && scheme != "file")
|
||||
{
|
||||
goDoCommand("cmd_publish");
|
||||
return true;
|
||||
}
|
||||
|
||||
FinishHTMLSource();
|
||||
result = SaveDocument(IsUrlAboutBlank(docUrl), false, editorShell.contentsMIMEType);
|
||||
result = SaveDocument(IsUrlAboutBlank(GetDocumentUrl()), false, editorShell.contentsMIMEType);
|
||||
window._content.focus();
|
||||
}
|
||||
return result;
|
||||
|
@ -1401,12 +1394,9 @@ function SaveDocument(aSaveAs, aSaveCopy, aMimeType)
|
|||
var urlstring = GetDocumentUrl();
|
||||
var mustShowFileDialog = (aSaveAs || IsUrlAboutBlank(urlstring) || (urlstring == ""));
|
||||
|
||||
// If not doing "Save As" and editing a remote URL, do publishing instead
|
||||
// If editing a remote URL, force SaveAs dialog
|
||||
if (!mustShowFileDialog && GetScheme(urlstring) != "file")
|
||||
{
|
||||
goDoCommand("cmd_publish");
|
||||
return true;
|
||||
}
|
||||
mustShowFileDialog = true;
|
||||
|
||||
var replacing = !aSaveAs;
|
||||
var titleChanged = false;
|
||||
|
@ -1716,61 +1706,11 @@ function GetDocUrlFromPublishData(publishData)
|
|||
return url;
|
||||
}
|
||||
|
||||
// Depending on editing local vs. remote files:
|
||||
// * Switch the "Save" and "Publish" buttons on toolbars,
|
||||
// * Shift accel+S keybinding to Save or Publish commands
|
||||
// Note: A new, unsaved file is treated as a local file
|
||||
// (XXX Have a pref to treat as remote for user's who mostly edit remote?)
|
||||
function SetSaveAndPublishUI(urlstring)
|
||||
{
|
||||
// Associate the "save" keybinding with Save for local files,
|
||||
// or with Publish for remote files
|
||||
var scheme = GetScheme(urlstring);
|
||||
var menuItem1;
|
||||
var menuItem2;
|
||||
var saveButton = document.getElementById("saveButton");
|
||||
var publishButton = document.getElementById("publishButton");
|
||||
var command;
|
||||
|
||||
if (!scheme || scheme == "file")
|
||||
{
|
||||
// Editing a new or local file
|
||||
menuItem1 = document.getElementById("publishMenuitem");
|
||||
menuItem2 = document.getElementById("saveMenuitem");
|
||||
command = "cmd_save";
|
||||
|
||||
// Hide "Publish". Show "Save" toolbar and menu items
|
||||
if (publishButton) publishButton.setAttribute("hidden", "true");
|
||||
if (saveButton) saveButton.removeAttribute("hidden");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Editing a remote file
|
||||
menuItem1 = document.getElementById("saveMenuitem");
|
||||
menuItem2 = document.getElementById("publishMenuitem");
|
||||
command = "cmd_publish";
|
||||
|
||||
// Hide "Save", show "Publish" toolbar and menuitems
|
||||
if (saveButton) saveButton.setAttribute("hidden", "true");
|
||||
if (publishButton) publishButton.removeAttribute("hidden");
|
||||
}
|
||||
|
||||
// Use this to hide "Save" menuitem if editing remote, Hide "Publish" if editing local
|
||||
// menuItem1.setAttribute("hidden", "true");
|
||||
// menuItem2.removeAttribute("hidden");
|
||||
|
||||
var key = document.getElementById("savekb");
|
||||
if (key && command)
|
||||
key.setAttribute("observes", command);
|
||||
|
||||
if (menuItem1 && menuItem2)
|
||||
{
|
||||
menuItem1.removeAttribute("key");
|
||||
menuItem2.setAttribute("key","savekb");
|
||||
}
|
||||
|
||||
// Be sure enabled state of toolbar button is correct
|
||||
goUpdateCommand(command);
|
||||
// Be sure enabled state of toolbar buttons are correct
|
||||
goUpdateCommand("cmd_save");
|
||||
goUpdateCommand("cmd_publish");
|
||||
}
|
||||
|
||||
function SetDocumentEditable(isDocEditable)
|
||||
|
|
|
@ -176,10 +176,10 @@
|
|||
<toolbarbutton id="spellingButton"/>
|
||||
<toolbarseparator class="toolbarseparator-primary"/>
|
||||
<toolbarbutton id="imageButton"/>
|
||||
<toolbarbutton id="hlineButton"/>
|
||||
<toolbarbutton id="tableButton"/>
|
||||
<toolbarbutton id="linkButton"/>
|
||||
<toolbarbutton id="namedAnchorButton"/>
|
||||
<toolbarbutton id="namedAnchorButton" hidden="true"/>
|
||||
<toolbarbutton id="hlineButton" hidden="true"/>
|
||||
<spacer flex="1"/>
|
||||
<hbox id="throbber-box" align="center">
|
||||
<button id="navigator-throbber" oncommand="goClickThrobber('editor.throbber.url')" tooltiptext="&throbber.tooltip;">
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
|
||||
<key id="openeditorkb" key="&fileopen.keybinding;" observes="cmd_open" modifiers="accel"/>
|
||||
<key id="openremoteeditorkb" key="&fileopenremote.keybinding;" observes="cmd_openRemote" modifiers="accel,shift"/>
|
||||
<key id="savekb" key="&filesave.keybinding;" observes="cmd_save" modifiers="accel"/>
|
||||
<key id="savekb" key="&filesave.keybinding;" observes="cmd_save" modifiers="accel"/>
|
||||
<key id="publishkb" key="&filesave.keybinding;" observes="cmd_publish" modifiers="accel,shift"/>
|
||||
<key id="closekb" key="&fileclose.keybinding;" observes="cmd_close" modifiers="accel"/>
|
||||
<key id="printkb" key="&fileprint.keybinding;" observes="cmd_print" modifiers="accel"/>
|
||||
<key id="key_quit"/>
|
||||
|
@ -314,12 +315,13 @@
|
|||
<menuitem id="saveMenuitem" accesskey="&filesave.accesskey;" key="savekb" observes="cmd_save"/>
|
||||
<menuitem accesskey="&filesaveas.accesskey;" observes="cmd_saveAs"/>
|
||||
<menuitem accesskey="&filesaveascharset.accesskey;" observes="cmd_saveAsCharset"/>
|
||||
<menuitem id="publishMenuitem" accesskey="&publishcmd.accesskey;" observes="cmd_publish"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="publishMenuitem" accesskey="&publishcmd.accesskey;" key="publishkb" observes="cmd_publish"/>
|
||||
<menuitem accesskey="&publishas.accesskey;" observes="cmd_publishAs"/>
|
||||
<menuseparator/>
|
||||
<menuitem accesskey="&fileexporttotext.accesskey;" observes="cmd_exportToText" id="fileExportToText"/>
|
||||
<menuitem accesskey="&filerevert.accesskey;" observes="cmd_revert"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="fileExportToText" accesskey="&fileexporttotext.accesskey;" observes="cmd_exportToText"/>
|
||||
<menuitem id="previewInBrowser" label="&previewCmd.label;" accesskey="&filepreview.accesskey;" observes="cmd_preview"/>
|
||||
<!-- menuitem id="menu_SendPage" is merged here from mailEditorOverlay.xul,
|
||||
where "position" is assumed to be just after 'previewInBrowser' -->
|
||||
|
@ -386,12 +388,12 @@
|
|||
|
||||
<!-- Insert menu -->
|
||||
<menu id="insertMenu" label="&insertMenu.label;" accesskey="&insertmenu.accesskey;">
|
||||
<menupopup>
|
||||
<menupopup id="insertMenuPopup">
|
||||
<menuitem accesskey="&insertimage.accesskey;" observes="cmd_image" label="&insertImageCmd.label;"/>
|
||||
<menuitem accesskey="&inserttable.accesskey;" observes="cmd_InsertTable" label="&insertTableCmd.label;"/>
|
||||
<menuitem accesskey="&insertlink.accesskey;" observes="cmd_link" label="&insertLinkCmd.label;" key="insertlinkkb"/>
|
||||
<menuitem accesskey="&insertanchor.accesskey;" observes="cmd_anchor" label="&insertAnchorCmd.label;"/>
|
||||
<menuitem accesskey="&insertimage.accesskey;" observes="cmd_image" label="&insertImageCmd.label;"/>
|
||||
<menuitem accesskey="&inserthline.accesskey;" observes="cmd_hline" label="&insertHLineCmd.label;"/>
|
||||
<menuitem accesskey="&inserttable.accesskey;" observes="cmd_InsertTable" label="&insertTableCmd.label;"/>
|
||||
<menuitem accesskey="&HTMLSourceMode.accesskey;" observes="cmd_insertHTML" key="inserthtmlkb"/>
|
||||
<menuitem accesskey="&insertchars.accesskey;" observes="cmd_insertChars" />
|
||||
<menuseparator/>
|
||||
|
@ -673,7 +675,7 @@
|
|||
tooltiptext="&saveToolbarCmd.tooltip;"/>
|
||||
<toolbarbutton id="publishButton" class="toolbarbutton-1"
|
||||
observes="cmd_publish"
|
||||
tooltiptext="&publishToolbarCmd.tooltip;" hidden="true"/>
|
||||
tooltiptext="&publishToolbarCmd.tooltip;"/>
|
||||
<toolbarbutton id="previewButton" class="toolbarbutton-1"
|
||||
label="&previewToolbarCmd.label;" observes="cmd_preview"
|
||||
tooltiptext="&previewToolbarCmd.tooltip;"/>
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
<!ENTITY fileopenremote.keybinding "l">
|
||||
<!ENTITY fileRecentMenu.label "Recent Pages">
|
||||
<!ENTITY filerecentmenu.accesskey "r">
|
||||
<!ENTITY fileRevert.label "Revert to Last Saved">
|
||||
<!ENTITY filerevert.accesskey "d">
|
||||
<!ENTITY fileRevert.label "Revert">
|
||||
<!ENTITY filerevert.accesskey "v">
|
||||
<!ENTITY saveCmd.label "Save">
|
||||
<!ENTITY filesave.accesskey "s">
|
||||
<!ENTITY filesave.keybinding "s">
|
||||
|
|
Загрузка…
Ссылка в новой задаче