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 1e57797fba1a98d3273bcd9499f8ddca98021222..2955c185b2db44f65ca2bb48885dd92117393098 100644 |
| --- a/chrome/browser/resources/print_preview/print_preview.js |
| +++ b/chrome/browser/resources/print_preview/print_preview.js |
| @@ -121,6 +121,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); }; |
| @@ -170,6 +171,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; |
| @@ -330,6 +332,15 @@ function getDuplexMode() { |
| } |
| /** |
| + * Checks whether the Headers and Footers checkbox is checked or not. |
| + * |
| + * @return {boolean} true if Headers and Footers are checked. |
| + */ |
| +function isHeaderFooter() { |
|
Lei Zhang
2011/07/12 22:04:50
how about hasHeadersFooters() ?
Aayush Kumar
2011/07/13 21:52:16
Done.
|
| + return $('header-footer').checked; |
| +} |
| + |
| +/** |
| * Creates a JSON string based on the values in the printer settings. |
| * |
| * @return {string} JSON string with print job settings. |
| @@ -348,7 +359,8 @@ function getSettingsJSON() { |
| 'collate': isCollated(), |
| 'landscape': isLandscape(), |
| 'color': isColor(), |
| - 'printToPDF': printToPDF}); |
| + 'printToPDF': printToPDF, |
| + 'headerFooter': isHeaderFooter()}); |
| } |
| /** |
| @@ -675,6 +687,9 @@ function checkIfSettingsChangedAndRegeneratePreview() { |
| requestPrintPreview(); |
| return true; |
| } |
| + } else if (printSettings.isHeaderFooter != tempPrintSettings.isHeaderFooter) { |
| + requestPrintPreview(); |
| + return true; |
| } |
| if (!isSelectedPagesValid()) |
| @@ -857,6 +872,14 @@ function onLayoutModeToggle() { |
| } |
| /** |
| + * When the user selects or de-selects the Headers and footers option then we |
| + * regenerate the preview pdf. |
| + */ |
| +function onHeaderFooterChanged() { |
| + requestPrintPreview(); |
| +} |
| + |
| +/** |
| * Sets the default values and sends a request to regenerate preview data. |
| */ |
| function setDefaultValuesAndRegeneratePreview() { |
| @@ -943,6 +966,7 @@ function onPageSelectionMayHaveChanged() { |
| function PrintSettings() { |
| this.deviceName = ''; |
| this.isLandscape = ''; |
| + this.isHeaderFooter = ''; |
| } |
| /** |
| @@ -951,4 +975,5 @@ function PrintSettings() { |
| PrintSettings.prototype.save = function() { |
| this.deviceName = getSelectedPrinterName(); |
| this.isLandscape = isLandscape(); |
| + this.isHeaderFooter = isHeaderFooter(); |
| } |