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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 set deletable(value) { | 84 set deletable(value) { |
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() { |
Dan Beam
2014/07/30 19:05:34
if (this.selected)
return;
engedy
2014/07/31 09:35:48
Done.
| |
95 var list = this.parentNode; | 95 var list = this.parentNode; |
96 var index = list.getIndexOfListItem(this); | 96 var index = list.getIndexOfListItem(this); |
97 list.selectionModel.selectedIndex = index; | 97 |
98 list.selectionModel.anchorIndex = index; | 98 // This handler is also fired when the child receives focus as a result of |
99 // the item getting selected by the customized mouse/keyboard handling in | |
100 // SelectionController. Take care not to destroy a potential multiple | |
101 // selection in this case. | |
102 if (!this.selected) { | |
103 list.selectionModel.selectedIndex = index; | |
104 list.selectionModel.anchorIndex = index; | |
105 } | |
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. |
105 * @param {Event} e The mouse down/up event object. | 112 * @param {Event} e The mouse down/up event object. |
106 * @private | 113 * @private |
107 */ | 114 */ |
108 handleMouseDownUpOnClose_: function(e) { | 115 handleMouseDownUpOnClose_: function(e) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 */ | 196 */ |
190 deleteItemAtIndex: function(index) { | 197 deleteItemAtIndex: function(index) { |
191 }, | 198 }, |
192 }; | 199 }; |
193 | 200 |
194 return { | 201 return { |
195 DeletableItemList: DeletableItemList, | 202 DeletableItemList: DeletableItemList, |
196 DeletableItem: DeletableItem, | 203 DeletableItem: DeletableItem, |
197 }; | 204 }; |
198 }); | 205 }); |
OLD | NEW |