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 * Base class for the printer option element visualizing the generic selection | 9 * Base class for the printer option element visualizing the generic selection |
10 * based option. | 10 * based option. |
11 * @param {!print_preview.ticket_items.TicketItem} ticketItem Ticket item | 11 * @param {!print_preview.ticket_items.TicketItem} ticketItem Ticket item |
12 * visualized by this component. | 12 * visualized by this component. |
13 * @constructor | 13 * @constructor |
14 * @extends {print_preview.SettingsSection} | 14 * @extends {print_preview.SettingsSection} |
15 */ | 15 */ |
16 function SettingsSectionSelect(ticketItem) { | 16 function SettingsSectionSelect(ticketItem) { |
17 print_preview.SettingsSection.call(this); | 17 print_preview.SettingsSection.call(this); |
18 | 18 |
19 /** @private {!print_preview.ticket_items.TicketItem} */ | 19 /** @private {!print_preview.ticket_items.TicketItem} */ |
20 this.ticketItem_ = ticketItem; | 20 this.ticketItem_ = ticketItem; |
21 }; | 21 } |
22 | 22 |
23 SettingsSectionSelect.prototype = { | 23 SettingsSectionSelect.prototype = { |
24 __proto__: print_preview.SettingsSection.prototype, | 24 __proto__: print_preview.SettingsSection.prototype, |
25 | 25 |
26 /** @override */ | 26 /** @override */ |
27 isAvailable: function() { | 27 isAvailable: function() { |
28 return this.ticketItem_.isCapabilityAvailable(); | 28 return this.ticketItem_.isCapabilityAvailable(); |
29 }, | 29 }, |
30 | 30 |
31 /** @override */ | 31 /** @override */ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 selectOption.text = this.getCustomDisplayName_(option) || | 82 selectOption.text = this.getCustomDisplayName_(option) || |
83 this.getDefaultDisplayName_(option); | 83 this.getDefaultDisplayName_(option); |
84 selectOption.value = JSON.stringify(option); | 84 selectOption.value = JSON.stringify(option); |
85 select.appendChild(selectOption); | 85 select.appendChild(selectOption); |
86 if (option.is_default) | 86 if (option.is_default) |
87 indexToSelect = index; | 87 indexToSelect = index; |
88 }, this); | 88 }, this); |
89 } | 89 } |
90 // Try to select current ticket item. | 90 // Try to select current ticket item. |
91 var valueToSelect = JSON.stringify(this.ticketItem_.getValue()); | 91 var valueToSelect = JSON.stringify(this.ticketItem_.getValue()); |
92 for (var i = 0, option; option = select.options[i]; i++) { | 92 for (var i = 0, option; (option = select.options[i]); i++) { |
93 if (option.value == valueToSelect) { | 93 if (option.value == valueToSelect) { |
94 indexToSelect = i; | 94 indexToSelect = i; |
95 break; | 95 break; |
96 } | 96 } |
97 } | 97 } |
98 select.selectedIndex = indexToSelect; | 98 select.selectedIndex = indexToSelect; |
99 this.onSelectChange_(); | 99 this.onSelectChange_(); |
100 }, | 100 }, |
101 | 101 |
102 /** | 102 /** |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 this.updateSelect_(); | 141 this.updateSelect_(); |
142 this.updateUiStateInternal(); | 142 this.updateUiStateInternal(); |
143 } | 143 } |
144 }; | 144 }; |
145 | 145 |
146 // Export | 146 // Export |
147 return { | 147 return { |
148 SettingsSectionSelect: SettingsSectionSelect | 148 SettingsSectionSelect: SettingsSectionSelect |
149 }; | 149 }; |
150 }); | 150 }); |
OLD | NEW |