Chromium Code Reviews| 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 17bdbcf3819108254bc5aa883254a9202965f137..98d28090da7f93e30255191f9e7c62d6f16b3384 100644 |
| --- a/chrome/browser/resources/print_preview/print_preview.js |
| +++ b/chrome/browser/resources/print_preview/print_preview.js |
| @@ -112,6 +112,7 @@ function onLoad() { |
| function addEventListeners() { |
| // Controls that require preview rendering. |
| $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; |
| + $('header-footer').onclick = onHeaderFooterChanged; |
| // Controls that do not require preview rendering. |
| $('color').onclick = function() { setColor(true); }; |
| @@ -127,6 +128,7 @@ function removeEventListeners() { |
| // Controls that require preview rendering |
| $('printer-list').onchange = null; |
| + $('header-footer').onclick = null; |
| // Controls that don't require preview rendering. |
| $('color').onclick = null; |
| @@ -321,6 +323,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. |
| @@ -339,6 +350,7 @@ function getSettings() { |
| 'landscape': layoutSettings.isLandscape(), |
| 'color': isColor(), |
| 'printToPDF': printToPDF, |
| + 'headerFooter': hasHeaderFooter(), |
| 'requestID': 0}; |
| var printerList = $('printer-list'); |
| @@ -794,6 +806,9 @@ function onPDFLoad() { |
| setColor($('color').checked); |
| hideLoadingAnimation(); |
| + if (!previewModifiable) { |
|
dpapad
2011/07/25 15:40:01
Nit: No need for {}.
Aayush Kumar
2011/07/25 18:37:23
Done.
|
| + fadeOutElement($('options-option')); |
| + } |
| cr.dispatchSimpleEvent(document, 'PDFLoaded'); |
| } |
| @@ -867,6 +882,10 @@ function checkIfSettingsChangedAndRegeneratePreview() { |
| setDefaultValuesAndRegeneratePreview(); |
| return true; |
| } |
| + if (printSettings.hasHeaderFooter != tempPrintSettings.hasHeaderFooter) { |
| + requestPrintPreview(); |
| + return true; |
| + } |
| if (pageSettings.requestPrintPreviewIfNeeded()) |
| return true; |
| @@ -915,6 +934,14 @@ function checkCompatiblePluginExists() { |
| window.addEventListener('DOMContentLoaded', onLoad); |
| /** |
| + * When the user selects or de-selects the headers and footers option then we |
|
dpapad
2011/07/25 15:40:01
Nit: Don't use "we"n in comments.
When the user s
Aayush Kumar
2011/07/25 18:37:23
Done.
|
| + * regenerate the preview pdf. |
| + */ |
| +function onHeaderFooterChanged() { |
| + requestPrintPreview(); |
| +} |
| + |
| +/** |
| * Sets the default values and sends a request to regenerate preview data. |
| */ |
| function setDefaultValuesAndRegeneratePreview() { |
| @@ -928,6 +955,7 @@ function setDefaultValuesAndRegeneratePreview() { |
| function PrintSettings() { |
| this.deviceName = ''; |
| this.isLandscape = ''; |
| + this.hasHeaderFooter = ''; |
| } |
| /** |
| @@ -936,5 +964,6 @@ function PrintSettings() { |
| PrintSettings.prototype.save = function() { |
| this.deviceName = getSelectedPrinterName(); |
| this.isLandscape = layoutSettings.isLandscape(); |
| + this.hasHeaderFooter = hasHeaderFooter(); |
| } |