summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 07:13:15 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-11 07:13:15 +0000
commitfdf13c6c6d1b5d9c3b524d7d24e8f19a8d51908f (patch)
treefe9d55e86f67436807ccc5de29385ea46e43d1e9 /chrome/browser/resources
parent494f5c479d1c61ecfb72ec1e0af89dd8e363d395 (diff)
downloadchromium_src-fdf13c6c6d1b5d9c3b524d7d24e8f19a8d51908f.zip
chromium_src-fdf13c6c6d1b5d9c3b524d7d24e8f19a8d51908f.tar.gz
chromium_src-fdf13c6c6d1b5d9c3b524d7d24e8f19a8d51908f.tar.bz2
Use ListSingleSelectionModel in LanguageList.
Users shouldn't be able to select multiple languages in the list. TEST=manually confirmed that multiple selection with Ctrl-click is now impossible BUG=chromium-os:4573 Review URL: http://codereview.chromium.org/3058059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55682 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources')
-rw-r--r--chrome/browser/resources/options.html1
-rw-r--r--chrome/browser/resources/options/chromeos_language_list.js24
-rw-r--r--chrome/browser/resources/shared_resources.grd2
3 files changed, 12 insertions, 15 deletions
diff --git a/chrome/browser/resources/options.html b/chrome/browser/resources/options.html
index a5ec32d1..1dfd0a0 100644
--- a/chrome/browser/resources/options.html
+++ b/chrome/browser/resources/options.html
@@ -14,6 +14,7 @@
<script src="chrome://resources/js/cr/ui/array_data_model.js"></script>
<script src="chrome://resources/js/cr/ui/list_selection_model.js"></script>
<script src="chrome://resources/js/cr/ui/list_selection_controller.js"></script>
+<script src="chrome://resources/js/cr/ui/list_single_selection_model.js"></script>
<script src="chrome://resources/js/cr/ui/list_item.js"></script>
<script src="chrome://resources/js/cr/ui/list.js"></script>
<script src="chrome://resources/js/local_strings.js"></script>
diff --git a/chrome/browser/resources/options/chromeos_language_list.js b/chrome/browser/resources/options/chromeos_language_list.js
index c6e6033..a29f7aa 100644
--- a/chrome/browser/resources/options/chromeos_language_list.js
+++ b/chrome/browser/resources/options/chromeos_language_list.js
@@ -3,10 +3,11 @@
// found in the LICENSE file.
cr.define('options.language', function() {
- const List = cr.ui.List;
- const ListItem = cr.ui.ListItem;
const ArrayDataModel = cr.ui.ArrayDataModel;
const LanguageOptions = options.LanguageOptions;
+ const List = cr.ui.List;
+ const ListItem = cr.ui.ListItem;
+ const ListSingleSelectionModel = cr.ui.ListSingleSelectionModel;
/**
* Creates a new language list.
@@ -42,6 +43,7 @@ cr.define('options.language', function() {
/** @inheritDoc */
decorate: function() {
List.prototype.decorate.call(this);
+ this.selectionModel = new ListSingleSelectionModel;
// HACK(arv): http://crbug.com/40902
window.addEventListener('resize', cr.bind(this.redraw, this));
@@ -90,18 +92,10 @@ cr.define('options.language', function() {
if (this.selectionModel.selectedIndex >= 0 &&
// Don't allow removing the last language.
this.dataModel.length > 1) {
- // TODO(satorux): Until we switch to the single selection model,
- // it's possible that multiple languages are selected, but we don't
- // handle that case here.
- var originalIndex = this.selectionModel.selectedIndex;
this.dataModel.splice(this.selectionModel.selectedIndex, 1);
- // Select the item at the original index if possible. Otherwise,
- // select the last item.
- // TODO(satorux): This should be handled by the selection model
- // See crbug.com/49893.
- this.selectionModel.selectedIndex = Math.min(
- originalIndex,
- this.dataModel.length - 1);
+ // Once the selected item is removed, there will be no selected item.
+ // Select the item pointed by the lead index.
+ this.selectionModel.selectedIndex = this.selectionModel.leadIndex;
this.updateBackend_();
}
},
@@ -136,8 +130,8 @@ cr.define('options.language', function() {
this.selectionModel.selectedIndex = originalSelectedIndex;
} else if (this.dataModel.length > 0){
// Otherwise, select the first item if it's not empty.
- // TODO(satorux): Switch to a single item selection model that does
- // not allow no selection, one it's ready: crbug.com/49893
+ // Note that ListSingleSelectionModel won't select an item
+ // automatically, hence we manually select the first item here.
this.selectionModel.selectedIndex = 0;
}
},
diff --git a/chrome/browser/resources/shared_resources.grd b/chrome/browser/resources/shared_resources.grd
index b0f8731..5512265 100644
--- a/chrome/browser/resources/shared_resources.grd
+++ b/chrome/browser/resources/shared_resources.grd
@@ -50,6 +50,8 @@ without changes to the corresponding grd file. paaaae -->
file="shared/js/cr/ui/list_selection_controller.js" type="BINDATA" />
<include name="IDR_SHARED_JS_CR_UI_LIST_SELECTION_MODEL"
file="shared/js/cr/ui/list_selection_model.js" type="BINDATA" />
+ <include name="IDR_SHARED_JS_CR_UI_LIST_SINGLE_SELECTION_MODEL"
+ file="shared/js/cr/ui/list_single_selection_model.js" type="BINDATA" />
<include name="IDR_SHARED_JS_CR_UI_MENU"
file="shared/js/cr/ui/menu.js" type="BINDATA" />
<include name="IDR_SHARED_JS_CR_UI_MENU_BUTTON"