Chromium Code Reviews| 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 // A close button does not give any visual indication that its behavior | |
| 140 // would be affected by the current selection, so it should not be. | |
|
Evan Stade
2014/07/31 19:36:07
I just don't think that code comments are the best
engedy
2014/08/01 08:06:25
Done, I have removed the comment.
| |
| 139 var listItem = this.getListItemAncestor(target); | 141 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); | 142 var idx = this.getIndexOfListItem(listItem); |
| 146 if (selected.indexOf(idx) == -1) { | 143 this.deleteItemAtIndex(idx); |
| 147 this.deleteItemAtIndex(idx); | |
| 148 } else { | |
| 149 this.deleteSelectedItems_(); | |
| 150 } | |
| 151 } | 144 } |
| 152 }, | 145 }, |
| 153 | 146 |
| 154 /** | 147 /** |
| 155 * Callback for keydown events. | 148 * Callback for keydown events. |
| 156 * @param {Event} e The keydown event object. | 149 * @param {Event} e The keydown event object. |
| 157 * @private | 150 * @private |
| 158 */ | 151 */ |
| 159 handleKeyDown_: function(e) { | 152 handleKeyDown_: function(e) { |
| 160 // Map delete (and backspace on Mac) to item deletion (unless focus is | 153 // Map delete (and backspace on Mac) to item deletion (unless focus is |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 189 */ | 182 */ |
| 190 deleteItemAtIndex: function(index) { | 183 deleteItemAtIndex: function(index) { |
| 191 }, | 184 }, |
| 192 }; | 185 }; |
| 193 | 186 |
| 194 return { | 187 return { |
| 195 DeletableItemList: DeletableItemList, | 188 DeletableItemList: DeletableItemList, |
| 196 DeletableItem: DeletableItem, | 189 DeletableItem: DeletableItem, |
| 197 }; | 190 }; |
| 198 }); | 191 }); |
| OLD | NEW |