summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-06 21:15:50 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-06 21:15:50 +0000
commitf24f483ad3acf1203a1a07b188b279322cb2e561 (patch)
treeebd897c112f5e60f9d184b866cb81d06d6e88809 /chrome/browser/resources/options
parent9bb336f50165f6935209d91163a05f50e5ec3d1f (diff)
downloadchromium_src-f24f483ad3acf1203a1a07b188b279322cb2e561.zip
chromium_src-f24f483ad3acf1203a1a07b188b279322cb2e561.tar.gz
chromium_src-f24f483ad3acf1203a1a07b188b279322cb2e561.tar.bz2
DOMUI: Make Autofill profile lists multi-select and implementing deleting
multiple list items. BUG=66956 TEST=none Review URL: http://codereview.chromium.org/6029013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/options')
-rw-r--r--chrome/browser/resources/options/autofill_options.js3
-rw-r--r--chrome/browser/resources/options/deletable_item_list.js26
2 files changed, 20 insertions, 9 deletions
diff --git a/chrome/browser/resources/options/autofill_options.js b/chrome/browser/resources/options/autofill_options.js
index bdc4ab7..2e129bb 100644
--- a/chrome/browser/resources/options/autofill_options.js
+++ b/chrome/browser/resources/options/autofill_options.js
@@ -5,7 +5,6 @@
cr.define('options', function() {
const OptionsPage = options.OptionsPage;
const ArrayDataModel = cr.ui.ArrayDataModel;
- const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
/////////////////////////////////////////////////////////////////////////////
// AutoFillOptions class:
@@ -65,7 +64,6 @@ cr.define('options', function() {
createAddressList_: function() {
this.addressList_ = $('address-list');
options.autoFillOptions.AutoFillAddressList.decorate(this.addressList_);
- this.addressList_.selectionModel = new ListSingleSelectionModel;
this.addressList_.autoExpands = true;
},
@@ -77,7 +75,6 @@ cr.define('options', function() {
this.creditCardList_ = $('creditcard-list');
options.autoFillOptions.AutoFillCreditCardList.decorate(
this.creditCardList_);
- this.creditCardList_.selectionModel = new ListSingleSelectionModel;
this.creditCardList_.autoExpands = true;
},
diff --git a/chrome/browser/resources/options/deletable_item_list.js b/chrome/browser/resources/options/deletable_item_list.js
index 6781c50..5d5b35b 100644
--- a/chrome/browser/resources/options/deletable_item_list.js
+++ b/chrome/browser/resources/options/deletable_item_list.js
@@ -61,7 +61,9 @@ cr.define('options', function() {
this.closeButtonElement_ = this.ownerDocument.createElement('button');
this.closeButtonElement_.className = 'close-button';
this.closeButtonElement_.addEventListener('mousedown',
- this.handleMouseDownOnClose_);
+ this.handleMouseDownUpOnClose_);
+ this.closeButtonElement_.addEventListener('mouseup',
+ this.handleMouseDownUpOnClose_);
this.appendChild(this.closeButtonElement_);
},
@@ -86,11 +88,11 @@ cr.define('options', function() {
/**
* Don't let the list have a crack at the event. We don't want clicking the
- * close button to select the list.
- * @param {Event} e The mouse down event object.
+ * close button to change the selection of the list.
+ * @param {Event} e The mouse down/up event object.
* @private
*/
- handleMouseDownOnClose_: function(e) {
+ handleMouseDownUpOnClose_: function(e) {
if (!e.target.disabled)
e.stopPropagation();
},
@@ -119,8 +121,20 @@ cr.define('options', function() {
var target = e.target;
if (target.className == 'close-button') {
var listItem = this.getListItemAncestor(target);
- if (listItem)
- this.deleteItemAtIndex(this.getIndexOfListItem(listItem));
+ var selected = this.selectionModel.selectedIndexes;
+
+ // Check if the list item that contains the close button being clicked
+ // is not in the list of selected items. Only delete this item in that
+ // case.
+ var idx = this.getIndexOfListItem(listItem);
+ if (selected.indexOf(idx) == -1) {
+ this.deleteItemAtIndex(idx);
+ } else {
+ // Reverse through the list of selected indexes to maintain the
+ // correct index values after deletion.
+ for (var j = selected.length - 1; j >= 0; j--)
+ this.deleteItemAtIndex(selected[j]);
+ }
}
},