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

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

Issue 9699040: PrintPreview: Hide/Show the header footer option based on print frame margins. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 8 years, 9 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/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..882829bc6db11a59ec23e6576075a27d2862a3b3 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,40 @@ cr.define('print_preview', function() {
},
/**
+ * Checks the printable area and updates the visibility of header footer
+ * option based on the selected margins.
+ * @param {{contentWidth: number, contentHeight: number, marginLeft: number,
+ * marginRight: number, marginTop: number, marginBottom: number,
+ * printableAreaX: number, printableAreaY: number,
+ * printableAreaWidth: number, printableAreaHeight: number}}
+ * pageLayout Specifies default page layout details in points.
+ * @param {number} marginsType Specifies the selected margins type value.
+ */
+ checkAndHideHeaderFooterOption: function(pageLayout, 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 > pageLayout.printableAreaY) ||
+ (pageLayout.marginBottom >
+ (pageHeight - pageLayout.printableAreaY -
+ pageLayout.printableAreaHeight));
+ }
+ }
+ this.setVisible_(headerFooterApplies);
+ },
+
+ /**
* Adding listeners to header footer related controls.
* @private
*/
@@ -54,14 +87,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_);
},
/**
« no previous file with comments | « chrome/browser/printing/print_preview_message_handler.cc ('k') | chrome/browser/resources/print_preview/margin_settings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698