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

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

Issue 7108012: file manager: Prevent [ENTER] from completing the save-as dialog in bad directories (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 | 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 835f5f0ccd353ba6ce1585c2e1a11818547d882e..54e7e99c0379fb2c675abf47563e994bcfb624f7 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;
rginda 2011/06/07 23:35:35 This was moved to updateOkButton_, where it should
-
this.summarizeSelection_();
- this.updateOkButton_();
this.updatePreview_();
+ if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
rginda 2011/06/07 23:35:35 This snippet came from updateOkButton_. It was ac
+ // 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;
};
/**
@@ -1922,9 +1932,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_();
};
« 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