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:
Martin Schroeder 2009-10-25 23:32:13 +01:00
Родитель 7d4d1c3274
Коммит 4c864adc3b
6 изменённых файлов: 93 добавлений и 113 удалений

Просмотреть файл

@ -18,15 +18,17 @@
* Portions created by the Initial Developer are Copyright (C) 2001 * Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved. * the Initial Developer. All Rights Reserved.
* *
* Contributor(s): Garth Smedley <garths@oeone.com> * Contributor(s):
* Mike Potter <mikep@oeone.com> * Garth Smedley <garths@oeone.com>
* Colin Phillips <colinp@oeone.com> * Mike Potter <mikep@oeone.com>
* Chris Charabaruk <ccharabaruk@meldstar.com> * Colin Phillips <colinp@oeone.com>
* ArentJan Banck <ajbanck@planet.nl> * Chris Charabaruk <ccharabaruk@meldstar.com>
* Chris Allen * ArentJan Banck <ajbanck@planet.nl>
* Eric Belhaire <belhaire@ief.u-psud.fr> * Chris Allen <chris@netinflux.com>
* Michiel van Leeuwen <mvl@exedo.nl> * Eric Belhaire <belhaire@ief.u-psud.fr>
* Matthew Willis <mattwillis@gmail.com> * 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 * 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 * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -42,21 +44,17 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
var gPrintSettings = null; function getCalendarView() {
let theView = window.opener.currentView();
function getCalendarView()
{
var theView = window.opener.currentView();
if (!theView.startDay) { if (!theView.startDay) {
theView = null; theView = null;
} }
return theView; return theView;
} }
function loadCalendarPrintDialog() function loadCalendarPrintDialog() {
{
// set the datepickers to the currently selected dates // set the datepickers to the currently selected dates
var theView = getCalendarView(); let theView = getCalendarView();
if (theView) { if (theView) {
document.getElementById("start-date-picker").value = theView.startDay.jsDate; document.getElementById("start-date-picker").value = theView.startDay.jsDate;
document.getElementById("end-date-picker").value = theView.endDay.jsDate; document.getElementById("end-date-picker").value = theView.endDay.jsDate;
@ -70,18 +68,17 @@ function loadCalendarPrintDialog()
.setAttribute("selected", true); .setAttribute("selected", true);
// Get a list of formatters // Get a list of formatters
var contractids = new Array(); let catman = Components.classes["@mozilla.org/categorymanager;1"]
var catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(Components.interfaces.nsICategoryManager); .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 // Walk the list, adding items to the layout menupopup
var layoutList = document.getElementById("layout-field"); let layoutList = document.getElementById("layout-field");
while (catenum.hasMoreElements()) { while (catenum.hasMoreElements()) {
var entry = catenum.getNext(); let entry = catenum.getNext();
entry = entry.QueryInterface(Components.interfaces.nsISupportsCString); entry = entry.QueryInterface(Components.interfaces.nsISupportsCString);
var contractid = catman.getCategoryEntry('cal-print-formatters', entry); let contractid = catman.getCategoryEntry("cal-print-formatters", entry);
var formatter = Components.classes[contractid] let formatter = Components.classes[contractid]
.getService(Components.interfaces.calIPrintFormatter); .getService(Components.interfaces.calIPrintFormatter);
// Use the contractid as value // Use the contractid as value
layoutList.appendItem(formatter.name, contractid); layoutList.appendItem(formatter.name, contractid);
@ -100,38 +97,37 @@ function loadCalendarPrintDialog()
* notifies an Object with title, layoutCId, eventList, start, and end * notifies an Object with title, layoutCId, eventList, start, and end
* properties containing the appropriate values. * properties containing the appropriate values.
*/ */
function getEventsAndDialogSettings(receiverFunc) function getEventsAndDialogSettings(receiverFunc) {
{ let settings = {};
var settings = new Object(); let tempTitle = document.getElementById("title-field").value;
var tempTitle = document.getElementById("title-field").value;
settings.title = (tempTitle || calGetString("calendar", "Untitled")); settings.title = (tempTitle || calGetString("calendar", "Untitled"));
settings.layoutCId = document.getElementById("layout-field").value; settings.layoutCId = document.getElementById("layout-field").value;
settings.start = null; settings.start = null;
settings.end = null; settings.end = null;
settings.eventList = null; settings.eventList = null;
var theView = getCalendarView(); let theView = getCalendarView();
switch (document.getElementById("view-field").selectedItem.value) { switch (document.getElementById("view-field").selectedItem.value) {
case 'currentview': case "currentview":
case '': //just in case case "": //just in case
settings.start = theView.startDay; settings.start = theView.startDay;
settings.end = theView.endDay; settings.end = theView.endDay;
break; break;
case 'selected': case "selected":
settings.eventList = theView.getSelectedItems({}); settings.eventList = theView.getSelectedItems({});
break; break;
case 'custom': case "custom":
// We return the time from the timepickers using the selected // We return the time from the timepickers using the selected
// timezone, as not doing so in timezones with a positive offset // timezone, as not doing so in timezones with a positive offset
// from UTC may cause the printout to include the wrong days. // 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 = jsDateToDateTime(document.getElementById("start-date-picker").value);
settings.start = settings.start.getInTimezone(currentTimezone); settings.start = settings.start.getInTimezone(currentTimezone);
settings.end = jsDateToDateTime(document.getElementById("end-date-picker").value); settings.end = jsDateToDateTime(document.getElementById("end-date-picker").value);
settings.end = settings.end.getInTimezone(currentTimezone); settings.end = settings.end.getInTimezone(currentTimezone);
break ; break ;
default : default:
dump("Error : no case in printDialog.js::printCalendar()"); Components.utils.reportError("Calendar print dialog: No calendar view found!");
} }
if (settings.eventList) { if (settings.eventList) {
@ -141,7 +137,7 @@ function getEventsAndDialogSettings(receiverFunc)
settings.end = settings.end.clone(); settings.end = settings.end.clone();
settings.end.day = settings.end.day + 1; settings.end.day = settings.end.day + 1;
settings.eventList = []; settings.eventList = [];
var listener = { let listener = {
onOperationComplete: onOperationComplete:
function onOperationComplete(aCalendar, aStatus, aOperationType, aId, aDateTime) { function onOperationComplete(aCalendar, aStatus, aOperationType, aId, aDateTime) {
receiverFunc(settings); receiverFunc(settings);
@ -152,7 +148,7 @@ function getEventsAndDialogSettings(receiverFunc)
} }
}; };
window.opener.getCompositeCalendar().getItems( 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, Components.interfaces.calICalendar.ITEM_FILTER_CLASS_OCCURRENCES,
0, settings.start, settings.end, listener); 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 * 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. * dialog UI element has changed, since we'll want to refresh the preview.
*/ */
function refreshHtml(finishFunc) function refreshHtml(finishFunc) {
{
getEventsAndDialogSettings( getEventsAndDialogSettings(
function getEventsAndDialogSettings_response(settings) { function getEventsAndDialogSettings_response(settings) {
// calGetString can't do "formatStringFromName". document.title = calGetString("calendar", "PrintPreviewWindowTitle", [settings.title]);
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);
var printformatter = Components.classes[settings.layoutCId] let printformatter = Components.classes[settings.layoutCId]
.createInstance(Components.interfaces.calIPrintFormatter); .createInstance(Components.interfaces.calIPrintFormatter);
let html = "";
var html = "";
try { try {
var pipe = Components.classes["@mozilla.org/pipe;1"] let pipe = Components.classes["@mozilla.org/pipe;1"]
.createInstance(Components.interfaces.nsIPipe); .createInstance(Components.interfaces.nsIPipe);
const PR_UINT32_MAX = 4294967295; // signals "infinite-length" const PR_UINT32_MAX = 4294967295; // signals "infinite-length"
pipe.init(true, true, 0, PR_UINT32_MAX, null); pipe.init(true, true, 0, PR_UINT32_MAX, null);
@ -190,13 +180,12 @@ function refreshHtml(finishFunc)
settings.title); settings.title);
pipe.outputStream.close(); pipe.outputStream.close();
// convert byte-array to UTF-8 string: // convert byte-array to UTF-8 string:
var convStream = let convStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
Components.classes["@mozilla.org/intl/converter-input-stream;1"] .createInstance(Components.interfaces.nsIConverterInputStream);
.createInstance(Components.interfaces.nsIConverterInputStream);
convStream.init(pipe.inputStream, "UTF-8", 0, convStream.init(pipe.inputStream, "UTF-8", 0,
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER); Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
try { try {
var portion = {}; let portion = {};
while (convStream.readString(-1, portion)) { while (convStream.readString(-1, portion)) {
html += portion.value; html += portion.value;
} }
@ -204,10 +193,10 @@ function refreshHtml(finishFunc)
convStream.close(); convStream.close();
} }
} catch (e) { } catch (e) {
dump("printDialog::refreshHtml:" + e + "\n"); Components.utils.reportError("Calendar print dialog:refreshHtml: " + e);
Components.utils.reportError(e);
} }
var iframeDoc = document.getElementById("content").contentDocument;
let iframeDoc = document.getElementById("content").contentDocument;
iframeDoc.documentElement.innerHTML = html; iframeDoc.documentElement.innerHTML = html;
iframeDoc.title = settings.title; iframeDoc.title = settings.title;
@ -218,12 +207,11 @@ function refreshHtml(finishFunc)
); );
} }
function printAndClose() function printAndClose() {
{
refreshHtml( refreshHtml(
function finish() { function finish() {
PrintUtils.print(); PrintUtils.print();
var closeDialog = true; let closeDialog = true;
#ifdef XP_UNIX #ifdef XP_UNIX
#ifndef XP_MACOSX #ifndef XP_MACOSX
closeDialog = false; closeDialog = false;

Просмотреть файл

@ -19,13 +19,15 @@
- Portions created by the Initial Developer are Copyright (C) 2001 - Portions created by the Initial Developer are Copyright (C) 2001
- the Initial Developer. All Rights Reserved. - the Initial Developer. All Rights Reserved.
- -
- Contributor(s): Garth Smedley <garths@oeone.com> - Contributor(s):
- Mike Potter <mikep@oeone.com> - Garth Smedley <garths@oeone.com>
- Colin Phillips <colinp@oeone.com> - Mike Potter <mikep@oeone.com>
- Chris Charabaruk <ccharabaruk@meldstar.com> - Colin Phillips <colinp@oeone.com>
- ArentJan Banck <ajbanck@planet.nl> - Chris Charabaruk <ccharabaruk@meldstar.com>
- Chris Allen <chris@netinflux.com> - ArentJan Banck <ajbanck@planet.nl>
- Matthew Willis <mattwillis@gmail.com> - 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 - 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 - either the GNU General Public License Version 2 or later (the "GPL"), or
@ -41,46 +43,35 @@
- -
- ***** END LICENSE BLOCK ***** --> - ***** 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"?> <!DOCTYPE dialog [
<!-- 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
[
<!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1; <!ENTITY % dtd1 SYSTEM "chrome://calendar/locale/global.dtd" > %dtd1;
<!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2; <!ENTITY % dtd2 SYSTEM "chrome://calendar/locale/calendar.dtd" > %dtd2;
<!ENTITY % dtd3 SYSTEM "chrome://calendar/locale/menuOverlay.dtd"> %dtd3; <!ENTITY % dtd3 SYSTEM "chrome://calendar/locale/menuOverlay.dtd"> %dtd3;
]> ]>
<dialog <dialog id="calendar-new-printwindow"
id="calendar-new-printwindow" title="&calendar.print.window.title;"
title="&calendar.print.window.title;" windowtype="Calendar:PrintDialog"
windowtype="Calendar:PrintDialog" onload="loadCalendarPrintDialog();"
onload="loadCalendarPrintDialog()" buttons="accept,cancel"
buttons="accept,cancel" buttonlabelaccept="&calendar.print.button.label;"
buttonlabelaccept="&calendar.print.button.label;" buttonaccesskeyaccept="&calendar.print.accesskey;"
buttonaccesskeyaccept="&calendar.print.accesskey;" defaultButton="accept"
defaultButton="accept" ondialogaccept="return printAndClose();"
ondialogaccept="return printAndClose();" ondialogcancel="return true;"
ondialogcancel="return true;" persist="screenX screenY width height"
persist="screenX screenY width height" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:nc="http://home.netscape.com/NC-rdf#">
<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://calendar/content/calUtils.js"/>
<script type="application/javascript" src="chrome://global/content/printUtils.js"/> <script type="application/javascript" src="chrome://global/content/printUtils.js"/>
<hbox id="firstHbox" flex="1"> <hbox id="firstHbox" flex="1">
<vbox id="groupboxVbox"> <vbox id="groupboxVbox">
<groupbox id="settingsGroup"> <groupbox id="settingsGroup">
<caption label="&calendar.print.settingsGroup.label;"/> <caption label="&calendar.print.settingsGroup.label;"/>
@ -92,8 +83,7 @@
<rows> <rows>
<row align="center"> <row align="center">
<label class="field-label-box-class" <label control="title-field"
control="title-field"
value="&calendar.print.title.label;"/> value="&calendar.print.title.label;"/>
<textbox id="title-field" <textbox id="title-field"
class="padded" class="padded"
@ -101,12 +91,11 @@
onchange="refreshHtml();"/> onchange="refreshHtml();"/>
</row> </row>
<row align="center"> <row align="center">
<label class="field-label-box-class" <label control="layout-field"
control="layout-field"
value="&calendar.print.layout.label;"/> value="&calendar.print.layout.label;"/>
<hbox> <hbox>
<menulist id="layout-field"> <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" <menupopup id="layout-menulist-menupopup"
oncommand="refreshHtml();"/> oncommand="refreshHtml();"/>
</menulist> </menulist>
@ -119,13 +108,16 @@
<groupbox id="whatToPrintGroup"> <groupbox id="whatToPrintGroup">
<caption label="&calendar.print.range.label;"/> <caption label="&calendar.print.range.label;"/>
<radiogroup id="view-field" oncommand="refreshHtml();"> <radiogroup id="view-field"
oncommand="refreshHtml();">
<radio id="printCurrentViewRadio" <radio id="printCurrentViewRadio"
label="&calendar.print.currentview.label;" label="&calendar.print.currentview.label;"
value="currentview"/> value="currentview"/>
<radio id="selected" label="&calendar.print.selected.label;" <radio id="selected"
label="&calendar.print.selected.label;"
value="selected"/> value="selected"/>
<radio id="custom-range" label="&calendar.print.custom.label;" <radio id="custom-range"
label="&calendar.print.custom.label;"
value="custom"/> value="custom"/>
<grid> <grid>
<columns> <columns>
@ -135,16 +127,16 @@
<rows> <rows>
<row align="center"> <row align="center">
<label class="field-label-box-class" <label control="start-date-picker"
control="start-date-picker"
value="&calendar.print.from.label;"/> value="&calendar.print.from.label;"/>
<datepicker id="start-date-picker" onchange="onDatePick();"/> <datepicker id="start-date-picker"
onchange="onDatePick();"/>
</row> </row>
<row align="center"> <row align="center">
<label class="field-label-box-class" <label control="end-date-picker"
control="end-date-picker"
value="&calendar.print.to.label;"/> value="&calendar.print.to.label;"/>
<datepicker id="end-date-picker" onchange="onDatePick();"/> <datepicker id="end-date-picker"
onchange="onDatePick();"/>
</row> </row>
</rows> </rows>
</grid> </grid>
@ -154,7 +146,9 @@
<splitter/> <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;"/> style="border: 2px solid #3c3c3c; width:30em; height:30em;"/>
</hbox> </hbox>
</dialog> </dialog>

Просмотреть файл

@ -69,6 +69,8 @@ calendar.jar:
content/calendar/calendar-invitations-dialog.js (content/dialogs/calendar-invitations-dialog.js) 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-dialog.xul (content/dialogs/calendar-invitations-dialog.xul)
content/calendar/calendar-invitations-list.xml (content/dialogs/calendar-invitations-list.xml) 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.xul (content/dialogs/calendar-properties-dialog.xul)
content/calendar/calendar-properties-dialog.js (content/dialogs/calendar-properties-dialog.js) content/calendar/calendar-properties-dialog.js (content/dialogs/calendar-properties-dialog.js)
content/calendar/calendar-providerUninstall-dialog.xul (content/dialogs/calendar-providerUninstall-dialog.xul) content/calendar/calendar-providerUninstall-dialog.xul (content/dialogs/calendar-providerUninstall-dialog.xul)

Просмотреть файл

@ -314,7 +314,7 @@ function openCalendarProperties(aCalendar) {
* Opens the print dialog * Opens the print dialog
*/ */
function calPrint() { function calPrint() {
openDialog("chrome://calendar/content/printDialog.xul", "Print", openDialog("chrome://calendar/content/calendar-print-dialog.xul", "Print",
"centerscreen,chrome,resizable"); "centerscreen,chrome,resizable");
} }

Просмотреть файл

@ -55,8 +55,6 @@ calendar.jar:
content/calendar/datetimepickers/datetimepickers.css (/calendar/resources/content/datetimepickers/datetimepickers.css) content/calendar/datetimepickers/datetimepickers.css (/calendar/resources/content/datetimepickers/datetimepickers.css)
* content/calendar/datetimepickers/datetimepickers.xml (/calendar/resources/content/datetimepickers/datetimepickers.xml) * content/calendar/datetimepickers/datetimepickers.xml (/calendar/resources/content/datetimepickers/datetimepickers.xml)
content/calendar/mouseoverPreviews.js (/calendar/resources/content/mouseoverPreviews.js) 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/publish.js (/calendar/resources/content/publish.js)
content/calendar/publishDialog.js (/calendar/resources/content/publishDialog.js) content/calendar/publishDialog.js (/calendar/resources/content/publishDialog.js)
content/calendar/publishDialog.xul (/calendar/resources/content/publishDialog.xul) content/calendar/publishDialog.xul (/calendar/resources/content/publishDialog.xul)

Просмотреть файл

@ -4,8 +4,6 @@ calendar.jar:
content/calendar/calendar.js (content/calendar.js) content/calendar/calendar.js (content/calendar.js)
content/calendar/calendarCreation.xul (content/calendarCreation.xul) content/calendar/calendarCreation.xul (content/calendarCreation.xul)
content/calendar/calendarCreation.js (content/calendarCreation.js) 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/publish.js (content/publish.js)
content/calendar/publishDialog.js (content/publishDialog.js) content/calendar/publishDialog.js (content/publishDialog.js)
content/calendar/publishDialog.xul (content/publishDialog.xul) content/calendar/publishDialog.xul (content/publishDialog.xul)