summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrginda@chromium.org <rginda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-08 16:51:05 +0000
committerrginda@chromium.org <rginda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-08 16:51:05 +0000
commit642f7e4c990343cd3a4147b35b6ff554070f0851 (patch)
tree5d4cf930a3e56d2a876ac2fce5973aa459b51d7d /chrome
parentace11faefd36cb2696bc626e219aa479b6d95352 (diff)
downloadchromium_src-642f7e4c990343cd3a4147b35b6ff554070f0851.zip
chromium_src-642f7e4c990343cd3a4147b35b6ff554070f0851.tar.gz
chromium_src-642f7e4c990343cd3a4147b35b6ff554070f0851.tar.bz2
file manager: Prevent [ENTER] from completing the save-as dialog in bad directories
Previous code reset the disabled state of the ok button on-keypress of the filename input text box. This overwrote the fact the the ok button may have been disabled because we're in the / or /media directories. BUG=chromium-os:16276 TEST=manual testing on chromeos-chrome in linux Review URL: http://codereview.chromium.org/7108012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/file_manager/js/file_manager.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 552cb41..553c2e8 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -1547,16 +1547,26 @@ FileManager.prototype = {
* @param {cr.Event} event The change event.
*/
FileManager.prototype.onSelectionChanged_ = function(event) {
- var selectable;
-
this.summarizeSelection_();
- this.updateOkButton_();
this.updatePreview_();
+ if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
+ // If this is a save-as dialog, copy the selected file into the filename
+ // input text box.
+ if (this.selection.leadEntry && this.selection.leadEntry.isFile)
+ this.filenameInput_.value = this.selection.leadEntry.name;
+ }
+
+ this.updateOkButton_();
+
var self = this;
setTimeout(function() { self.onSelectionChangeComplete_(event) }, 0);
};
+ /**
+ * Handle selection change related tasks that won't run properly during
+ * the actual selection change event.
+ */
FileManager.prototype.onSelectionChangeComplete_ = function(event) {
if (!this.showCheckboxes_)
return;
@@ -1593,6 +1603,8 @@ FileManager.prototype = {
};
FileManager.prototype.updateOkButton_ = function(event) {
+ var selectable;
+
if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) {
selectable = this.selection.directoryCount == 1 &&
this.selection.fileCount == 0;
@@ -1604,9 +1616,6 @@ FileManager.prototype = {
selectable = (this.selection.directoryCount == 0 &&
this.selection.fileCount >= 1);
} else if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
- if (this.selection.leadEntry && this.selection.leadEntry.isFile)
- this.filenameInput_.value = this.selection.leadEntry.name;
-
if (this.currentDirEntry_.fullPath == '/' ||
this.currentDirEntry_.fullPath == MEDIA_DIRECTORY) {
// Nothing can be saved in to the root or media/ directories.
@@ -1622,6 +1631,7 @@ FileManager.prototype = {
}
this.okButton_.disabled = !selectable;
+ return selectable;
};
/**
@@ -1925,9 +1935,8 @@ FileManager.prototype = {
};
FileManager.prototype.onFilenameInputKeyUp_ = function(event) {
- this.okButton_.disabled = this.filenameInput_.value.length == 0;
-
- if (event.keyCode == 13 /* Enter */ && !this.okButton_.disabled)
+ var enabled = this.updateOkButton_();
+ if (enabled && event.keyCode == 13 /* Enter */)
this.onOk_();
};