summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-07 18:57:37 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-07 18:57:37 +0000
commit8768d94cc7c853bd20f46d252e5b453b5267e3e7 (patch)
tree77962ad0fbf6fdd938e8859bf499d7c61918f119 /chrome
parent419d85de128f5e14704c71a53cb3b45180d3fa71 (diff)
downloadchromium_src-8768d94cc7c853bd20f46d252e5b453b5267e3e7.zip
chromium_src-8768d94cc7c853bd20f46d252e5b453b5267e3e7.tar.gz
chromium_src-8768d94cc7c853bd20f46d252e5b453b5267e3e7.tar.bz2
DOMUI Prefs: Allow multi-selection for editable lists
Changes the trigger for edit mode to be lead+selection, rather than just selection, so that we don't have to set single-selection mode on all the editable lists. BUG=71103 TEST=Select more than one item in Search Engines, Startup Pages, or Content Settings expections. Multi-selection should work, but only the lead item should be editable. Review URL: http://codereview.chromium.org/6246126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/options/browser_options.js2
-rw-r--r--chrome/browser/resources/options/content_settings_exceptions_area.js1
-rw-r--r--chrome/browser/resources/options/inline_editable_list.js30
-rw-r--r--chrome/browser/resources/options/search_engine_manager.js2
4 files changed, 25 insertions, 10 deletions
diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js
index 4bdf82c..4d69d05 100644
--- a/chrome/browser/resources/options/browser_options.js
+++ b/chrome/browser/resources/options/browser_options.js
@@ -5,7 +5,6 @@
cr.define('options', function() {
const OptionsPage = options.OptionsPage;
const ArrayDataModel = cr.ui.ArrayDataModel;
- const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
//
// BrowserOptions class
@@ -92,7 +91,6 @@ cr.define('options', function() {
var list = $('startupPagesList');
options.browser_options.StartupPageList.decorate(list);
list.autoExpands = true;
- list.selectionModel = new ListSingleSelectionModel;
// Check if we are in the guest mode.
if (cr.commandLine.options['--bwsi']) {
diff --git a/chrome/browser/resources/options/content_settings_exceptions_area.js b/chrome/browser/resources/options/content_settings_exceptions_area.js
index 98c289e..b2a49c4 100644
--- a/chrome/browser/resources/options/content_settings_exceptions_area.js
+++ b/chrome/browser/resources/options/content_settings_exceptions_area.js
@@ -336,7 +336,6 @@ cr.define('options.contentSettings', function() {
decorate: function() {
InlineEditableItemList.prototype.decorate.call(this);
- this.selectionModel = new cr.ui.ListSingleSelectionModel;
this.classList.add('settings-list');
for (var parentNode = this.parentNode; parentNode;
diff --git a/chrome/browser/resources/options/inline_editable_list.js b/chrome/browser/resources/options/inline_editable_list.js
index a6474d5..16b3390 100644
--- a/chrome/browser/resources/options/inline_editable_list.js
+++ b/chrome/browser/resources/options/inline_editable_list.js
@@ -50,12 +50,29 @@ cr.define('options', function() {
DeletableItem.prototype.decorate.call(this);
this.addEventListener('keydown', this.handleKeyDown_.bind(this));
+ this.addEventListener('leadChange', this.handleLeadChange_);
},
/** @inheritDoc */
selectionChanged: function() {
+ this.updateEditState();
+ },
+
+ /**
+ * Called when this element gains or loses 'lead' status. Updates editing
+ * mode accordingly.
+ * @private
+ */
+ handleLeadChange_: function() {
+ this.updateEditState();
+ },
+
+ /**
+ * Updates the edit state based on the current selected and lead states.
+ */
+ updateEditState: function() {
if (this.editable)
- this.editing = this.selected;
+ this.editing = this.selected && this.lead;
},
/**
@@ -259,14 +276,17 @@ cr.define('options', function() {
/**
* Called when the list hierarchy as a whole loses or gains focus; starts
- * or ends editing for any selected items.
+ * or ends editing for the lead item if necessary.
* @param {Event} e The change event.
* @private
*/
handleListFocusChange_: function(e) {
- var indexes = this.selectionModel.selectedIndexes;
- for (var i = 0; i < indexes.length; i++) {
- this.getListItemByIndex(indexes[i]).editing = e.newValue;
+ var leadItem = this.getListItemByIndex(this.selectionModel.leadIndex);
+ if (leadItem) {
+ if (e.newValue)
+ leadItem.updateEditState();
+ else
+ leadItem.editing = false;
}
},
};
diff --git a/chrome/browser/resources/options/search_engine_manager.js b/chrome/browser/resources/options/search_engine_manager.js
index ea87ebd..9889812 100644
--- a/chrome/browser/resources/options/search_engine_manager.js
+++ b/chrome/browser/resources/options/search_engine_manager.js
@@ -5,7 +5,6 @@
cr.define('options', function() {
const OptionsPage = options.OptionsPage;
const ArrayDataModel = cr.ui.ArrayDataModel;
- const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
/**
* Encapsulated handling of search engine management page.
@@ -55,7 +54,6 @@ cr.define('options', function() {
*/
setUpList_: function(list) {
options.search_engines.SearchEngineList.decorate(list);
- list.selectionModel = new ListSingleSelectionModel;
list.autoExpands = true;
},