Bug 251953 - Implement / add "Print preview..." option when composing mail. r=Neil, e=mkmelin, ui-r=Paenglab
CLOSED TREE
This commit is contained in:
Родитель
8d4e7c760c
Коммит
54294140e1
|
@ -84,6 +84,80 @@ function EditorOnLoad()
|
|||
}
|
||||
}
|
||||
|
||||
function toggleAffectedChrome(aHide)
|
||||
{
|
||||
// chrome to toggle includes:
|
||||
// (*) menubar
|
||||
// (*) toolbox
|
||||
// (*) sidebar
|
||||
// (*) statusbar
|
||||
|
||||
if (!gChromeState)
|
||||
gChromeState = new Object;
|
||||
|
||||
var statusbar = document.getElementById("status-bar");
|
||||
|
||||
// sidebar states map as follows:
|
||||
// hidden => hide/show nothing
|
||||
// collapsed => hide/show only the splitter
|
||||
// shown => hide/show the splitter and the box
|
||||
if (aHide)
|
||||
{
|
||||
// going into print preview mode
|
||||
gChromeState.sidebar = SidebarGetState();
|
||||
SidebarSetState("hidden");
|
||||
|
||||
// deal with the Status Bar
|
||||
gChromeState.statusbarWasHidden = statusbar.hidden;
|
||||
statusbar.hidden = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// restoring normal mode (i.e., leaving print preview mode)
|
||||
SidebarSetState(gChromeState.sidebar);
|
||||
|
||||
// restore the Status Bar
|
||||
statusbar.hidden = gChromeState.statusbarWasHidden;
|
||||
}
|
||||
|
||||
// if we are unhiding and sidebar used to be there rebuild it
|
||||
if (!aHide && gChromeState.sidebar == "visible")
|
||||
SidebarRebuild();
|
||||
|
||||
document.getElementById("EditorToolbox").hidden = aHide;
|
||||
document.getElementById("appcontent").collapsed = aHide;
|
||||
}
|
||||
|
||||
var PrintPreviewListener = {
|
||||
getPrintPreviewBrowser: function () {
|
||||
var browser = document.getElementById("ppBrowser");
|
||||
if (!browser) {
|
||||
browser = document.createElement("browser");
|
||||
browser.setAttribute("id", "ppBrowser");
|
||||
browser.setAttribute("flex", "1");
|
||||
browser.setAttribute("disablehistory", "true");
|
||||
browser.setAttribute("disablesecurity", "true");
|
||||
browser.setAttribute("type", "content");
|
||||
document.getElementById("sidebar-parent").
|
||||
insertBefore(browser, document.getElementById("appcontent"));
|
||||
}
|
||||
return browser;
|
||||
},
|
||||
getSourceBrowser: function () {
|
||||
return GetCurrentEditorElement();
|
||||
},
|
||||
getNavToolbox: function () {
|
||||
return document.getElementById("EditorToolbox");
|
||||
},
|
||||
onEnter: function () {
|
||||
toggleAffectedChrome(true);
|
||||
},
|
||||
onExit: function () {
|
||||
document.getElementById("ppBrowser").collapsed = true;
|
||||
toggleAffectedChrome(false);
|
||||
}
|
||||
}
|
||||
|
||||
function EditorStartup(aUrl, aCharset)
|
||||
{
|
||||
gUntitledString = GetFormattedString("untitledTitle", GetNextUntitledValue());
|
||||
|
|
|
@ -482,80 +482,6 @@ function EditorSharedStartup()
|
|||
gColorObj.LastHighlightColor = "";
|
||||
}
|
||||
|
||||
function toggleAffectedChrome(aHide)
|
||||
{
|
||||
// chrome to toggle includes:
|
||||
// (*) menubar
|
||||
// (*) toolbox
|
||||
// (*) sidebar
|
||||
// (*) statusbar
|
||||
|
||||
if (!gChromeState)
|
||||
gChromeState = new Object;
|
||||
|
||||
var statusbar = document.getElementById("status-bar");
|
||||
|
||||
// sidebar states map as follows:
|
||||
// hidden => hide/show nothing
|
||||
// collapsed => hide/show only the splitter
|
||||
// shown => hide/show the splitter and the box
|
||||
if (aHide)
|
||||
{
|
||||
// going into print preview mode
|
||||
gChromeState.sidebar = SidebarGetState();
|
||||
SidebarSetState("hidden");
|
||||
|
||||
// deal with the Status Bar
|
||||
gChromeState.statusbarWasHidden = statusbar.hidden;
|
||||
statusbar.hidden = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// restoring normal mode (i.e., leaving print preview mode)
|
||||
SidebarSetState(gChromeState.sidebar);
|
||||
|
||||
// restore the Status Bar
|
||||
statusbar.hidden = gChromeState.statusbarWasHidden;
|
||||
}
|
||||
|
||||
// if we are unhiding and sidebar used to be there rebuild it
|
||||
if (!aHide && gChromeState.sidebar == "visible")
|
||||
SidebarRebuild();
|
||||
|
||||
document.getElementById("EditorToolbox").hidden = aHide;
|
||||
document.getElementById("appcontent").collapsed = aHide;
|
||||
}
|
||||
|
||||
var PrintPreviewListener = {
|
||||
getPrintPreviewBrowser: function () {
|
||||
var browser = document.getElementById("ppBrowser");
|
||||
if (!browser) {
|
||||
browser = document.createElement("browser");
|
||||
browser.setAttribute("id", "ppBrowser");
|
||||
browser.setAttribute("flex", "1");
|
||||
browser.setAttribute("disablehistory", "true");
|
||||
browser.setAttribute("disablesecurity", "true");
|
||||
browser.setAttribute("type", "content");
|
||||
document.getElementById("sidebar-parent").
|
||||
insertBefore(browser, document.getElementById("appcontent"));
|
||||
}
|
||||
return browser;
|
||||
},
|
||||
getSourceBrowser: function () {
|
||||
return GetCurrentEditorElement();
|
||||
},
|
||||
getNavToolbox: function () {
|
||||
return document.getElementById("EditorToolbox");
|
||||
},
|
||||
onEnter: function () {
|
||||
toggleAffectedChrome(true);
|
||||
},
|
||||
onExit: function () {
|
||||
document.getElementById("ppBrowser").collapsed = true;
|
||||
toggleAffectedChrome(false);
|
||||
}
|
||||
}
|
||||
|
||||
// This method is only called by Message composer when recycling a compose window
|
||||
function EditorResetFontAndColorAttributes()
|
||||
{
|
||||
|
|
|
@ -246,6 +246,110 @@ var gComposeRecyclingListener = {
|
|||
}
|
||||
};
|
||||
|
||||
var PrintPreviewListener = {
|
||||
getPrintPreviewBrowser: function() {
|
||||
var browser = document.getElementById("cppBrowser");
|
||||
if (!browser) {
|
||||
browser = document.createElement("browser");
|
||||
browser.setAttribute("id", "cppBrowser");
|
||||
browser.setAttribute("flex", "1");
|
||||
browser.setAttribute("disablehistory", "true");
|
||||
browser.setAttribute("type", "content");
|
||||
document.getElementById("headers-parent").
|
||||
insertBefore(browser, document.getElementById("appcontent"));
|
||||
}
|
||||
return browser;
|
||||
},
|
||||
getSourceBrowser: function() {
|
||||
return GetCurrentEditorElement();
|
||||
},
|
||||
getNavToolbox: function() {
|
||||
return document.getElementById("compose-toolbox");
|
||||
},
|
||||
onEnter: function() {
|
||||
toggleAffectedChrome(true);
|
||||
},
|
||||
onExit: function() {
|
||||
document.getElementById("cppBrowser").collapsed = true;
|
||||
toggleAffectedChrome(false);
|
||||
}
|
||||
}
|
||||
|
||||
function sidebar_is_hidden() {
|
||||
var sidebar_title = document.getElementById('sidebar-title-box');
|
||||
var sidebar_box = document.getElementById('sidebar-box');
|
||||
return sidebar_box.getAttribute('hidden') == 'true' ||
|
||||
sidebar_title.getAttribute('hidden') == 'true';
|
||||
}
|
||||
|
||||
function sidebar_is_collapsed() {
|
||||
var sidebar_splitter = document.getElementById('sidebar-splitter');
|
||||
return (sidebar_splitter &&
|
||||
sidebar_splitter.getAttribute('state') == 'collapsed');
|
||||
}
|
||||
|
||||
function SidebarSetState(aState) {
|
||||
document.getElementById("sidebar-box").hidden = aState != "visible";
|
||||
document.getElementById("sidebar-splitter").hidden = aState == "hidden";
|
||||
}
|
||||
|
||||
function SidebarGetState() {
|
||||
if (sidebar_is_hidden())
|
||||
return "hidden";
|
||||
if (sidebar_is_collapsed())
|
||||
return "collapsed";
|
||||
return "visible";
|
||||
}
|
||||
|
||||
function toggleAffectedChrome(aHide)
|
||||
{
|
||||
// chrome to toggle includes:
|
||||
// (*) menubar
|
||||
// (*) toolbox
|
||||
// (*) sidebar
|
||||
// (*) statusbar
|
||||
if (!gChromeState)
|
||||
gChromeState = new Object;
|
||||
|
||||
var statusbar = document.getElementById("status-bar");
|
||||
|
||||
// sidebar states map as follows:
|
||||
// hidden => hide/show nothing
|
||||
// collapsed => hide/show only the splitter
|
||||
// shown => hide/show the splitter and the box
|
||||
if (aHide)
|
||||
{
|
||||
// going into print preview mode
|
||||
document.getElementById("headers-box").hidden = true;
|
||||
gChromeState.sidebar = SidebarGetState();
|
||||
let subject = document.getElementById("msgSubject").value;
|
||||
if (subject)
|
||||
document.title = subject;
|
||||
SidebarSetState("hidden");
|
||||
|
||||
// deal with the Status Bar
|
||||
gChromeState.statusbarWasHidden = statusbar.hidden;
|
||||
statusbar.hidden = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// restoring normal mode (i.e., leaving print preview mode)
|
||||
SetComposeWindowTitle();
|
||||
SidebarSetState(gChromeState.sidebar);
|
||||
document.getElementById("headers-box").hidden = false;
|
||||
|
||||
// restore the Status Bar
|
||||
statusbar.hidden = gChromeState.statusbarWasHidden;
|
||||
}
|
||||
|
||||
// if we are unhiding and sidebar used to be there rebuild it
|
||||
if (!aHide && gChromeState.sidebar == "visible")
|
||||
SidebarRebuild();
|
||||
|
||||
document.getElementById("compose-toolbox").hidden = aHide;
|
||||
document.getElementById("appcontent").collapsed = aHide;
|
||||
}
|
||||
|
||||
var stateListener = {
|
||||
NotifyComposeFieldsReady: function() {
|
||||
ComposeFieldsReady();
|
||||
|
@ -517,6 +621,15 @@ var defaultController = {
|
|||
}
|
||||
},
|
||||
|
||||
cmd_printPreview: {
|
||||
isEnabled: function() {
|
||||
return !gWindowLocked;
|
||||
},
|
||||
doCommand: function() {
|
||||
DoCommandPrintPreview();
|
||||
}
|
||||
},
|
||||
|
||||
cmd_delete: {
|
||||
isEnabled: function() {
|
||||
let cmdDelete = document.getElementById("cmd_delete");
|
||||
|
@ -1530,6 +1643,13 @@ function DoCommandPrint()
|
|||
} catch(ex) {dump("#PRINT ERROR: " + ex + "\n");}
|
||||
}
|
||||
|
||||
function DoCommandPrintPreview()
|
||||
{
|
||||
try {
|
||||
PrintUtils.printPreview(PrintPreviewListener);
|
||||
} catch(ex) { Components.utils.reportError(ex); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Locks/Unlocks the window widgets while a message is being saved/sent.
|
||||
* Locking means to disable all possible items in the window so that
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
<command id="cmd_sendWithCheck" oncommand="goDoCommand('cmd_sendWithCheck')"/>
|
||||
<command id="cmd_sendLater" oncommand="goDoCommand('cmd_sendLater')"/>
|
||||
<command id="cmd_printSetup" oncommand="goDoCommand('cmd_printSetup')"/>
|
||||
<command id="cmd_printPreview" oncommand="goDoCommand('cmd_printPreview')"/>
|
||||
<command id="cmd_print" oncommand="goDoCommand('cmd_print')"/>
|
||||
|
||||
<!-- Edit Menu -->
|
||||
|
@ -472,6 +473,9 @@
|
|||
<menuitem label="&sendLaterCmd.label;" accesskey="&sendLaterCmd.accesskey;" key="key_sendLater" command="cmd_sendLater"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="printSetupMenuItem" label="&printSetupCmd.label;" accesskey="&printSetupCmd.accesskey;" command="cmd_printSetup"/>
|
||||
#ifndef XP_MACOSX
|
||||
<menuitem id="printPreviewMenuItem" label="&printPreviewCmd.label;" accesskey="&printPreviewCmd.accesskey;" command="cmd_printPreview"/>
|
||||
#endif
|
||||
<menuitem id="printMenuItem" label="&printCmd.label;" accesskey="&printCmd.accesskey;" key="key_print" command="cmd_print"/>
|
||||
<menuseparator id="menu_FileCloseSeparator"/>
|
||||
<menuitem id="menu_close"
|
||||
|
@ -810,7 +814,7 @@
|
|||
|
||||
<splitter id="sidebar-splitter" hidden="true"/>
|
||||
|
||||
<vbox flex="1">
|
||||
<vbox id="headers-parent" flex="1">
|
||||
<toolbox id="headers-box" class="toolbox-top" mode="icons">
|
||||
<toolbar id="MsgHeadersToolbar" persist="collapsed" flex="1"
|
||||
customizable="true" nowindowdrag="true"
|
||||
|
|
|
@ -50,6 +50,8 @@
|
|||
<!ENTITY sendLaterCmd.accesskey "L">
|
||||
<!ENTITY printSetupCmd.label "Page Setup…">
|
||||
<!ENTITY printSetupCmd.accesskey "u">
|
||||
<!ENTITY printPreviewCmd.label "Print Preview">
|
||||
<!ENTITY printPreviewCmd.accesskey "v">
|
||||
<!ENTITY printCmd.label "Print…">
|
||||
<!ENTITY printCmd.key "P">
|
||||
<!ENTITY printCmd.accesskey "P">
|
||||
|
|
Загрузка…
Ссылка в новой задаче