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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 var listItem = this.getListItemAncestor(target); | 139 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); | 140 var idx = this.getIndexOfListItem(listItem); |
146 if (selected.indexOf(idx) == -1) { | 141 this.deleteItemAtIndex(idx); |
147 this.deleteItemAtIndex(idx); | |
148 } else { | |
149 this.deleteSelectedItems_(); | |
150 } | |
151 } | 142 } |
152 }, | 143 }, |
153 | 144 |
154 /** | 145 /** |
155 * Callback for keydown events. | 146 * Callback for keydown events. |
156 * @param {Event} e The keydown event object. | 147 * @param {Event} e The keydown event object. |
157 * @private | 148 * @private |
158 */ | 149 */ |
159 handleKeyDown_: function(e) { | 150 handleKeyDown_: function(e) { |
160 // Map delete (and backspace on Mac) to item deletion (unless focus is | 151 // Map delete (and backspace on Mac) to item deletion (unless focus is |
(...skipping 28 matching lines...) Expand all Loading... |
189 */ | 180 */ |
190 deleteItemAtIndex: function(index) { | 181 deleteItemAtIndex: function(index) { |
191 }, | 182 }, |
192 }; | 183 }; |
193 | 184 |
194 return { | 185 return { |
195 DeletableItemList: DeletableItemList, | 186 DeletableItemList: DeletableItemList, |
196 DeletableItem: DeletableItem, | 187 DeletableItem: DeletableItem, |
197 }; | 188 }; |
198 }); | 189 }); |
OLD | NEW |