Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/resources/options/deletable_item_list.js

Issue 435553003: DeletableItemList: Make 'X' button delete only the one list item that contains it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove comment. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698