| 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.ticket_items', function() { | 5 cr.define('print_preview.ticket_items', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * An object that represents a user modifiable item in a print ticket. Each | 9 * An object that represents a user modifiable item in a print ticket. Each |
| 10 * ticket item has a value which can be set by the user. Ticket items can also | 10 * ticket item has a value which can be set by the user. Ticket items can also |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 throw Error('Abstract method not overridden'); | 31 throw Error('Abstract method not overridden'); |
| 32 }, | 32 }, |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * @return {boolean} Whether the print destination capability is available. | 35 * @return {boolean} Whether the print destination capability is available. |
| 36 */ | 36 */ |
| 37 isCapabilityAvailable: function() { | 37 isCapabilityAvailable: function() { |
| 38 throw Error('Abstract method not overridden'); | 38 throw Error('Abstract method not overridden'); |
| 39 }, | 39 }, |
| 40 | 40 |
| 41 /** @return {object} The value of the ticket item. */ | 41 /** @return {!Object} The value of the ticket item. */ |
| 42 getValue: function() { | 42 getValue: function() { |
| 43 if (this.isCapabilityAvailable()) { | 43 if (this.isCapabilityAvailable()) { |
| 44 if (this.value_ == null) { | 44 if (this.value_ == null) { |
| 45 return this.getDefaultValueInternal(); | 45 return this.getDefaultValueInternal(); |
| 46 } else { | 46 } else { |
| 47 return this.value_; | 47 return this.value_; |
| 48 } | 48 } |
| 49 } else { | 49 } else { |
| 50 return this.getCapabilityNotAvailableValueInternal(); | 50 return this.getCapabilityNotAvailableValueInternal(); |
| 51 } | 51 } |
| 52 }, | 52 }, |
| 53 | 53 |
| 54 /** @return {boolean} Whether the ticket item was modified by the user. */ | 54 /** @return {boolean} Whether the ticket item was modified by the user. */ |
| 55 isUserEdited: function() { | 55 isUserEdited: function() { |
| 56 return this.value_ != null; | 56 return this.value_ != null; |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 /** @return {boolean} Whether the ticket item's value is valid. */ | 59 /** @return {boolean} Whether the ticket item's value is valid. */ |
| 60 isValid: function() { | 60 isValid: function() { |
| 61 if (!this.isUserEdited()) { | 61 if (!this.isUserEdited()) { |
| 62 return true; | 62 return true; |
| 63 } | 63 } |
| 64 return this.wouldValueBeValid(this.value_); | 64 return this.wouldValueBeValid(this.value_); |
| 65 }, | 65 }, |
| 66 | 66 |
| 67 /** @param {object} Value to set as the value of the ticket item. */ | 67 /** @param {!Object} Value to set as the value of the ticket item. */ |
| 68 updateValue: function(value) { | 68 updateValue: function(value) { |
| 69 this.value_ = value; | 69 this.value_ = value; |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * @return {object} Default value of the ticket item if no value was set by | 73 * @return {!Object} Default value of the ticket item if no value was set by |
| 74 * the user. | 74 * the user. |
| 75 * @protected | 75 * @protected |
| 76 */ | 76 */ |
| 77 getDefaultValueInternal: function() { | 77 getDefaultValueInternal: function() { |
| 78 throw Error('Abstract method not overridden'); | 78 throw Error('Abstract method not overridden'); |
| 79 }, | 79 }, |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * @return {object} Default value of the ticket item if the capability is | 82 * @return {!Object} Default value of the ticket item if the capability is |
| 83 * not available. | 83 * not available. |
| 84 * @protected | 84 * @protected |
| 85 */ | 85 */ |
| 86 getCapabilityNotAvailableValueInternal: function() { | 86 getCapabilityNotAvailableValueInternal: function() { |
| 87 throw Error('Abstract method not overridden'); | 87 throw Error('Abstract method not overridden'); |
| 88 } | 88 } |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // Export | 91 // Export |
| 92 return { | 92 return { |
| 93 TicketItem: TicketItem | 93 TicketItem: TicketItem |
| 94 }; | 94 }; |
| 95 }); | 95 }); |
| OLD | NEW |