diff options
author | serya@google.com <serya@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 10:58:12 +0000 |
---|---|---|
committer | serya@google.com <serya@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-27 10:58:12 +0000 |
commit | e5c34eec0f8930980c9478fe17811bba0f29ecac (patch) | |
tree | dd0faa2afc04dc246d2fb40ecb89f0a6e152c54e | |
parent | 93c432bd681eaad1e9b91c3f0c398fb068521ef5 (diff) | |
download | chromium_src-e5c34eec0f8930980c9478fe17811bba0f29ecac.zip chromium_src-e5c34eec0f8930980c9478fe17811bba0f29ecac.tar.gz chromium_src-e5c34eec0f8930980c9478fe17811bba0f29ecac.tar.bz2 |
Navigating to directory or device then dragging files.
When the user is dragging files and keeps the cursor over a folder or device (in the file list, divice list or breadcrumbs) for 2 secs that folder gets current (or in case of device the latest visited folder, like when user clickis on it).
BUG=chromiumos:29774
TEST=Manual test.
Review URL: https://chromiumcodereview.appspot.com/10254002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134254 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 51 insertions, 16 deletions
diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js index 4f59fb8..3c0416f 100644 --- a/chrome/browser/resources/file_manager/js/directory_model.js +++ b/chrome/browser/resources/file_manager/js/directory_model.js @@ -659,11 +659,23 @@ DirectoryModel.prototype.createDirectory = function(name, successCallback, * Changes directory. Causes 'directory-change' event. * * @param {string} path New current directory path. - * @param {function} opt_OnError Called if failed. */ -DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) { - var onDirectoryResolved = this.changeDirectoryEntry_.bind(this, false); +DirectoryModel.prototype.changeDirectory = function(path) { + this.resolveDirectory(path, function(directoryEntry) { + this.changeDirectoryEntry_(false, directoryEntry); + }.bind(this), function(error) { + console.error('Error changing directory to ' + path + ': ', error); + }); +} +/** + * Resolves absolute directory path. Handles GData stub. + * @param {string} path Path to the directory. + * @param {function(DirectoryEntry} successCallback Success callback. + * @param {function(FileError} errorCallback Error callback. + */ +DirectoryModel.prototype.resolveDirectory = function(path, successCallback, + errorCallback) { if (this.unmountedGDataEntry_ && DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) { // TODO(kaznacheeev): Currently if path points to some GData subdirectory @@ -672,21 +684,40 @@ DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) { // changing to it once GDdata is mounted. This is only relevant for cases // when we open the File Manager with an URL pointing to GData (e.g. via // a bookmark). - onDirectoryResolved(this.unmountedGDataEntry_); + successCallback(this.unmountedGDataEntry_); return; } if (path == '/') { - onDirectoryResolved(this.root_); + successCallback(this.root_); return; } - var onError = opt_OnError || function(error) { - // TODO(serya): We should show an alert. - console.error('Error changing directory to: ' + path + ', ' + error); - }; + this.root_.getDirectory(path, {create: false}, + successCallback, errorCallback); +}; - this.root_.getDirectory(path, {create: false}, onDirectoryResolved, onError); +/** + * Changes directory. If path points to a root (except current one) + * then directory changed to the last used one for the root. + * + * @param {string} path New current directory path or new root. + */ +DirectoryModel.prototype.changeDirectoryOrRoot = function(path) { + if (DirectoryModel.getRootPath(path) == this.getCurrentRootPath()) { + this.changeDirectory(path); + } else if (this.currentDirByRoot_[path]) { + var self = this; + this.resolveDirectory(this.currentDirByRoot_[path], + function(directoryEntry) { + self.changeDirectoryEntry_(false, directoryEntry); + }, + function(error) { + self.changeDrectory(path); + }); + } else { + this.changeDirectory(path); + } }; /** diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index 494d23f..12a77ad 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -1712,12 +1712,7 @@ FileManager.prototype = { * @param {Event} event The event. */ FileManager.prototype.onRootClick_ = function(entry, event) { - var new_path = entry.fullPath; - if (entry.fullPath == this.directoryModel_.getCurrentRootPath()) { - this.directoryModel_.changeDirectory(entry.fullPath); - } else { - this.directoryModel_.changeRoot(entry.fullPath); - } + this.directoryModel_.changeDirectoryOrRoot(entry.fullPath); }; FileManager.prototype.renderRoot_ = function(entry) { diff --git a/chrome/browser/resources/file_manager/js/file_transfer_controller.js b/chrome/browser/resources/file_manager/js/file_transfer_controller.js index 9a626cb..8c78b37 100644 --- a/chrome/browser/resources/file_manager/js/file_transfer_controller.js +++ b/chrome/browser/resources/file_manager/js/file_transfer_controller.js @@ -273,6 +273,15 @@ FileTransferController.prototype = { }, 0); } this.dropTarget_ = domElement; + if (this.navigateTimer_ !== undefined) { + clearTimeout(this.navigateTimer_); + this.navigateTimer_ = undefined; + } + if (domElement && isDirectory && opt_destinationPath) { + this.navigateTimer_ = setTimeout(function() { + this.directoryModel_.changeDirectoryOrRoot(opt_destinationPath); + }.bind(this), 2000); + } }, isDocumentWideEvent_: function(event) { |