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

Unified Diff: chrome/browser/resources/print_preview/settings/other_options_settings.js

Issue 1125343004: Add a "Simplify Page" option to the print preview dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify version of the HiddenPrintPreview and solved issues pointed out by the last review Created 5 years, 6 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/settings/other_options_settings.js
diff --git a/chrome/browser/resources/print_preview/settings/other_options_settings.js b/chrome/browser/resources/print_preview/settings/other_options_settings.js
index dd8a3fde574580ca9e320380906c76beea715658..5ec8a8600bf4721dee6f74e0cecd554b02d50c65 100644
--- a/chrome/browser/resources/print_preview/settings/other_options_settings.js
+++ b/chrome/browser/resources/print_preview/settings/other_options_settings.js
@@ -16,11 +16,14 @@ cr.define('print_preview', function() {
* only ticket item.
* @param {!print_preview.ticket_items.HeaderFooter} headerFooter Header
* footer ticket item.
+ * @param {!print_preview.ticket_items.PrintFriendly} printFriendly Print
+ * friendly ticket item.
* @constructor
* @extends {print_preview.SettingsSection}
*/
function OtherOptionsSettings(
- duplex, fitToPage, cssBackground, selectionOnly, headerFooter) {
+ duplex, fitToPage, cssBackground, selectionOnly,
+ headerFooter, printFriendly) {
print_preview.SettingsSection.call(this);
/**
@@ -59,6 +62,27 @@ cr.define('print_preview', function() {
this.headerFooterTicketItem_ = headerFooter;
/**
+ * Print friendly ticket item, used to read/write.
+ * @type {!print_preview.ticket_items.PrintFriendly}
+ * @private
+ */
+ this.printFriendlyTicketItem_ = printFriendly;
+
+ /**
+ * Print friendly container element.
+ * @type {HTMLElement}
+ * @private
+ */
+ this.printFriendlyContainer_ = null;
+
+ /**
+ * Print friendly checkbox.
+ * @type {HTMLInputElement}
+ * @private
+ */
+ this.printFriendlyCheckbox_ = null;
+
+ /**
* Header footer container element.
* @type {HTMLElement}
* @private
@@ -134,7 +158,8 @@ cr.define('print_preview', function() {
/** @override */
isAvailable: function() {
- return this.headerFooterTicketItem_.isCapabilityAvailable() ||
+ return this.printFriendlyTicketItem_.isCapabilityAvailable() ||
+ this.headerFooterTicketItem_.isCapabilityAvailable() ||
this.fitToPageTicketItem_.isCapabilityAvailable() ||
this.duplexTicketItem_.isCapabilityAvailable() ||
this.cssBackgroundTicketItem_.isCapabilityAvailable() ||
@@ -154,6 +179,7 @@ cr.define('print_preview', function() {
this.headerFooterCheckbox_.disabled = !isEnabled;
this.fitToPageCheckbox_.disabled = !isEnabled;
this.duplexCheckbox_.disabled = !isEnabled;
+ this.printFriendlyCheckbox_.disabled = !isEnabled;
this.cssBackgroundCheckbox_.disabled = !isEnabled;
},
@@ -161,6 +187,10 @@ cr.define('print_preview', function() {
enterDocument: function() {
print_preview.SettingsSection.prototype.enterDocument.call(this);
this.tracker.add(
+ this.printFriendlyCheckbox_,
+ 'click',
+ this.onPrintFriendlyCheckboxClick_.bind(this));
+ this.tracker.add(
this.headerFooterCheckbox_,
'click',
this.onHeaderFooterCheckboxClick_.bind(this));
@@ -200,11 +230,17 @@ cr.define('print_preview', function() {
this.headerFooterTicketItem_,
print_preview.ticket_items.TicketItem.EventType.CHANGE,
this.onHeaderFooterChange_.bind(this));
+ this.tracker.add(
+ this.printFriendlyTicketItem_,
+ print_preview.ticket_items.TicketItem.EventType.CHANGE,
+ this.onPrintFriendlyChange_.bind(this));
},
/** @override */
exitDocument: function() {
print_preview.SettingsSection.prototype.exitDocument.call(this);
+ this.printFriendlyContainer_ = null;
+ this.printFriendlyCheckbox_ = null;
this.headerFooterContainer_ = null;
this.headerFooterCheckbox_ = null;
this.fitToPageContainer_ = null;
@@ -219,6 +255,10 @@ cr.define('print_preview', function() {
/** @override */
decorateInternal: function() {
+ this.printFriendlyContainer_ = this.getElement().querySelector(
+ '.print-friendly-container');
+ this.printFriendlyCheckbox_ = this.printFriendlyContainer_.querySelector(
+ '.print-friendly-checkbox');
this.headerFooterContainer_ = this.getElement().querySelector(
'.header-footer-container');
this.headerFooterCheckbox_ = this.headerFooterContainer_.querySelector(
@@ -244,6 +284,8 @@ cr.define('print_preview', function() {
/** @override */
updateUiStateInternal: function() {
if (this.isAvailable()) {
+ setIsVisible(this.printFriendlyContainer_,
+ this.printFriendlyTicketItem_.isCapabilityAvailable());
setIsVisible(this.headerFooterContainer_,
this.headerFooterTicketItem_.isCapabilityAvailable() &&
!this.collapseContent);
@@ -264,11 +306,24 @@ cr.define('print_preview', function() {
/** @override */
isSectionVisibleInternal: function() {
- return this.collapseContent ?
- this.duplexTicketItem_.isCapabilityAvailable() : this.isAvailable();
+ if (this.collapseContent)
+ return this.printFriendlyTicketItem_.isCapabilityAvailable() ||
+ this.duplexTicketItem_.isCapabilityAvailable();
Aleksey Shlyapnikov 2015/07/07 01:26:18 if (this.collapseContent) { ... }
+
+ return this.isAvailable();
},
/**
+ * Called when the print-friendly checkbox is clicked. Updates the print
+ * ticket.
+ * @private
+ */
+ onPrintFriendlyCheckboxClick_: function() {
+ this.printFriendlyTicketItem_.updateValue(
+ this.printFriendlyCheckbox_.checked);
+ },
+
+ /**
* Called when the header-footer checkbox is clicked. Updates the print
* ticket.
* @private
@@ -366,6 +421,17 @@ cr.define('print_preview', function() {
this.headerFooterCheckbox_.checked =
this.headerFooterTicketItem_.getValue();
this.updateUiStateInternal();
+ },
+
+ /**
+ * Called when the print-friendly ticket item has changed. Updates the
+ * print-friendly checkbox.
+ * @private
+ */
+ onPrintFriendlyChange_: function() {
+ this.printFriendlyCheckbox_.checked =
+ this.printFriendlyTicketItem_.getValue();
+ this.updateUiStateInternal();
}
};

Powered by Google App Engine
This is Rietveld 408576698