Bug 517805 - Move printDialog to calendar/base/content. r=philipp
--HG-- rename : calendar/resources/content/printDialog.js => calendar/base/content/dialogs/calendar-print-dialog.js rename : calendar/resources/content/printDialog.xul => calendar/base/content/dialogs/calendar-print-dialog.xul
This commit is contained in:
Родитель
7d4d1c3274
Коммит
4c864adc3b
|
@ -18,15 +18,17 @@
|
|||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Garth Smedley <garths@oeone.com>
|
||||
* Mike Potter <mikep@oeone.com>
|
||||
* Colin Phillips <colinp@oeone.com>
|
||||
* Chris Charabaruk <ccharabaruk@meldstar.com>
|
||||
* ArentJan Banck <ajbanck@planet.nl>
|
||||
* Chris Allen
|
||||
* Eric Belhaire <belhaire@ief.u-psud.fr>
|
||||
* Michiel van Leeuwen <mvl@exedo.nl>
|
||||
* Matthew Willis <mattwillis@gmail.com>
|
||||
* Contributor(s):
|
||||
* Garth Smedley <garths@oeone.com>
|
||||
* Mike Potter <mikep@oeone.com>
|
||||
* Colin Phillips <colinp@oeone.com>
|
||||
* Chris Charabaruk <ccharabaruk@meldstar.com>
|
||||
* ArentJan Banck <ajbanck@planet.nl>
|
||||
* Chris Allen <chris@netinflux.com>
|
||||
* Eric Belhaire <belhaire@ief.u-psud.fr>
|
||||
* Michiel van Leeuwen <mvl@exedo.nl>
|
||||
* Matthew Willis <mattwillis@gmail.com>
|
||||
* Martin Schroeder <mschroeder@mozilla.x-home.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -42,21 +44,17 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var gPrintSettings = null;
|
||||
|
||||
function getCalendarView()
|
||||
{
|
||||
var theView = window.opener.currentView();
|
||||
function getCalendarView() {
|
||||
let theView = window.opener.currentView();
|
||||
if (!theView.startDay) {
|
||||
theView = null;
|
||||
}
|
||||
return theView;
|
||||
}
|
||||
|
||||
function loadCalendarPrintDialog()
|
||||
{
|
||||
function loadCalendarPrintDialog() {
|
||||
// set the datepickers to the currently selected dates
|
||||
var theView = getCalendarView();
|
||||
let theView = getCalendarView();
|
||||
if (theView) {
|
||||
document.getElementById("start-date-picker").value = theView.startDay.jsDate;
|
||||
document.getElementById("end-date-picker").value = theView.endDay.jsDate;
|
||||
|
@ -70,18 +68,17 @@ function loadCalendarPrintDialog()
|
|||
.setAttribute("selected", true);
|
||||
|
||||
// Get a list of formatters
|
||||
var contractids = new Array();
|
||||
var catman = Components.classes["@mozilla.org/categorymanager;1"]
|
||||
let catman = Components.classes["@mozilla.org/categorymanager;1"]
|
||||
.getService(Components.interfaces.nsICategoryManager);
|
||||
var catenum = catman.enumerateCategory('cal-print-formatters');
|
||||
let catenum = catman.enumerateCategory("cal-print-formatters");
|
||||
|
||||
// Walk the list, adding items to the layout menupopup
|
||||
var layoutList = document.getElementById("layout-field");
|
||||
let layoutList = document.getElementById("layout-field");
|
||||
while (catenum.hasMoreElements()) {
|
||||
var entry = catenum.getNext();
|
||||
let entry = catenum.getNext();
|
||||
entry = entry.QueryInterface(Components.interfaces.nsISupportsCString);
|
||||
var contractid = catman.getCategoryEntry('cal-print-formatters', entry);
|
||||
var formatter = Components.classes[contractid]
|
||||
let contractid = catman.getCategoryEntry("cal-print-formatters", entry);
|
||||
let formatter = Components.classes[contractid]
|
||||
.getService(Components.interfaces.calIPrintFormatter);
|
||||
// Use the contractid as value
|
||||
layoutList.appendItem(formatter.name, contractid);
|
||||
|
@ -100,38 +97,37 @@ function loadCalendarPrintDialog()
|
|||
* notifies an Object with title, layoutCId, eventList, start, and end
|
||||
* properties containing the appropriate values.
|
||||
*/
|
||||
function getEventsAndDialogSettings(receiverFunc)
|
||||
{
|
||||
var settings = new Object();
|
||||
var tempTitle = document.getElementById("title-field").value;
|
||||
function getEventsAndDialogSettings(receiverFunc) {
|
||||
let settings = {};
|
||||
let tempTitle = document.getElementById("title-field").value;
|
||||
settings.title = (tempTitle || calGetString("calendar", "Untitled"));
|
||||
settings.layoutCId = document.getElementById("layout-field").value;
|
||||
settings.start = null;
|
||||
settings.end = null;
|
||||
settings.eventList = null;
|
||||
|
||||
var theView = getCalendarView();
|
||||
let theView = getCalendarView();
|
||||
switch (document.getElementById("view-field").selectedItem.value) {
|
||||
case 'currentview':
|
||||
case '': //just in case
|
||||
case "currentview":
|
||||
case "": //just in case
|
||||
settings.start = theView.startDay;
|
||||
settings.end = theView.endDay;
|
||||
break;
|
||||
case 'selected':
|
||||
case "selected":
|
||||
settings.eventList = theView.getSelectedItems({});
|
||||
break;
|
||||
case 'custom':
|
||||
case "custom":
|
||||
// We return the time from the timepickers using the selected
|
||||
// timezone, as not doing so in timezones with a positive offset
|
||||
// from UTC may cause the printout to include the wrong days.
|
||||
var currentTimezone = calendarDefaultTimezone();
|
||||
let currentTimezone = calendarDefaultTimezone();
|
||||
settings.start = jsDateToDateTime(document.getElementById("start-date-picker").value);
|
||||
settings.start = settings.start.getInTimezone(currentTimezone);
|
||||
settings.end = jsDateToDateTime(document.getElementById("end-date-picker").value);
|
||||
settings.end = settings.end.getInTimezone(currentTimezone);
|
||||
break ;
|
||||
default :
|
||||
dump("Error : no case in printDialog.js::printCalendar()");
|
||||
default:
|
||||
Components.utils.reportError("Calendar print dialog: No calendar view found!");
|
||||
}
|
||||
|
||||
if (settings.eventList) {
|
||||
|
@ -141,7 +137,7 @@ function getEventsAndDialogSettings(receiverFunc)
|
|||
settings.end = settings.end.clone();
|
||||
settings.end.day = settings.end.day + 1;
|
||||
settings.eventList = [];
|
||||
var listener = {
|
||||
let listener = {
|
||||
onOperationComplete:
|
||||
function onOperationComplete(aCalendar, aStatus, aOperationType, aId, aDateTime) {
|
||||
receiverFunc(settings);
|
||||
|
@ -152,7 +148,7 @@ function getEventsAndDialogSettings(receiverFunc)
|
|||
}
|
||||
};
|
||||
window.opener.getCompositeCalendar().getItems(
|
||||
Components.interfaces.calICalendar.ITEM_FILTER_TYPE_EVENT |
|
||||
Components.interfaces.calICalendar.ITEM_FILTER_TYPE_EVENT |
|
||||
Components.interfaces.calICalendar.ITEM_FILTER_CLASS_OCCURRENCES,
|
||||
0, settings.start, settings.end, listener);
|
||||
}
|
||||
|
@ -163,22 +159,16 @@ function getEventsAndDialogSettings(receiverFunc)
|
|||
* updates the HTML in the iframe accordingly. This is also called when a
|
||||
* dialog UI element has changed, since we'll want to refresh the preview.
|
||||
*/
|
||||
function refreshHtml(finishFunc)
|
||||
{
|
||||
function refreshHtml(finishFunc) {
|
||||
getEventsAndDialogSettings(
|
||||
function getEventsAndDialogSettings_response(settings) {
|
||||
// calGetString can't do "formatStringFromName".
|
||||
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService);
|
||||
var props = sbs.createBundle("chrome://calendar/locale/calendar.properties");
|
||||
document.title = props.formatStringFromName("PrintPreviewWindowTitle", [settings.title], 1);
|
||||
document.title = calGetString("calendar", "PrintPreviewWindowTitle", [settings.title]);
|
||||
|
||||
var printformatter = Components.classes[settings.layoutCId]
|
||||
let printformatter = Components.classes[settings.layoutCId]
|
||||
.createInstance(Components.interfaces.calIPrintFormatter);
|
||||
|
||||
var html = "";
|
||||
let html = "";
|
||||
try {
|
||||
var pipe = Components.classes["@mozilla.org/pipe;1"]
|
||||
let pipe = Components.classes["@mozilla.org/pipe;1"]
|
||||
.createInstance(Components.interfaces.nsIPipe);
|
||||
const PR_UINT32_MAX = 4294967295; // signals "infinite-length"
|
||||
pipe.init(true, true, 0, PR_UINT32_MAX, null);
|
||||
|
@ -190,13 +180,12 @@ function refreshHtml(finishFunc)
|
|||
settings.title);
|
||||
pipe.outputStream.close();
|
||||
// convert byte-array to UTF-8 string:
|
||||
var convStream =
|
||||
Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIConverterInputStream);
|
||||
let convStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIConverterInputStream);
|
||||
convStream.init(pipe.inputStream, "UTF-8", 0,
|
||||
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
|
||||
try {
|
||||
var portion = {};
|
||||
let portion = {};
|
||||
while (convStream.readString(-1, portion)) {
|
||||
html += portion.value;
|
||||
}
|
||||
|
@ -204,10 +193,10 @@ function refreshHtml(finishFunc)
|
|||
convStream.close();
|
||||
}
|
||||
} catch (e) {
|
||||
dump("printDialog::refreshHtml:" + e + "\n");
|
||||
Components.utils.reportError(e);
|
||||
Components.utils.reportError("Calendar print dialog:refreshHtml: " + e);
|
||||
}
|
||||
var iframeDoc = document.getElementById("content").contentDocument;
|
||||
|
||||
let iframeDoc = document.getElementById("content").contentDocument;
|
||||
iframeDoc.documentElement.innerHTML = html;
|
||||
iframeDoc.title = settings.title;
|
||||
|
||||
|
@ -218,12 +207,11 @@ function refreshHtml(finishFunc)
|
|||
);
|
||||
}
|
||||
|
||||
function printAndClose()
|
||||
{
|
||||
function printAndClose() {
|
||||
refreshHtml(
|
||||
function finish() {
|
||||
PrintUtils.print();
|
||||
var closeDialog = true;
|
||||
let closeDialog = true;
|
||||
#ifdef XP_UNIX
|
||||
#ifndef XP_MACOSX
|
||||
closeDialog = false;
|
|
@ -19,13 +19,15 @@
|
|||
- Portions created by the Initial Developer are Copyright (C) 2001
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s): Garth Smedley <garths@oeone.com>
|
||||
- Mike Potter <mikep@oeone.com>
|
||||
- Colin Phillips <colinp@oeone.com>
|
||||
- Chris Charabaruk <ccharabaruk@meldstar.com>
|
||||
- ArentJan Banck <ajbanck@planet.nl>
|
||||
- Chris Allen <chris@netinflux.com>
|
||||
- Matthew Willis <mattwillis@gmail.com>
|
||||
- Contributor(s):
|
||||
- Garth Smedley <garths@oeone.com>
|
||||
- Mike Potter <mikep@oeone.com>
|
||||
- Colin Phillips <colinp@oeone.com>
|
||||
- Chris Charabaruk <ccharabaruk@meldstar.com>
|
||||
- ArentJan Banck <ajbanck@planet.nl>
|
||||
- Chris Allen <chris@netinflux.com>
|
||||
- Matthew Willis <mattwillis@gmail.com>
|
||||
- Martin Schroeder <mschroeder@mozilla.x-home.org>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -41,46 +43,35 @@
|
|||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://calendar/content/datetimepickers/datetimepickers.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!-- CSS File with all styles specific to the dialog -->
|
||||
<?xml-stylesheet href="chrome://calendar/skin/dialogOverlay.css" type="text/css"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://calendar/content/datetimepickers/datetimepickers.css" type="text/css" ?>
|
||||
|
||||
<!-- DTD File with all strings specific to the calendar -->
|
||||
<!DOCTYPE dialog
|
||||
[
|
||||
<!DOCTYPE dialog [
|
||||
<!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
|
||||
<!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
|
||||
<!ENTITY % dtd3 SYSTEM "chrome://calendar/locale/menuOverlay.dtd"> %dtd3;
|
||||
]>
|
||||
|
||||
|
||||
<dialog
|
||||
id="calendar-new-printwindow"
|
||||
title="&calendar.print.window.title;"
|
||||
windowtype="Calendar:PrintDialog"
|
||||
onload="loadCalendarPrintDialog()"
|
||||
buttons="accept,cancel"
|
||||
buttonlabelaccept="&calendar.print.button.label;"
|
||||
buttonaccesskeyaccept="&calendar.print.accesskey;"
|
||||
defaultButton="accept"
|
||||
ondialogaccept="return printAndClose();"
|
||||
ondialogcancel="return true;"
|
||||
persist="screenX screenY width height"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#">
|
||||
<dialog id="calendar-new-printwindow"
|
||||
title="&calendar.print.window.title;"
|
||||
windowtype="Calendar:PrintDialog"
|
||||
onload="loadCalendarPrintDialog();"
|
||||
buttons="accept,cancel"
|
||||
buttonlabelaccept="&calendar.print.button.label;"
|
||||
buttonaccesskeyaccept="&calendar.print.accesskey;"
|
||||
defaultButton="accept"
|
||||
ondialogaccept="return printAndClose();"
|
||||
ondialogcancel="return true;"
|
||||
persist="screenX screenY width height"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript" src="chrome://calendar/content/printDialog.js"/>
|
||||
<script type="application/javascript" src="chrome://calendar/content/calendar-print-dialog.js"/>
|
||||
<script type="application/javascript" src="chrome://calendar/content/calUtils.js"/>
|
||||
<script type="application/javascript" src="chrome://global/content/printUtils.js"/>
|
||||
|
||||
<hbox id="firstHbox" flex="1">
|
||||
<vbox id="groupboxVbox">
|
||||
|
||||
<groupbox id="settingsGroup">
|
||||
<caption label="&calendar.print.settingsGroup.label;"/>
|
||||
|
||||
|
@ -92,8 +83,7 @@
|
|||
|
||||
<rows>
|
||||
<row align="center">
|
||||
<label class="field-label-box-class"
|
||||
control="title-field"
|
||||
<label control="title-field"
|
||||
value="&calendar.print.title.label;"/>
|
||||
<textbox id="title-field"
|
||||
class="padded"
|
||||
|
@ -101,12 +91,11 @@
|
|||
onchange="refreshHtml();"/>
|
||||
</row>
|
||||
<row align="center">
|
||||
<label class="field-label-box-class"
|
||||
control="layout-field"
|
||||
<label control="layout-field"
|
||||
value="&calendar.print.layout.label;"/>
|
||||
<hbox>
|
||||
<menulist id="layout-field">
|
||||
<!-- This menupopup will be populated by printDialog.js -->
|
||||
<!-- This menupopup will be populated by calendar-print-dialog.js! -->
|
||||
<menupopup id="layout-menulist-menupopup"
|
||||
oncommand="refreshHtml();"/>
|
||||
</menulist>
|
||||
|
@ -119,13 +108,16 @@
|
|||
|
||||
<groupbox id="whatToPrintGroup">
|
||||
<caption label="&calendar.print.range.label;"/>
|
||||
<radiogroup id="view-field" oncommand="refreshHtml();">
|
||||
<radiogroup id="view-field"
|
||||
oncommand="refreshHtml();">
|
||||
<radio id="printCurrentViewRadio"
|
||||
label="&calendar.print.currentview.label;"
|
||||
value="currentview"/>
|
||||
<radio id="selected" label="&calendar.print.selected.label;"
|
||||
<radio id="selected"
|
||||
label="&calendar.print.selected.label;"
|
||||
value="selected"/>
|
||||
<radio id="custom-range" label="&calendar.print.custom.label;"
|
||||
<radio id="custom-range"
|
||||
label="&calendar.print.custom.label;"
|
||||
value="custom"/>
|
||||
<grid>
|
||||
<columns>
|
||||
|
@ -135,16 +127,16 @@
|
|||
|
||||
<rows>
|
||||
<row align="center">
|
||||
<label class="field-label-box-class"
|
||||
control="start-date-picker"
|
||||
<label control="start-date-picker"
|
||||
value="&calendar.print.from.label;"/>
|
||||
<datepicker id="start-date-picker" onchange="onDatePick();"/>
|
||||
<datepicker id="start-date-picker"
|
||||
onchange="onDatePick();"/>
|
||||
</row>
|
||||
<row align="center">
|
||||
<label class="field-label-box-class"
|
||||
control="end-date-picker"
|
||||
<label control="end-date-picker"
|
||||
value="&calendar.print.to.label;"/>
|
||||
<datepicker id="end-date-picker" onchange="onDatePick();"/>
|
||||
<datepicker id="end-date-picker"
|
||||
onchange="onDatePick();"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
@ -154,7 +146,9 @@
|
|||
|
||||
<splitter/>
|
||||
|
||||
<iframe src="about:blank" id="content" flex="1"
|
||||
<iframe src="about:blank"
|
||||
id="content"
|
||||
flex="1"
|
||||
style="border: 2px solid #3c3c3c; width:30em; height:30em;"/>
|
||||
</hbox>
|
||||
</dialog>
|
|
@ -69,6 +69,8 @@ calendar.jar:
|
|||
content/calendar/calendar-invitations-dialog.js (content/dialogs/calendar-invitations-dialog.js)
|
||||
content/calendar/calendar-invitations-dialog.xul (content/dialogs/calendar-invitations-dialog.xul)
|
||||
content/calendar/calendar-invitations-list.xml (content/dialogs/calendar-invitations-list.xml)
|
||||
* content/calendar/calendar-print-dialog.js (content/dialogs/calendar-print-dialog.js)
|
||||
content/calendar/calendar-print-dialog.xul (content/dialogs/calendar-print-dialog.xul)
|
||||
content/calendar/calendar-properties-dialog.xul (content/dialogs/calendar-properties-dialog.xul)
|
||||
content/calendar/calendar-properties-dialog.js (content/dialogs/calendar-properties-dialog.js)
|
||||
content/calendar/calendar-providerUninstall-dialog.xul (content/dialogs/calendar-providerUninstall-dialog.xul)
|
||||
|
|
|
@ -314,7 +314,7 @@ function openCalendarProperties(aCalendar) {
|
|||
* Opens the print dialog
|
||||
*/
|
||||
function calPrint() {
|
||||
openDialog("chrome://calendar/content/printDialog.xul", "Print",
|
||||
openDialog("chrome://calendar/content/calendar-print-dialog.xul", "Print",
|
||||
"centerscreen,chrome,resizable");
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@ calendar.jar:
|
|||
content/calendar/datetimepickers/datetimepickers.css (/calendar/resources/content/datetimepickers/datetimepickers.css)
|
||||
* content/calendar/datetimepickers/datetimepickers.xml (/calendar/resources/content/datetimepickers/datetimepickers.xml)
|
||||
content/calendar/mouseoverPreviews.js (/calendar/resources/content/mouseoverPreviews.js)
|
||||
* content/calendar/printDialog.js (/calendar/resources/content/printDialog.js)
|
||||
content/calendar/printDialog.xul (/calendar/resources/content/printDialog.xul)
|
||||
content/calendar/publish.js (/calendar/resources/content/publish.js)
|
||||
content/calendar/publishDialog.js (/calendar/resources/content/publishDialog.js)
|
||||
content/calendar/publishDialog.xul (/calendar/resources/content/publishDialog.xul)
|
||||
|
|
|
@ -4,8 +4,6 @@ calendar.jar:
|
|||
content/calendar/calendar.js (content/calendar.js)
|
||||
content/calendar/calendarCreation.xul (content/calendarCreation.xul)
|
||||
content/calendar/calendarCreation.js (content/calendarCreation.js)
|
||||
* content/calendar/printDialog.js (content/printDialog.js)
|
||||
content/calendar/printDialog.xul (content/printDialog.xul)
|
||||
content/calendar/publish.js (content/publish.js)
|
||||
content/calendar/publishDialog.js (content/publishDialog.js)
|
||||
content/calendar/publishDialog.xul (content/publishDialog.xul)
|
||||
|
|
Загрузка…
Ссылка в новой задаче