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

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

Issue 10409066: Sort by type now sorts by localized string representation of file type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Codereview fix. Created 8 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 | 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 502b1bbf4f93349ffc1e3052e2defd8401fb9ace..746f97f76e6987575954a4b51d1d9222dd3ba3d0 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -875,19 +875,14 @@ FileManager.prototype = {
* Compare by type first, then by subtype and then by name.
*/
FileManager.prototype.compareType_ = function(a, b) {
- var aType = FileType.getType(a);
- var bType = FileType.getType(b);
+ // Directories precede files.
+ if (a.isDirectory != b.isDirectory)
+ return Number(b.isDirectory) - Number(a.isDirectory);
+ var aType = this.getFileTypeString_(a);
+ var bType = this.getFileTypeString_(b);
- // Files of unknown type follows all the others.
- var result = this.collator_.compare(aType.type || 'Z',
- bType.type || 'Z');
- if (result != 0)
- return result;
-
- // If types are same both subtypes are defined of both are undefined.
- result = this.collator_.compare(aType.subtype || '',
- bType.subtype || '');
+ var result = this.collator_.compare(aType, bType);
if (result != 0)
return result;
@@ -1991,12 +1986,20 @@ FileManager.prototype = {
FileManager.prototype.renderType_ = function(entry, columnId, table) {
var div = this.document_.createElement('div');
div.className = 'type';
+ div.textContent = this.getFileTypeString_(entry);
+ return div;
+ };
+
+ /**
+ * @param {Entry} entry File or directory entry.
+ * @return {string} Localized string representation of file type.
+ */
+ FileManager.prototype.getFileTypeString_ = function(entry) {
var fileType = FileType.getType(entry);
if (fileType.subtype)
- div.textContent = strf(fileType.name, fileType.subtype);
+ return strf(fileType.name, fileType.subtype);
else
- div.textContent = str(fileType.name);
- return div;
+ return str(fileType.name);
};
/**
« 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