Chromium Code Reviews| 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..d212a3ff9f5debd099ef44346798e3f97107809b 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); |
| @@ -265,10 +307,21 @@ cr.define('print_preview', function() { |
| /** @override */ |
| isSectionVisibleInternal: function() { |
| return this.collapseContent ? |
| + this.printFriendlyTicketItem_.isCapabilityAvailable() || |
| this.duplexTicketItem_.isCapabilityAvailable() : this.isAvailable(); |
|
Aleksey Shlyapnikov
2015/07/01 23:23:51
Convert it to regular if statement, it's too big t
|
| }, |
| /** |
| + * 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 +419,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(); |
| } |
| }; |