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

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

Issue 329763003: Update file extension based on the selected type in the save dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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: ui/file_manager/file_manager/foreground/js/file_manager.js
diff --git a/ui/file_manager/file_manager/foreground/js/file_manager.js b/ui/file_manager/file_manager/foreground/js/file_manager.js
index b1b9cbb2d1f830137cfc31907afaf5afb799a419..2a4920b7421f9b3552f53c360b45d587ac7f7a6f 100644
--- a/ui/file_manager/file_manager/foreground/js/file_manager.js
+++ b/ui/file_manager/file_manager/foreground/js/file_manager.js
@@ -1346,12 +1346,25 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
this.fileFilter_.removeFilter('fileType');
var selectedIndex = this.getSelectedFilterIndex_();
if (selectedIndex > 0) { // Specific filter selected.
- var regexp = new RegExp('.*(' +
+ var regexp = new RegExp('\\.(' +
this.fileTypes_[selectedIndex - 1].extensions.join('|') + ')$', 'i');
var filter = function(entry) {
return entry.isDirectory || regexp.test(entry.name);
};
this.fileFilter_.addFilter('fileType', filter);
+
+ // In save dialog, update the destination name extension.
+ if (this.dialogType === DialogType.SELECT_SAVEAS_FILE) {
+ var current = this.filenameInput_.value;
+ var newExt = this.fileTypes_[selectedIndex - 1].extensions[0];
+ if (newExt && !regexp.test(current)) {
hirono 2014/06/11 07:14:05 Maybe we can do just: if (newExt) { this.filenam
kinaba 2014/06/11 07:23:44 Unfortunately not. |regexp| matches with the new e
+ var i = current.lastIndexOf('.');
+ if (i >= 0) {
+ this.filenameInput_.value = current.substr(0, i) + '.' + newExt;
+ this.selectTargetNameInFilenameInput_();
+ }
+ }
+ }
}
};
« 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