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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 8770045: Selecting first item in the directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/file_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index bd5e5c03a9d89a004718514363bbff4928c52c5c..d44aa829542f0b376a9a7daaae47bb5088e52d89 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -2509,14 +2509,20 @@ FileManager.prototype = {
FileManager.prototype.selectEntry = function(name) {
for (var i = 0; i < this.dataModel_.length; i++) {
if (this.dataModel_.item(i).name == name) {
- this.currentList_.selectionModel.selectedIndex = i;
- this.currentList_.scrollIndexIntoView(i);
- this.currentList_.focus();
+ this.selectIndex(i);
return;
}
}
};
+ FileManager.prototype.selectIndex = function(index) {
+ this.currentList_.focus();
+ if (index >= this.dataModel_.length)
+ return;
+ this.currentList_.selectionModel.selectedIndex = index;
+ this.currentList_.scrollIndexIntoView(index);
+ };
+
/**
* Add the file/directory with given name to the current selection.
*
@@ -2649,6 +2655,8 @@ FileManager.prototype = {
// Directory didn't actually change.
if (opt_selectedEntry)
this.selectEntry(opt_selectedEntry);
+ else
+ this.selectIndex(0);
return;
}
@@ -3066,6 +3074,8 @@ FileManager.prototype = {
this.rescanDirectory_(function() {
if (event.selectedEntry)
self.selectEntry(event.selectedEntry);
+ else
+ self.selectIndex(0);
if (event.opt_callback) {
try {
event.opt_callback();
« 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