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 e26fcd89b427de43a04d3abaf974c8a4807209a2..03796cd901ba1e5c1cd852112bce2e42227f5922 100644 |
| --- a/chrome/browser/resources/print_preview/print_preview.js |
| +++ b/chrome/browser/resources/print_preview/print_preview.js |
| @@ -95,6 +95,7 @@ function addEventListeners() { |
| $('landscape').onclick = onLayoutModeToggle; |
| $('portrait').onclick = onLayoutModeToggle; |
| $('printer-list').onchange = updateControlsWithSelectedPrinterCapabilities; |
| + $('header-footer').onclick = onHeaderFooterChanged; |
| // Controls that do not require preview rendering. |
| $('color').onclick = function() { setColor(true); }; |
| @@ -111,6 +112,7 @@ function removeEventListeners() { |
| $('landscape').onclick = null; |
| $('portrait').onclick = null; |
| $('printer-list').onchange = null; |
| + $('header-footer').onclick = null; |
| // Controls that don't require preview rendering. |
| $('color').onclick = null; |
| @@ -341,6 +343,15 @@ function getDuplexMode() { |
| } |
| /** |
| + * 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 a JSON string based on the values in the printer settings. |
| * |
| * @return {string} JSON string with print job settings. |
| @@ -357,7 +368,8 @@ function getSettingsJSON() { |
| 'collate': isCollated(), |
| 'landscape': isLandscape(), |
| 'color': isColor(), |
| - 'printToPDF': printToPDF}; |
| + 'printToPDF': printToPDF, |
| + 'headerFooter': hasHeaderFooter()}; |
| var printerList = $('printer-list'); |
| var selectedPrinter = printerList.selectedIndex; |
| if (cloudprint.isCloudPrint(printerList.options[selectedPrinter])) { |
| @@ -835,6 +847,10 @@ function checkIfSettingsChangedAndRegeneratePreview() { |
| setDefaultValuesAndRegeneratePreview(); |
| return true; |
| } |
| + if (printSettings.hasHeaderFooter != tempPrintSettings.hasHeaderFooter) { |
| + requestPrintPreview(); |
| + return true; |
| + } |
| if (pageSettings.requestPrintPreviewIfNeeded()) |
| return true; |
| @@ -967,6 +983,14 @@ function onLayoutModeToggle() { |
| } |
| /** |
| + * When the user selects or de-selects the Headers and footers option then we |
|
kmadhusu
2011/07/14 01:50:15
Headers -> headers
Aayush Kumar
2011/07/19 01:20:30
Done.
|
| + * regenerate the preview pdf. |
| + */ |
| +function onHeaderFooterChanged() { |
|
dpapad
2011/07/14 15:59:35
Are headers and footers always available? For exam
Aayush Kumar
2011/07/19 01:20:30
Done.
|
| + requestPrintPreview(); |
| +} |
| + |
| +/** |
| * Sets the default values and sends a request to regenerate preview data. |
| */ |
| function setDefaultValuesAndRegeneratePreview() { |
| @@ -980,6 +1004,7 @@ function setDefaultValuesAndRegeneratePreview() { |
| function PrintSettings() { |
| this.deviceName = ''; |
| this.isLandscape = ''; |
| + this.hasHeaderFooter = ''; |
| } |
| /** |
| @@ -988,5 +1013,6 @@ function PrintSettings() { |
| PrintSettings.prototype.save = function() { |
| this.deviceName = getSelectedPrinterName(); |
| this.isLandscape = isLandscape(); |
| + this.hasHeaderFooter = hasHeaderFooter(); |
| } |