Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: chrome/browser/resources/print_preview/print_preview.js

Issue 7348010: Added Header and Footer support using Skia (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove header_footer_info from settings Dictionary. Changes as per Steve and Kausalya's comments. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/print_preview.js
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js
index 35ec000338f2f92da3c38462ea19c040f2c210a9..9868509eec070416d54a4f6f2525f554d817e949 100644
--- a/chrome/browser/resources/print_preview/print_preview.js
+++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -116,6 +116,7 @@ function onLoad() {
function addEventListeners() {
// Controls that require preview rendering.
$('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities;
+ $('header-footer').onclick = onHeaderFooterChanged;
}
/**
@@ -127,6 +128,7 @@ function removeEventListeners() {
// Controls that require preview rendering
$('printer-list').onchange = null;
+ $('header-footer').onclick = null;
}
/**
@@ -293,6 +295,15 @@ function areSettingsValid() {
}
/**
+ * Checks whether the Headers and Footers checkbox is checked or not.
+ *
+ * @return {boolean} true if Headers and Footers are checked.
+ */
+function hasHeaderFooter() {
+ return $('header-footer').checked;
+}
+
+/**
* Creates an object based on the values in the printer settings.
*
* @return {Object} Object containing print job settings.
@@ -311,6 +322,7 @@ function getSettings() {
'landscape': layoutSettings.isLandscape(),
'color': colorSettings.isColor(),
'printToPDF': printToPDF,
+ 'headerFooter': hasHeaderFooter(),
'requestID': 0};
var printerList = $('printer-list');
@@ -775,6 +787,8 @@ function onPDFLoad() {
if (previewModifiable) {
setPluginPreviewPageCount();
cr.dispatchSimpleEvent(document, 'updateSummary');
+ } else {
+ fadeOutElement($('options-option'));
}
$('pdf-viewer').fitToHeight();
cr.dispatchSimpleEvent(document, 'PDFLoaded');
@@ -891,6 +905,10 @@ function checkIfSettingsChangedAndRegeneratePreview() {
setDefaultValuesAndRegeneratePreview();
return true;
}
+ if (printSettings.hasHeaderFooter != tempPrintSettings.hasHeaderFooter) {
+ requestPrintPreview();
+ return true;
+ }
if (pageSettings.requestPrintPreviewIfNeeded())
return true;
@@ -943,6 +961,14 @@ function checkCompatiblePluginExists() {
window.addEventListener('DOMContentLoaded', onLoad);
/**
+ * When the user selects or de-selects the headers and footers option then a
+ * new preview is requested.
+ */
+function onHeaderFooterChanged() {
+ requestPrintPreview();
+}
+
+/**
* Sets the default values and sends a request to regenerate preview data.
*/
function setDefaultValuesAndRegeneratePreview() {
@@ -956,6 +982,7 @@ function setDefaultValuesAndRegeneratePreview() {
function PrintSettings() {
this.deviceName = '';
this.isLandscape = '';
+ this.hasHeaderFooter = '';
}
/**
@@ -964,5 +991,6 @@ function PrintSettings() {
PrintSettings.prototype.save = function() {
this.deviceName = getSelectedPrinterName();
this.isLandscape = layoutSettings.isLandscape();
+ this.hasHeaderFooter = hasHeaderFooter();
}

Powered by Google App Engine
This is Rietveld 408576698