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

Unified Diff: ui/file_manager/file_manager/foreground/js/directory_model.js

Issue 279873002: Files.app: Handle change-by-keyboard in the directory tree (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 | « no previous file | ui/file_manager/file_manager/foreground/js/directory_tree.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/directory_model.js
diff --git a/ui/file_manager/file_manager/foreground/js/directory_model.js b/ui/file_manager/file_manager/foreground/js/directory_model.js
index cc93910caba83c040e3734a8b97c77da33c1f37e..810a12706b2273bb31ef6388f71004d72f55ed50 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_model.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_model.js
@@ -647,12 +647,16 @@ DirectoryModel.prototype.createDirectory = function(name,
};
/**
- * Change the current directory to the directory represented by
+ * Changes the current directory to the directory represented by
* a DirectoryEntry or a fake entry.
*
* Dispatches the 'directory-changed' event when the directory is successfully
* changed.
*
+ * Note : if this is called from UI, please consider to use DirectoryModel.
+ * activateDirectoryEntry instead of this, which is higher-level function and
+ * cares about the selection.
+ *
* @param {DirectoryEntry|Object} dirEntry The entry of the new directory to
* be opened.
* @param {function()=} opt_callback Executed if the directory loads
@@ -695,6 +699,31 @@ DirectoryModel.prototype.changeDirectoryEntry = function(
};
/**
+ * Activates the given directry.
+ * This method:
+ * - Changes the current directory, if the given directory is the current
+ * directory.
+ * - Clears the selection, if the given directory is the current directory.
+ *
+ * @param {DirectoryEntry|Object} dirEntry The entry of the new directory to
+ * be opened.
+ * @param {function()=} opt_callback Executed if the directory loads
+ * successfully.
+ */
+DirectoryModel.prototype.activateDirectoryEntry = function(
+ dirEntry, opt_callback) {
+ var currentDirectoryEntry = this.getCurrentDirEntry();
+ if (currentDirectoryEntry &&
+ util.isSameEntry(dirEntry, currentDirectoryEntry)) {
+ // On activating the current directory, clear the selection on the filelist.
+ this.clearSelection();
+ } else {
+ // Otherwise, changes the current directory.
+ this.changeDirectoryEntry(dirEntry, opt_callback);
+ }
+};
+
+/**
* Clears the selection in the file list.
*/
DirectoryModel.prototype.clearSelection = function() {
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/directory_tree.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698