| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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.ticket_items', function() { | 5 cr.define('print_preview.ticket_items', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Scaling ticket item whose value is a {@code string} that indicates what the | 9 * Scaling ticket item whose value is a {@code string} that indicates what the |
| 10 * scaling (in percent) of the document should be. The ticket item is backed | 10 * scaling (in percent) of the document should be. The ticket item is backed |
| 11 * by a string since the user can textually input the scaling value. | 11 * by a string since the user can textually input the scaling value. |
| 12 * @param {!print_preview.AppState} appState App state to persist item value. | 12 * @param {!print_preview.AppState} appState App state to persist item value. |
| 13 * @param {!print_preview.DocumentInfo} documentInfo Information about the | 13 * @param {!print_preview.DocumentInfo} documentInfo Information about the |
| 14 * document to print. | 14 * document to print. |
| 15 * @param {!print_preview.DestinationStore} destinationStore Used to determine | 15 * @param {!print_preview.DestinationStore} destinationStore Used to determine |
| 16 * whether fit to page should be available. | 16 * whether fit to page should be available. |
| 17 * @constructor | 17 * @constructor |
| 18 * @extends {print_preview.ticket_items.TicketItem} | 18 * @extends {print_preview.ticket_items.TicketItem} |
| 19 */ | 19 */ |
| 20 function Scaling(appState, destinationStore, documentInfo) { | 20 function Scaling(appState, destinationStore, documentInfo) { |
| 21 print_preview.ticket_items.TicketItem.call( | 21 print_preview.ticket_items.TicketItem.call( |
| 22 this, | 22 this, appState, print_preview.AppStateField.SCALING, destinationStore, |
| 23 appState, | |
| 24 print_preview.AppStateField.SCALING, | |
| 25 destinationStore, | |
| 26 documentInfo); | 23 documentInfo); |
| 27 } | 24 } |
| 28 | 25 |
| 29 Scaling.prototype = { | 26 Scaling.prototype = { |
| 30 __proto__: print_preview.ticket_items.TicketItem.prototype, | 27 __proto__: print_preview.ticket_items.TicketItem.prototype, |
| 31 | 28 |
| 32 /** @override */ | 29 /** @override */ |
| 33 wouldValueBeValid: function(value) { | 30 wouldValueBeValid: function(value) { |
| 34 return true; | 31 return true; |
| 35 }, | 32 }, |
| 36 | 33 |
| 37 /** @override */ | 34 /** @override */ |
| 38 isValueEqual: function(value) { | 35 isValueEqual: function(value) { |
| 39 return this.getValueAsNumber() == value; | 36 return this.getValueAsNumber() == value; |
| 40 }, | 37 }, |
| 41 | 38 |
| 42 /** @override */ | 39 /** @override */ |
| 43 isCapabilityAvailable: function() { | 40 isCapabilityAvailable: function() { |
| 44 // This is not a function of the printer, but should be disabled if we are | 41 // This is not a function of the printer, but should be disabled if we are |
| 45 // saving a PDF to a PDF. | 42 // saving a PDF to a PDF. |
| 46 var knownSizeToSaveAsPdf = | 43 var knownSizeToSaveAsPdf = |
| 47 (!this.getDocumentInfoInternal().isModifiable || | 44 (!this.getDocumentInfoInternal().isModifiable || |
| 48 this.getDocumentInfoInternal().hasCssMediaStyles) && | 45 this.getDocumentInfoInternal().hasCssMediaStyles) && |
| 49 this.getSelectedDestInternal() && | 46 this.getSelectedDestInternal() && |
| 50 this.getSelectedDestInternal().id == | 47 this.getSelectedDestInternal().id == |
| 51 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; | 48 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; |
| 52 return !knownSizeToSaveAsPdf; | 49 return !knownSizeToSaveAsPdf; |
| 53 }, | 50 }, |
| 54 | 51 |
| 55 /** @return {number} The scaling percentage indicated by the ticket item. */ | 52 /** @return {number} The scaling percentage indicated by the ticket item. */ |
| 56 getValueAsNumber: function() { | 53 getValueAsNumber: function() { |
| 57 return parseInt(this.getValue(), 10); | 54 return parseInt(this.getValue(), 10); |
| 58 }, | 55 }, |
| 59 | 56 |
| 60 /** @override */ | 57 /** @override */ |
| 61 getDefaultValueInternal: function() { | 58 getDefaultValueInternal: function() { |
| 62 return '100'; | 59 return '100'; |
| 63 }, | 60 }, |
| 64 | 61 |
| 65 /** @override */ | 62 /** @override */ |
| 66 getCapabilityNotAvailableValueInternal: function() { | 63 getCapabilityNotAvailableValueInternal: function() { |
| 67 return '100'; | 64 return '100'; |
| 68 }, | 65 }, |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 // Export | 68 // Export |
| 72 return { | 69 return {Scaling: Scaling}; |
| 73 Scaling: Scaling | |
| 74 }; | |
| 75 }); | 70 }); |
| OLD | NEW |