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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 * Callback for onclick events. | 129 * Callback for onclick events. |
130 * @param {Event} e The click event object. | 130 * @param {Event} e The click event object. |
131 * @private | 131 * @private |
132 */ | 132 */ |
133 handleClick_: function(e) { | 133 handleClick_: function(e) { |
134 if (this.disabled) | 134 if (this.disabled) |
135 return; | 135 return; |
136 | 136 |
137 var target = e.target; | 137 var target = e.target; |
138 if (target.classList.contains('row-delete-button')) { | 138 if (target.classList.contains('row-delete-button')) { |
139 // Because the close buttons do not give any visual indication that they | |
140 // would behave differently when multiple items are selected, delete | |
141 // only the one list item that contains the close button being clicked, | |
142 // regardless of how many other items are selected. If the user wants to | |
143 // delete a lot of stuff at once, he would have to press the delete key. | |
Evan Stade
2014/07/31 15:09:26
I think this comment is too much. Better to make t
engedy
2014/07/31 16:36:53
Moved it to the CL description, and replaced it wi
| |
139 var listItem = this.getListItemAncestor(target); | 144 var listItem = this.getListItemAncestor(target); |
140 var selected = this.selectionModel.selectedIndexes; | |
141 | |
142 // Check if the list item that contains the close button being clicked | |
143 // is not in the list of selected items. Only delete this item in that | |
144 // case. | |
145 var idx = this.getIndexOfListItem(listItem); | 145 var idx = this.getIndexOfListItem(listItem); |
146 if (selected.indexOf(idx) == -1) { | 146 this.deleteItemAtIndex(idx); |
147 this.deleteItemAtIndex(idx); | 147 this.selectionModel.clear(); |
engedy
2014/07/31 09:30:22
What is the motivation for clearing the selection?
Evan Stade
2014/07/31 15:09:27
It's my impression that that is the expected behav
engedy
2014/07/31 16:36:53
Sorry, turns out my above statement was incorrect:
| |
148 } else { | |
149 this.deleteSelectedItems_(); | |
150 } | |
151 } | 148 } |
152 }, | 149 }, |
153 | 150 |
154 /** | 151 /** |
155 * Callback for keydown events. | 152 * Callback for keydown events. |
156 * @param {Event} e The keydown event object. | 153 * @param {Event} e The keydown event object. |
157 * @private | 154 * @private |
158 */ | 155 */ |
159 handleKeyDown_: function(e) { | 156 handleKeyDown_: function(e) { |
160 // Map delete (and backspace on Mac) to item deletion (unless focus is | 157 // Map delete (and backspace on Mac) to item deletion (unless focus is |
(...skipping 28 matching lines...) Expand all Loading... | |
189 */ | 186 */ |
190 deleteItemAtIndex: function(index) { | 187 deleteItemAtIndex: function(index) { |
191 }, | 188 }, |
192 }; | 189 }; |
193 | 190 |
194 return { | 191 return { |
195 DeletableItemList: DeletableItemList, | 192 DeletableItemList: DeletableItemList, |
196 DeletableItem: DeletableItem, | 193 DeletableItem: DeletableItem, |
197 }; | 194 }; |
198 }); | 195 }); |
OLD | NEW |