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

Unified Diff: chrome/browser/resources/shared/js/cr/ui/list_selection_model.js

Issue 9429003: Accurate selection change event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/list_selection_controller.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/shared/js/cr/ui/list_selection_model.js
diff --git a/chrome/browser/resources/shared/js/cr/ui/list_selection_model.js b/chrome/browser/resources/shared/js/cr/ui/list_selection_model.js
index a0e5b983681db836cec3d83bccb4b9218f446856..740b73b2a6f0a371c3d1ec70f6d5254ef7d97315 100644
--- a/chrome/browser/resources/shared/js/cr/ui/list_selection_model.js
+++ b/chrome/browser/resources/shared/js/cr/ui/list_selection_model.js
@@ -40,10 +40,26 @@ cr.define('cr.ui', function() {
},
set selectedIndexes(selectedIndexes) {
this.beginChange();
- this.unselectAll();
+ var unselected = {};
+ for (var index in this.selectedIndexes_) {
+ unselected[index] = true;
+ }
+
for (var i = 0; i < selectedIndexes.length; i++) {
- this.setIndexSelected(selectedIndexes[i], true);
+ var index = selectedIndexes[i];
+ if (index in this.selectedIndexes_) {
+ delete unselected[index];
+ } else {
+ this.selectedIndexes_[index] = true;
+ this.changedIndexes_[index] = true;
+ }
+ }
+
+ for (var index in unselected) {
+ delete this.selectedIndexes_[index];
+ this.changedIndexes_[index] = false;
}
+
if (selectedIndexes.length) {
this.leadIndex = this.anchorIndex = selectedIndexes[0];
} else {
@@ -63,14 +79,7 @@ cr.define('cr.ui', function() {
return -1;
},
set selectedIndex(selectedIndex) {
- this.beginChange();
- this.unselectAll();
- if (selectedIndex != -1) {
- this.selectedIndexes = [selectedIndex];
- } else {
- this.leadIndex = this.anchorIndex = -1;
- }
- this.endChange();
+ this.selectedIndexes = selectedIndex != -1 ? [selectedIndex] : [];
},
/**
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/list_selection_controller.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698