Index: chrome/browser/resources/print_preview/header_footer_settings.js |
diff --git a/chrome/browser/resources/print_preview/header_footer_settings.js b/chrome/browser/resources/print_preview/header_footer_settings.js |
index 02776c58b86b8e351e8924dd57ebe07423b36e74..e2e742f1cc1a3a8bfbeddbf397a873a565149e2c 100644 |
--- a/chrome/browser/resources/print_preview/header_footer_settings.js |
+++ b/chrome/browser/resources/print_preview/header_footer_settings.js |
@@ -13,7 +13,6 @@ cr.define('print_preview', function() { |
function HeaderFooterSettings() { |
this.headerFooterOption_ = $('header-footer-option'); |
this.headerFooterCheckbox_ = $('header-footer'); |
- this.headerFooterApplies_ = false; |
this.addEventListeners_(); |
} |
@@ -33,7 +32,7 @@ cr.define('print_preview', function() { |
* @return {boolean} true if Headers and Footers are checked. |
*/ |
hasHeaderFooter: function() { |
- return this.headerFooterApplies_ && this.headerFooterCheckbox_.checked; |
+ return previewModifiable && this.headerFooterCheckbox_.checked; |
}, |
/** |
@@ -46,6 +45,39 @@ cr.define('print_preview', function() { |
}, |
/** |
+ * Checks the printable area and updates the visibility of header footer |
+ * option based on the selected margins. |
+ * @param {printing::PageSizeMargins} pageLayout The default layout of the |
dpapad
2012/03/17 00:36:41
Fix comment.
kmadhusu
2012/03/19 18:45:31
Done.
|
+ * in poitns. |
+ * @param {{x: number, y: number, width: number, height: number}} |
+ * printableArea Specifies the printable area details. |
+ * @param {number} marginsType Specifies the selected margins type value. |
+ */ |
+ checkAndHideHeaderFooterOption: function(pageLayout, printableArea, |
+ marginsType) { |
+ var headerFooterApplies = true; |
+ if (marginsType == |
+ print_preview.MarginSettings.MARGINS_VALUE_NO_MARGINS || |
+ !previewModifiable) { |
+ headerFooterApplies = false; |
+ } else if (marginsType != |
+ print_preview.MarginSettings.MARGINS_VALUE_MINIMUM) { |
+ if (cr.isLinux || cr.isChromeOS) { |
+ headerFooterApplies = pageLayout.marginTop > 0 || |
+ pageLayout.marginBottom > 0; |
+ } else { |
+ var pageHeight = pageLayout.marginTop + pageLayout.marginBottom + |
+ pageLayout.contentHeight; |
+ headerFooterApplies = |
+ (pageLayout.marginTop > printableArea.y) || |
+ (pageLayout.marginBottom > |
+ (pageHeight - printableArea.y - printableArea.height)); |
+ } |
+ } |
+ this.setVisible_(headerFooterApplies); |
+ }, |
+ |
+ /** |
* Adding listeners to header footer related controls. |
* @private |
*/ |
@@ -54,14 +86,6 @@ cr.define('print_preview', function() { |
this.onHeaderFooterChanged_.bind(this); |
document.addEventListener(customEvents.PDF_LOADED, |
this.onPDFLoaded_.bind(this)); |
- document.addEventListener(customEvents.MARGINS_SELECTION_CHANGED, |
- this.onMarginsSelectionChanged_.bind(this)); |
- }, |
- |
- onMarginsSelectionChanged_: function(event) { |
- this.headerFooterApplies_ = event.selectedMargins != |
- print_preview.MarginSettings.MARGINS_VALUE_NO_MARGINS; |
- this.setVisible_(this.headerFooterApplies_); |
}, |
/** |