bug 224160: hook up Print Preview to view source.

git-svn-id: svn://10.0.0.236/trunk@148545 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
chanial%noos.fr 2003-10-30 06:02:54 +00:00
parent 3984958139
commit c76a54433c
7 changed files with 38 additions and 7 deletions

View File

@ -39,6 +39,8 @@
# #
# ***** END LICENSE BLOCK ***** */ # ***** END LICENSE BLOCK ***** */
var XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var PrintUtils = { var PrintUtils = {
showPageSetup: function () showPageSetup: function ()
@ -213,8 +215,10 @@ var PrintUtils = {
getBrowser().parentNode.insertBefore(printPreviewTB, getBrowser()); getBrowser().parentNode.insertBefore(printPreviewTB, getBrowser());
// Tab browser... // Tab browser...
if ("getStripVisibility" in getBrowser()) {
this._chromeState.hadTabStrip = getBrowser().getStripVisibility(); this._chromeState.hadTabStrip = getBrowser().getStripVisibility();
getBrowser().setStripVisibilityTo(false); getBrowser().setStripVisibilityTo(false);
}
// disable chrome shortcuts... // disable chrome shortcuts...
window.addEventListener("keypress", this.onKeyPressPP, true); window.addEventListener("keypress", this.onKeyPressPP, true);
@ -230,6 +234,7 @@ var PrintUtils = {
{ {
window.removeEventListener("keypress", this.onKeyPressPP, true); window.removeEventListener("keypress", this.onKeyPressPP, true);
if ("getStripVisibility" in getBrowser())
getBrowser().setStripVisibilityTo(this._chromeState.hadTabStrip); getBrowser().setStripVisibilityTo(this._chromeState.hadTabStrip);
var webBrowserPrint = this.getWebBrowserPrint(); var webBrowserPrint = this.getWebBrowserPrint();
webBrowserPrint.exitPrintPreview(); webBrowserPrint.exitPrintPreview();

View File

@ -40,6 +40,7 @@
#***** END LICENSE BLOCK ***** --> #***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/content/viewSource.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?> <?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?> <?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
@ -73,6 +74,7 @@
<command id="cmd_savePage" disabled="true" oncommand="ViewSourceSavePage();"/> <command id="cmd_savePage" disabled="true" oncommand="ViewSourceSavePage();"/>
<command id="cmd_print" oncommand="PrintUtils.print();"/> <command id="cmd_print" oncommand="PrintUtils.print();"/>
<command id="cmd_printpreview" oncommand="PrintUtils.printPreview(onEnterPP, onExitPP);"/>
<command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/> <command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
<command id="cmd_close" oncommand="window.close();"/> <command id="cmd_close" oncommand="window.close();"/>
<commandset id="editMenuCommands"/> <commandset id="editMenuCommands"/>
@ -106,6 +108,8 @@
label="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;"/> label="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;"/>
<menuitem command="cmd_pagesetup" <menuitem command="cmd_pagesetup"
label="&pageSetupCmd.label;" accesskey="&pageSetupCmd.accesskey;"/> label="&pageSetupCmd.label;" accesskey="&pageSetupCmd.accesskey;"/>
<menuitem command="cmd_printpreview"
label="&printPreviewCmd.label;" accesskey="&printPreviewCmd.accesskey;"/>
<menuitem key="key_print" command="cmd_print" <menuitem key="key_print" command="cmd_print"
label="&printCmd.label;" accesskey="&printCmd.accesskey;"/> label="&printCmd.label;" accesskey="&printCmd.accesskey;"/>
<menuseparator/> <menuseparator/>

View File

@ -0,0 +1,3 @@
toolbar[printpreview="true"] {
-moz-binding: url("chrome://global/content/printPreviewBindings.xml#printpreviewtoolbar");
}

View File

@ -233,6 +233,18 @@ function ViewSourceSavePage()
saveURL(window.content.location.href.substring(12), null, "SaveLinkTitle"); saveURL(window.content.location.href.substring(12), null, "SaveLinkTitle");
} }
function onEnterPP()
{
var toolbox = document.getElementById("viewSource-toolbox");
toolbox.hidden = true;
}
function onExitPP()
{
var toolbox = document.getElementById("viewSource-toolbox");
toolbox.hidden = false;
}
function ViewSourceGoToLine() function ViewSourceGoToLine()
{ {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]

View File

@ -40,6 +40,7 @@
#***** END LICENSE BLOCK ***** --> #***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://global/content/viewSource.css" type="text/css"?>
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?> <?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?> <?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
@ -71,9 +72,10 @@
<stringbundle id="findBundle" src="chrome://global/locale/finddialog.properties"/> <stringbundle id="findBundle" src="chrome://global/locale/finddialog.properties"/>
<stringbundle id="viewSourceBundle" src="chrome://global/locale/viewSource.properties"/> <stringbundle id="viewSourceBundle" src="chrome://global/locale/viewSource.properties"/>
<command id="cmd_print" oncommand="PrintUtils.print();"/>
<command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
<command id="cmd_savePage" disabled="true" oncommand="ViewSourceSavePage();"/> <command id="cmd_savePage" disabled="true" oncommand="ViewSourceSavePage();"/>
<command id="cmd_print" oncommand="PrintUtils.print();"/>
<command id="cmd_printpreview" oncommand="PrintUtils.printPreview(onEnterPP, onExitPP);"/>
<command id="cmd_pagesetup" oncommand="PrintUtils.showPageSetup();"/>
<command id="cmd_close" oncommand="window.close();"/> <command id="cmd_close" oncommand="window.close();"/>
<commandset id="editMenuCommands"/> <commandset id="editMenuCommands"/>
<command id="cmd_goToLine" oncommand="ViewSourceGoToLine();" disabled="true"/> <command id="cmd_goToLine" oncommand="ViewSourceGoToLine();" disabled="true"/>
@ -107,6 +109,8 @@
label="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;"/> label="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;"/>
<menuitem command="cmd_pagesetup" <menuitem command="cmd_pagesetup"
label="&pageSetupCmd.label;" accesskey="&pageSetupCmd.accesskey;"/> label="&pageSetupCmd.label;" accesskey="&pageSetupCmd.accesskey;"/>
<menuitem command="cmd_printpreview"
label="&printPreviewCmd.label;" accesskey="&printPreviewCmd.accesskey;"/>
<menuitem key="key_print" command="cmd_print" <menuitem key="key_print" command="cmd_print"
label="&printCmd.label;" accesskey="&printCmd.accesskey;"/> label="&printCmd.label;" accesskey="&printCmd.accesskey;"/>
<menuseparator/> <menuseparator/>

View File

@ -1,8 +1,9 @@
toolkit.jar: toolkit.jar:
* content/global/viewSource.xul (content/viewSource.xul) * content/global/viewSource.css (content/viewSource.css)
* content/global/viewSource.js (content/viewSource.js) * content/global/viewSource.js (content/viewSource.js)
* content/global/viewPartialSource.xul (content/viewPartialSource.xul) * content/global/viewSource.xul (content/viewSource.xul)
* content/global/viewPartialSource.js (content/viewPartialSource.js) * content/global/viewPartialSource.js (content/viewPartialSource.js)
* content/global/viewPartialSource.xul (content/viewPartialSource.xul)
en-US.jar: en-US.jar:
locale/en-US/global/viewSource.dtd (locale/viewSource.dtd) locale/en-US/global/viewSource.dtd (locale/viewSource.dtd)

View File

@ -15,6 +15,8 @@
<!ENTITY savePageCmd.commandkey "S"> <!ENTITY savePageCmd.commandkey "S">
<!ENTITY pageSetupCmd.label "Page Setup..."> <!ENTITY pageSetupCmd.label "Page Setup...">
<!ENTITY pageSetupCmd.accesskey "u"> <!ENTITY pageSetupCmd.accesskey "u">
<!ENTITY printPreviewCmd.label "Print Preview">
<!ENTITY printPreviewCmd.accesskey "v">
<!ENTITY printCmd.label "Print..."> <!ENTITY printCmd.label "Print...">
<!ENTITY printCmd.accesskey "P"> <!ENTITY printCmd.accesskey "P">
<!ENTITY printCmd.commandkey "P"> <!ENTITY printCmd.commandkey "P">