OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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', function() { | 5 cr.define('print_preview', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Print options section to control printer advanced options. | 9 * Print options section to control printer advanced options. |
| 10 * @param {!print_preview.ticket_item.VendorItems} ticketItem Ticket item to |
| 11 * check settings availability. |
10 * @param {!print_preview.DestinationStore} destinationStore Used to determine | 12 * @param {!print_preview.DestinationStore} destinationStore Used to determine |
11 * the selected destination. | 13 * the selected destination. |
12 * @constructor | 14 * @constructor |
13 * @extends {print_preview.SettingsSection} | 15 * @extends {print_preview.SettingsSection} |
14 */ | 16 */ |
15 function AdvancedOptionsSettings(destinationStore) { | 17 function AdvancedOptionsSettings(ticketItem, destinationStore) { |
16 print_preview.SettingsSection.call(this); | 18 print_preview.SettingsSection.call(this); |
17 | 19 |
18 /** | 20 /** |
| 21 * Ticket item to check settings availability. |
| 22 * @private {!print_preview.ticket_items.VendorItems} |
| 23 */ |
| 24 this.ticketItem_ = ticketItem; |
| 25 |
| 26 /** |
19 * Used to determine the selected destination. | 27 * Used to determine the selected destination. |
20 * @private {!print_preview.DestinationStore} | 28 * @private {!print_preview.DestinationStore} |
21 */ | 29 */ |
22 this.destinationStore_ = destinationStore; | 30 this.destinationStore_ = destinationStore; |
23 }; | 31 }; |
24 | 32 |
25 /** | 33 /** |
26 * Event types dispatched by the component. | 34 * Event types dispatched by the component. |
27 * @enum {string} | 35 * @enum {string} |
28 */ | 36 */ |
29 AdvancedOptionsSettings.EventType = { | 37 AdvancedOptionsSettings.EventType = { |
30 BUTTON_ACTIVATED: 'print_preview.AdvancedOptionsSettings.BUTTON_ACTIVATED' | 38 BUTTON_ACTIVATED: 'print_preview.AdvancedOptionsSettings.BUTTON_ACTIVATED' |
31 }; | 39 }; |
32 | 40 |
33 AdvancedOptionsSettings.prototype = { | 41 AdvancedOptionsSettings.prototype = { |
34 __proto__: print_preview.SettingsSection.prototype, | 42 __proto__: print_preview.SettingsSection.prototype, |
35 | 43 |
36 /** @override */ | 44 /** @override */ |
37 isAvailable: function() { | 45 isAvailable: function() { |
38 var destination = this.destinationStore_.selectedDestination; | 46 return this.ticketItem_.isCapabilityAvailable(); |
39 var vendorCapabilities = | |
40 destination && | |
41 destination.capabilities && | |
42 destination.capabilities.printer && | |
43 destination.capabilities.printer.vendor_capability; | |
44 return !!vendorCapabilities; | |
45 }, | 47 }, |
46 | 48 |
47 /** @override */ | 49 /** @override */ |
48 hasCollapsibleContent: function() { | 50 hasCollapsibleContent: function() { |
49 return this.isAvailable(); | 51 return this.isAvailable(); |
50 }, | 52 }, |
51 | 53 |
52 /** @param {boolean} isEnabled Whether the component is enabled. */ | 54 /** @param {boolean} isEnabled Whether the component is enabled. */ |
53 set isEnabled(isEnabled) { | 55 set isEnabled(isEnabled) { |
54 this.getButton_().disabled = !isEnabled; | 56 this.getButton_().disabled = !isEnabled; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 onDestinationChanged_: function() { | 91 onDestinationChanged_: function() { |
90 this.updateUiStateInternal(); | 92 this.updateUiStateInternal(); |
91 } | 93 } |
92 }; | 94 }; |
93 | 95 |
94 // Export | 96 // Export |
95 return { | 97 return { |
96 AdvancedOptionsSettings: AdvancedOptionsSettings | 98 AdvancedOptionsSettings: AdvancedOptionsSettings |
97 }; | 99 }; |
98 }); | 100 }); |
OLD | NEW |