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 * Creates a PrintHeader object. This object encapsulates all the elements | 9 * Creates a PrintHeader object. This object encapsulates all the elements |
| 10 * and logic related to the top part of the left pane in print_preview.html. | 10 * and logic related to the top part of the left pane in print_preview.html. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 /** | 152 /** |
| 153 * Updates the summary element based on the currently selected user options. | 153 * Updates the summary element based on the currently selected user options. |
| 154 * @private | 154 * @private |
| 155 */ | 155 */ |
| 156 updateSummary_: function() { | 156 updateSummary_: function() { |
| 157 if (!this.printTicketStore_.isTicketValid()) { | 157 if (!this.printTicketStore_.isTicketValid()) { |
| 158 this.getChildElement('.summary').innerHTML = ''; | 158 this.getChildElement('.summary').innerHTML = ''; |
| 159 return; | 159 return; |
| 160 } | 160 } |
| 161 | 161 |
| 162 var summaryLabel = | |
| 163 loadTimeData.getString('printPreviewSheetsLabelSingular'); | |
| 164 var pagesLabel = loadTimeData.getString('printPreviewPageLabelPlural'); | |
| 165 | |
| 166 var saveToPdfOrDrive = this.destinationStore_.selectedDestination && | 162 var saveToPdfOrDrive = this.destinationStore_.selectedDestination && |
| 167 (this.destinationStore_.selectedDestination.id == | 163 (this.destinationStore_.selectedDestination.id == |
| 168 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF || | 164 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF || |
| 169 this.destinationStore_.selectedDestination.id == | 165 this.destinationStore_.selectedDestination.id == |
| 170 print_preview.Destination.GooglePromotedId.DOCS); | 166 print_preview.Destination.GooglePromotedId.DOCS); |
| 171 if (saveToPdfOrDrive) { | |
| 172 summaryLabel = loadTimeData.getString('printPreviewPageLabelSingular'); | |
| 173 } | |
| 174 | 167 |
| 175 var numPages = this.printTicketStore_.pageRange.getPageNumberSet().size; | 168 var numPages = this.printTicketStore_.pageRange.getPageNumberSet().size; |
| 176 var numSheets = numPages; | 169 var numSheets = numPages; |
| 177 if (!saveToPdfOrDrive && this.printTicketStore_.duplex.getValue()) { | 170 if (!saveToPdfOrDrive && this.printTicketStore_.duplex.getValue()) { |
| 178 numSheets = Math.ceil(numPages / 2); | 171 numSheets = Math.ceil(numPages / 2); |
| 179 } | 172 } |
| 180 | 173 |
| 181 var copies = this.printTicketStore_.copies.getValueAsNumber(); | 174 var copies = this.printTicketStore_.copies.getValueAsNumber(); |
| 182 numSheets *= copies; | 175 numSheets *= copies; |
| 183 numPages *= copies; | 176 numPages *= copies; |
| 184 | 177 |
| 178 var pagesLabel = loadTimeData.getString('printPreviewPageLabelPlural'); | |
| 179 var summaryLabel; | |
| 185 if (numSheets > 1) { | 180 if (numSheets > 1) { |
| 186 summaryLabel = saveToPdfOrDrive ? pagesLabel : | 181 summaryLabel = saveToPdfOrDrive ? pagesLabel : |
| 187 loadTimeData.getString('printPreviewSheetsLabelPlural'); | 182 loadTimeData.getString('printPreviewSheetsLabelPlural'); |
| 183 } else { | |
| 184 summaryLabel = saveToPdfOrDrive ? | |
|
dpapad
2017/04/24 17:23:40
Nit: Can be compacted even further as follows:
su
Lei Zhang
2017/04/24 23:12:17
Done.
| |
| 185 loadTimeData.getString('printPreviewPageLabelSingular') : | |
| 186 loadTimeData.getString('printPreviewSheetsLabelSingular'); | |
| 188 } | 187 } |
| 189 | 188 |
| 190 var html; | 189 var html; |
| 191 var label; | 190 var label; |
| 192 if (numPages != numSheets) { | 191 if (numPages != numSheets) { |
| 193 html = loadTimeData.getStringF( | 192 html = loadTimeData.getStringF( |
| 194 'printPreviewSummaryFormatLong', | 193 'printPreviewSummaryFormatLong', |
| 195 '<b>' + numSheets.toLocaleString() + '</b>', | 194 '<b>' + numSheets.toLocaleString() + '</b>', |
| 196 '<b>' + summaryLabel + '</b>', | 195 '<b>' + summaryLabel + '</b>', |
| 197 numPages.toLocaleString(), | 196 numPages.toLocaleString(), |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 this.getChildElement('button.print').focus(); | 276 this.getChildElement('button.print').focus(); |
| 278 } | 277 } |
| 279 } | 278 } |
| 280 }; | 279 }; |
| 281 | 280 |
| 282 // Export | 281 // Export |
| 283 return { | 282 return { |
| 284 PrintHeader: PrintHeader | 283 PrintHeader: PrintHeader |
| 285 }; | 284 }; |
| 286 }); | 285 }); |
| OLD | NEW |