| 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 |
| 11 * be unavailable for modifying if the print destination doesn't support it or | 11 * be unavailable for modifying if the print destination doesn't support it or |
| 12 * if other ticket item constraints are not met. | 12 * if other ticket item constraints are not met. |
| 13 * @param {print_preview.AppState=} appState Application state model to update | 13 * @param {print_preview.AppState=} appState Application state model to update |
| 14 * when ticket items update. | 14 * when ticket items update. |
| 15 * @param {print_preview.AppState.Field=} field Field of the app state to | 15 * @param {print_preview.AppState.Field=} field Field of the app state to |
| 16 * update when ticket item is updated. | 16 * update when ticket item is updated. |
| 17 * @param {print_preview.DestinationStore=} destinationStore Used listen for | 17 * @param {print_preview.DestinationStore=} destinationStore Used listen for |
| 18 * changes in the currently selected destination's capabilities. Since | 18 * changes in the currently selected destination's capabilities. Since |
| 19 * this is a common dependency of ticket items, it's handled in the base | 19 * this is a common dependency of ticket items, it's handled in the base |
| 20 * class. | 20 * class. |
| 21 * @param {print_preview.DocumentInfo=} documentInfo Used to listen for | 21 * @param {print_preview.DocumentInfo=} documentInfo Used to listen for |
| 22 * changes in the document. Since this is a common dependency of ticket | 22 * changes in the document. Since this is a common dependency of ticket |
| 23 * items, it's handled in the base class. | 23 * items, it's handled in the base class. |
| 24 * @constructor | 24 * @constructor |
| 25 * @extends {cr.EventTarget} |
| 25 */ | 26 */ |
| 26 function TicketItem(appState, field, destinationStore, documentInfo) { | 27 function TicketItem(appState, field, destinationStore, documentInfo) { |
| 27 cr.EventTarget.call(this); | 28 cr.EventTarget.call(this); |
| 28 | 29 |
| 29 /** | 30 /** |
| 30 * Application state model to update when ticket items update. | 31 * Application state model to update when ticket items update. |
| 31 * @type {print_preview.AppState} | 32 * @type {print_preview.AppState} |
| 32 * @private | 33 * @private |
| 33 */ | 34 */ |
| 34 this.appState_ = appState || null; | 35 this.appState_ = appState || null; |
| 35 | 36 |
| 36 /** | 37 /** |
| 37 * Field of the app state to update when ticket item is updated. | 38 * Field of the app state to update when ticket item is updated. |
| 38 * @type {print_preview.AppState.Field} | 39 * @type {?print_preview.AppState.Field} |
| 39 * @private | 40 * @private |
| 40 */ | 41 */ |
| 41 this.field_ = field || null; | 42 this.field_ = field || null; |
| 42 | 43 |
| 43 /** | 44 /** |
| 44 * Used listen for changes in the currently selected destination's | 45 * Used listen for changes in the currently selected destination's |
| 45 * capabilities. | 46 * capabilities. |
| 46 * @type {print_preview.DestinationStore} | 47 * @type {print_preview.DestinationStore} |
| 47 * @private | 48 * @private |
| 48 */ | 49 */ |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // Don't lose requested value if capability is not available. | 142 // Don't lose requested value if capability is not available. |
| 142 this.updateValueInternal(value); | 143 this.updateValueInternal(value); |
| 143 if (this.appState_) { | 144 if (this.appState_) { |
| 144 this.appState_.persistField(this.field_, value); | 145 this.appState_.persistField(this.field_, value); |
| 145 } | 146 } |
| 146 if (sendUpdateEvent) | 147 if (sendUpdateEvent) |
| 147 cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE); | 148 cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE); |
| 148 }, | 149 }, |
| 149 | 150 |
| 150 /** | 151 /** |
| 151 * @return {!Object} Default value of the ticket item if no value was set by | 152 * @return {?} Default value of the ticket item if no value was set by |
| 152 * the user. | 153 * the user. |
| 153 * @protected | 154 * @protected |
| 154 */ | 155 */ |
| 155 getDefaultValueInternal: function() { | 156 getDefaultValueInternal: function() { |
| 156 throw Error('Abstract method not overridden'); | 157 throw Error('Abstract method not overridden'); |
| 157 }, | 158 }, |
| 158 | 159 |
| 159 /** | 160 /** |
| 160 * @return {!Object} Default value of the ticket item if the capability is | 161 * @return {?} Default value of the ticket item if the capability is |
| 161 * not available. | 162 * not available. |
| 162 * @protected | 163 * @protected |
| 163 */ | 164 */ |
| 164 getCapabilityNotAvailableValueInternal: function() { | 165 getCapabilityNotAvailableValueInternal: function() { |
| 165 throw Error('Abstract method not overridden'); | 166 throw Error('Abstract method not overridden'); |
| 166 }, | 167 }, |
| 167 | 168 |
| 168 /** | 169 /** |
| 169 * @return {!EventTracker} Event tracker to keep track of events from | 170 * @return {!EventTracker} Event tracker to keep track of events from |
| 170 * dependencies. | 171 * dependencies. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 this.dispatchChangeEventInternal.bind(this)); | 230 this.dispatchChangeEventInternal.bind(this)); |
| 230 } | 231 } |
| 231 }, | 232 }, |
| 232 }; | 233 }; |
| 233 | 234 |
| 234 // Export | 235 // Export |
| 235 return { | 236 return { |
| 236 TicketItem: TicketItem | 237 TicketItem: TicketItem |
| 237 }; | 238 }; |
| 238 }); | 239 }); |
| OLD | NEW |