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('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var List = cr.ui.List; | 6 /** @const */ var List = cr.ui.List; |
7 /** @const */ var ListItem = cr.ui.ListItem; | 7 /** @const */ var ListItem = cr.ui.ListItem; |
8 | 8 |
9 /** | 9 /** |
10 * Creates a deletable list item, which has a button that will trigger a call | 10 * Creates a deletable list item, which has a button that will trigger a call |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 this.deletable_ = value; | 85 this.deletable_ = value; |
86 this.closeButtonElement_.disabled = !value; | 86 this.closeButtonElement_.disabled = !value; |
87 }, | 87 }, |
88 | 88 |
89 /** | 89 /** |
90 * Called when a focusable child element receives focus. Selects this item | 90 * Called when a focusable child element receives focus. Selects this item |
91 * in the list selection model. | 91 * in the list selection model. |
92 * @private | 92 * @private |
93 */ | 93 */ |
94 handleFocus_: function() { | 94 handleFocus_: function() { |
| 95 // This handler is also fired when the child receives focus as a result of |
| 96 // the item getting selected by the customized mouse/keyboard handling in |
| 97 // SelectionController. Take care not to destroy a potential multiple |
| 98 // selection in this case. |
| 99 if (this.selected) |
| 100 return; |
| 101 |
95 var list = this.parentNode; | 102 var list = this.parentNode; |
96 var index = list.getIndexOfListItem(this); | 103 var index = list.getIndexOfListItem(this); |
97 list.selectionModel.selectedIndex = index; | 104 list.selectionModel.selectedIndex = index; |
98 list.selectionModel.anchorIndex = index; | 105 list.selectionModel.anchorIndex = index; |
99 }, | 106 }, |
100 | 107 |
101 /** | 108 /** |
102 * Don't let the list have a crack at the event. We don't want clicking the | 109 * Don't let the list have a crack at the event. We don't want clicking the |
103 * close button to change the selection of the list or to focus on the close | 110 * close button to change the selection of the list or to focus on the close |
104 * button. | 111 * button. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 */ | 193 */ |
187 deleteItemAtIndex: function(index) { | 194 deleteItemAtIndex: function(index) { |
188 }, | 195 }, |
189 }; | 196 }; |
190 | 197 |
191 return { | 198 return { |
192 DeletableItemList: DeletableItemList, | 199 DeletableItemList: DeletableItemList, |
193 DeletableItem: DeletableItem, | 200 DeletableItem: DeletableItem, |
194 }; | 201 }; |
195 }); | 202 }); |
OLD | NEW |