| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * @param {Object} value Value to compare to the value of this ticket item. | 129 * @param {Object} value Value to compare to the value of this ticket item. |
| 130 * @return {boolean} Whether the given value is equal to the value of the | 130 * @return {boolean} Whether the given value is equal to the value of the |
| 131 * ticket item. | 131 * ticket item. |
| 132 */ | 132 */ |
| 133 isValueEqual: function(value) { | 133 isValueEqual: function(value) { |
| 134 return this.getValue() == value; | 134 return this.getValue() == value; |
| 135 }, | 135 }, |
| 136 | 136 |
| 137 /** @param {!Object} Value to set as the value of the ticket item. */ | 137 /** @param {!Object} value Value to set as the value of the ticket item. */ |
| 138 updateValue: function(value) { | 138 updateValue: function(value) { |
| 139 // Use comparison with capabilities for event. | 139 // Use comparison with capabilities for event. |
| 140 var sendUpdateEvent = !this.isValueEqual(value); | 140 var sendUpdateEvent = !this.isValueEqual(value); |
| 141 // Don't lose requested value if capability is not available. | 141 // Don't lose requested value if capability is not available. |
| 142 this.updateValueInternal(value); | 142 this.updateValueInternal(value); |
| 143 if (this.appState_) { | 143 if (this.appState_) { |
| 144 this.appState_.persistField(this.field_, value); | 144 this.appState_.persistField(this.field_, value); |
| 145 } | 145 } |
| 146 if (sendUpdateEvent) | 146 if (sendUpdateEvent) |
| 147 cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE); | 147 cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 this.dispatchChangeEventInternal.bind(this)); | 229 this.dispatchChangeEventInternal.bind(this)); |
| 230 } | 230 } |
| 231 }, | 231 }, |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 // Export | 234 // Export |
| 235 return { | 235 return { |
| 236 TicketItem: TicketItem | 236 TicketItem: TicketItem |
| 237 }; | 237 }; |
| 238 }); | 238 }); |
| OLD | NEW |