Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Represents a single option in the Other Options settings section. | 9 * Represents a single option in the Other Options settings section. |
| 10 * @param {!print_preview.ticket_items.TicketItem} ticketItem The ticket item | 10 * @param {!print_preview.ticket_items.TicketItem} ticketItem The ticket item |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 * UI component that renders checkboxes for various print options. | 120 * UI component that renders checkboxes for various print options. |
| 121 * @param {!print_preview.ticket_items.Duplex} duplex Duplex ticket item. | 121 * @param {!print_preview.ticket_items.Duplex} duplex Duplex ticket item. |
| 122 * @param {!print_preview.ticket_items.FitToPage} fitToPage Fit-to-page ticket | 122 * @param {!print_preview.ticket_items.FitToPage} fitToPage Fit-to-page ticket |
| 123 * item. | 123 * item. |
| 124 * @param {!print_preview.ticket_items.CssBackground} cssBackground CSS | 124 * @param {!print_preview.ticket_items.CssBackground} cssBackground CSS |
| 125 * background ticket item. | 125 * background ticket item. |
| 126 * @param {!print_preview.ticket_items.SelectionOnly} selectionOnly Selection | 126 * @param {!print_preview.ticket_items.SelectionOnly} selectionOnly Selection |
| 127 * only ticket item. | 127 * only ticket item. |
| 128 * @param {!print_preview.ticket_items.HeaderFooter} headerFooter Header | 128 * @param {!print_preview.ticket_items.HeaderFooter} headerFooter Header |
| 129 * footer ticket item. | 129 * footer ticket item. |
| 130 * @param {!print_preview.ticket_items.Rasterize} rasterize Rasterize ticket | |
| 131 * item. | |
| 130 * @constructor | 132 * @constructor |
| 131 * @extends {print_preview.SettingsSection} | 133 * @extends {print_preview.SettingsSection} |
| 132 */ | 134 */ |
| 133 function OtherOptionsSettings( | 135 function OtherOptionsSettings( |
| 134 duplex, fitToPage, cssBackground, selectionOnly, headerFooter) { | 136 duplex, fitToPage, cssBackground, selectionOnly, headerFooter, |
| 137 rasterize) { | |
| 135 print_preview.SettingsSection.call(this); | 138 print_preview.SettingsSection.call(this); |
| 139 /** | |
| 140 * @private {boolean} rasterizeEnabled Whether the print as image feature is | |
| 141 * enabled. | |
| 142 */ | |
| 143 this.rasterizeEnabled_ = loadTimeData.getBoolean('printPdfAsImageEnabled'); | |
| 136 | 144 |
| 137 /* | 145 /** |
| 138 * @private {!Array<!CheckboxTicketItemElement>} checkbox ticket item | 146 * @private {!Array<!CheckboxTicketItemElement>} checkbox ticket item |
| 139 * elements representing the different options in the section. | 147 * elements representing the different options in the section. |
| 140 * Selection only must always be the last element in the array. | 148 * Selection only must always be the last element in the array. |
| 141 */ | 149 */ |
| 142 this.elements_ = [ | 150 this.elements_ = [ |
| 143 new CheckboxTicketItemElement(headerFooter, true, | 151 new CheckboxTicketItemElement(headerFooter, true, |
|
dpapad
2016/12/22 19:27:00
Nit: Indentation should be 2 less.
rbpotter
2016/12/22 22:58:46
Done.
| |
| 144 'header-footer-container'), | 152 'header-footer-container'), |
| 145 new CheckboxTicketItemElement(fitToPage, false, | 153 new CheckboxTicketItemElement(fitToPage, false, |
| 146 'fit-to-page-container'), | 154 'fit-to-page-container'), |
| 147 new CheckboxTicketItemElement(duplex, false, 'duplex-container'), | 155 new CheckboxTicketItemElement(duplex, false, 'duplex-container'), |
| 148 new CheckboxTicketItemElement(cssBackground, true, | 156 new CheckboxTicketItemElement(cssBackground, true, |
| 149 'css-background-container'), | 157 'css-background-container'), |
| 150 new CheckboxTicketItemElement(selectionOnly, true, | 158 new CheckboxTicketItemElement(selectionOnly, true, |
| 151 'selection-only-container') | 159 'selection-only-container') |
| 152 ]; | 160 ]; |
| 153 | 161 if (this.rasterizeEnabled_) { |
| 162 this.elements_.splice(4, 0, new CheckboxTicketItemElement(rasterize, | |
|
dpapad
2016/12/22 19:27:00
Nit: This type of line breaking violates the "rect
rbpotter
2016/12/22 22:58:46
Done.
| |
| 163 true, 'rasterize-container')); | |
| 164 } | |
| 154 }; | 165 }; |
| 155 | 166 |
| 156 OtherOptionsSettings.prototype = { | 167 OtherOptionsSettings.prototype = { |
| 157 __proto__: print_preview.SettingsSection.prototype, | 168 __proto__: print_preview.SettingsSection.prototype, |
| 158 | 169 |
| 159 /** @override */ | 170 /** @override */ |
| 160 isAvailable: function() { | 171 isAvailable: function() { |
| 161 return this.elements_.some(function(element) { | 172 return this.elements_.some(function(element) { |
| 162 return element.ticketItem.isCapabilityAvailable(); | 173 return element.ticketItem.isCapabilityAvailable(); |
| 163 }); | 174 }); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 exitDocument: function() { | 210 exitDocument: function() { |
| 200 print_preview.SettingsSection.prototype.exitDocument.call(this); | 211 print_preview.SettingsSection.prototype.exitDocument.call(this); |
| 201 for (var i = 0; i < this.elements_.length; i++) | 212 for (var i = 0; i < this.elements_.length; i++) |
| 202 this.elements_[i].exitDocument(); | 213 this.elements_[i].exitDocument(); |
| 203 }, | 214 }, |
| 204 | 215 |
| 205 /** @override */ | 216 /** @override */ |
| 206 decorateInternal: function() { | 217 decorateInternal: function() { |
| 207 for (var i = 0; i < this.elements_.length; i++) | 218 for (var i = 0; i < this.elements_.length; i++) |
| 208 this.elements_[i].decorate(); | 219 this.elements_[i].decorate(); |
| 220 if (!this.rasterizeEnabled_) | |
| 221 $('rasterize-container').style.display = 'none'; | |
|
dpapad
2016/12/22 19:27:00
Nit (optional): I think the following would also w
rbpotter
2016/12/22 22:58:46
Done.
| |
| 209 }, | 222 }, |
| 210 | 223 |
| 211 /** @override */ | 224 /** @override */ |
| 212 updateUiStateInternal: function() { | 225 updateUiStateInternal: function() { |
| 213 if (this.isAvailable()) { | 226 if (this.isAvailable()) { |
| 214 for (var i = 0; i < this.elements_.length; i++) | 227 for (var i = 0; i < this.elements_.length; i++) |
| 215 this.elements_[i].setVisibility(this.collapseContent); | 228 this.elements_[i].setVisibility(this.collapseContent); |
| 216 } | 229 } |
| 217 print_preview.SettingsSection.prototype.updateUiStateInternal.call(this); | 230 print_preview.SettingsSection.prototype.updateUiStateInternal.call(this); |
| 218 }, | 231 }, |
| 219 | 232 |
| 220 /** @override */ | 233 /** @override */ |
| 221 isSectionVisibleInternal: function() { | 234 isSectionVisibleInternal: function() { |
| 222 return this.elements_.some(function(element) { | 235 return this.elements_.some(function(element) { |
| 223 return element.isVisible(this.collapseContent); | 236 return element.isVisible(this.collapseContent); |
| 224 }, this); | 237 }, this); |
| 225 }, | 238 }, |
| 226 | 239 |
| 227 }; | 240 }; |
| 228 | 241 |
| 229 // Export | 242 // Export |
| 230 return { | 243 return { |
| 231 OtherOptionsSettings: OtherOptionsSettings | 244 OtherOptionsSettings: OtherOptionsSettings |
| 232 }; | 245 }; |
| 233 }); | 246 }); |
| OLD | NEW |