| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = | 162 var summaryLabel = |
| 163 loadTimeData.getString('printPreviewSheetsLabelSingular'); | 163 loadTimeData.getString('printPreviewSheetsLabelSingular'); |
| 164 var pagesLabel = loadTimeData.getString('printPreviewPageLabelPlural'); | 164 var pagesLabel = loadTimeData.getString('printPreviewPageLabelPlural'); |
| 165 | 165 |
| 166 var saveToPdf = this.destinationStore_.selectedDestination && | 166 var saveToPdfOrDrive = this.destinationStore_.selectedDestination && |
| 167 this.destinationStore_.selectedDestination.id == | 167 (this.destinationStore_.selectedDestination.id == |
| 168 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; | 168 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF || |
| 169 if (saveToPdf) { | 169 this.destinationStore_.selectedDestination.id == |
| 170 print_preview.Destination.GooglePromotedId.DOCS); |
| 171 if (saveToPdfOrDrive) { |
| 170 summaryLabel = loadTimeData.getString('printPreviewPageLabelSingular'); | 172 summaryLabel = loadTimeData.getString('printPreviewPageLabelSingular'); |
| 171 } | 173 } |
| 172 | 174 |
| 173 var numPages = this.printTicketStore_.pageRange.getPageNumberSet().size; | 175 var numPages = this.printTicketStore_.pageRange.getPageNumberSet().size; |
| 174 var numSheets = numPages; | 176 var numSheets = numPages; |
| 175 if (!saveToPdf && this.printTicketStore_.duplex.getValue()) { | 177 if (!saveToPdfOrDrive && this.printTicketStore_.duplex.getValue()) { |
| 176 numSheets = Math.ceil(numPages / 2); | 178 numSheets = Math.ceil(numPages / 2); |
| 177 } | 179 } |
| 178 | 180 |
| 179 var copies = this.printTicketStore_.copies.getValueAsNumber(); | 181 var copies = this.printTicketStore_.copies.getValueAsNumber(); |
| 180 numSheets *= copies; | 182 numSheets *= copies; |
| 181 numPages *= copies; | 183 numPages *= copies; |
| 182 | 184 |
| 183 if (numSheets > 1) { | 185 if (numSheets > 1) { |
| 184 summaryLabel = saveToPdf ? pagesLabel : | 186 summaryLabel = saveToPdfOrDrive ? pagesLabel : |
| 185 loadTimeData.getString('printPreviewSheetsLabelPlural'); | 187 loadTimeData.getString('printPreviewSheetsLabelPlural'); |
| 186 } | 188 } |
| 187 | 189 |
| 188 var html; | 190 var html; |
| 189 var label; | 191 var label; |
| 190 if (numPages != numSheets) { | 192 if (numPages != numSheets) { |
| 191 html = loadTimeData.getStringF( | 193 html = loadTimeData.getStringF( |
| 192 'printPreviewSummaryFormatLong', | 194 'printPreviewSummaryFormatLong', |
| 193 '<b>' + numSheets.toLocaleString() + '</b>', | 195 '<b>' + numSheets.toLocaleString() + '</b>', |
| 194 '<b>' + summaryLabel + '</b>', | 196 '<b>' + summaryLabel + '</b>', |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 this.getChildElement('button.print').focus(); | 277 this.getChildElement('button.print').focus(); |
| 276 } | 278 } |
| 277 } | 279 } |
| 278 }; | 280 }; |
| 279 | 281 |
| 280 // Export | 282 // Export |
| 281 return { | 283 return { |
| 282 PrintHeader: PrintHeader | 284 PrintHeader: PrintHeader |
| 283 }; | 285 }; |
| 284 }); | 286 }); |
| OLD | NEW |