| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 throw Error('Abstract method not overridden'); | 93 throw Error('Abstract method not overridden'); |
| 94 }, | 94 }, |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * @return {boolean} Whether the print destination capability is available. | 97 * @return {boolean} Whether the print destination capability is available. |
| 98 */ | 98 */ |
| 99 isCapabilityAvailable: function() { | 99 isCapabilityAvailable: function() { |
| 100 throw Error('Abstract method not overridden'); | 100 throw Error('Abstract method not overridden'); |
| 101 }, | 101 }, |
| 102 | 102 |
| 103 /** @return {print_preview.ValueType} The value of the ticket item. */ | 103 /** @return {?} The value of the ticket item. */ |
| 104 getValue: function() { | 104 getValue: function() { |
| 105 if (this.isCapabilityAvailable()) { | 105 if (this.isCapabilityAvailable()) { |
| 106 if (this.value_ == null) { | 106 if (this.value_ == null) { |
| 107 return this.getDefaultValueInternal(); | 107 return this.getDefaultValueInternal(); |
| 108 } else { | 108 } else { |
| 109 return this.value_; | 109 return this.value_; |
| 110 } | 110 } |
| 111 } else { | 111 } else { |
| 112 return this.getCapabilityNotAvailableValueInternal(); | 112 return this.getCapabilityNotAvailableValueInternal(); |
| 113 } | 113 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 137 | 137 |
| 138 /** | 138 /** |
| 139 * @param {?} value Value to set as the value of the ticket item. | 139 * @param {?} value Value to set as the value of the ticket item. |
| 140 */ | 140 */ |
| 141 updateValue: function(value) { | 141 updateValue: function(value) { |
| 142 // Use comparison with capabilities for event. | 142 // Use comparison with capabilities for event. |
| 143 var sendUpdateEvent = !this.isValueEqual(value); | 143 var sendUpdateEvent = !this.isValueEqual(value); |
| 144 // Don't lose requested value if capability is not available. | 144 // Don't lose requested value if capability is not available. |
| 145 this.updateValueInternal(value); | 145 this.updateValueInternal(value); |
| 146 if (this.appState_) { | 146 if (this.appState_) { |
| 147 this.appState_.persistField(this.field_, value); | 147 this.appState_.persistField(assert(this.field_), value); |
| 148 } | 148 } |
| 149 if (sendUpdateEvent) | 149 if (sendUpdateEvent) |
| 150 cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE); | 150 cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE); |
| 151 }, | 151 }, |
| 152 | 152 |
| 153 /** | 153 /** |
| 154 * @return {?} Default value of the ticket item if no value was set by | 154 * @return {?} Default value of the ticket item if no value was set by |
| 155 * the user. | 155 * the user. |
| 156 * @protected | 156 * @protected |
| 157 */ | 157 */ |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 this.dispatchChangeEventInternal.bind(this)); | 232 this.dispatchChangeEventInternal.bind(this)); |
| 233 } | 233 } |
| 234 }, | 234 }, |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 // Export | 237 // Export |
| 238 return { | 238 return { |
| 239 TicketItem: TicketItem | 239 TicketItem: TicketItem |
| 240 }; | 240 }; |
| 241 }); | 241 }); |
| OLD | NEW |