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

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

Issue 479503002: Files.app: Not use URL in sorting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comment Created 6 years, 4 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
Index: ui/file_manager/file_manager/foreground/js/directory_contents.js
diff --git a/ui/file_manager/file_manager/foreground/js/directory_contents.js b/ui/file_manager/file_manager/foreground/js/directory_contents.js
index b40d1ec04fab3da10ee88ebe3bcd1c0221e15340..10ca762e4b2cfd863986691d4016db35c5c25b5b 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_contents.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js
@@ -415,14 +415,8 @@ function FileListModel(metadataCache) {
*/
this.metadataCache_ = metadataCache;
- /**
- * Collator for sorting.
- * @type {Intl.Collator}
- */
- this.collator_ = new Intl.Collator([], {numeric: true, sensitivity: 'base'});
-
// Initialize compare functions.
- this.setCompareFunction('name', this.compareName_.bind(this));
+ this.setCompareFunction('name', util.compareName);
this.setCompareFunction('modificationTime', this.compareMtime_.bind(this));
this.setCompareFunction('size', this.compareSize_.bind(this));
this.setCompareFunction('type', this.compareType_.bind(this));
@@ -439,18 +433,6 @@ FileListModel.prototype = {
* @return {number} Compare result.
* @private
*/
-FileListModel.prototype.compareName_ = function(a, b) {
- var result = this.collator_.compare(a.name, b.name);
- return result !== 0 ? result : a.toURL().localeCompare(b.toURL());
-};
-
-/**
- * Compare by mtime first, then by name.
- * @param {Entry} a First entry.
- * @param {Entry} b Second entry.
- * @return {number} Compare result.
- * @private
- */
FileListModel.prototype.compareMtime_ = function(a, b) {
var aCachedFilesystem = this.metadataCache_.getCached(a, 'filesystem');
var aTime = aCachedFilesystem ? aCachedFilesystem.modificationTime : 0;
@@ -464,7 +446,7 @@ FileListModel.prototype.compareMtime_ = function(a, b) {
if (aTime < bTime)
return -1;
- return this.compareName_(a, b);
+ return util.compareName(a, b);
};
/**
@@ -481,7 +463,7 @@ FileListModel.prototype.compareSize_ = function(a, b) {
var bCachedFilesystem = this.metadataCache_.getCached(b, 'filesystem');
var bSize = bCachedFilesystem ? bCachedFilesystem.size : 0;
- return aSize !== bSize ? aSize - bSize : this.compareName_(a, b);
+ return aSize !== bSize ? aSize - bSize : util.compareName(a, b);
};
/**
@@ -499,8 +481,8 @@ FileListModel.prototype.compareType_ = function(a, b) {
var aType = FileType.typeToString(FileType.getType(a));
var bType = FileType.typeToString(FileType.getType(b));
- var result = this.collator_.compare(aType, bType);
- return result !== 0 ? result : this.compareName_(a, b);
+ var result = util.collator.compare(aType, bType);
+ return result !== 0 ? result : util.compareName(a, b);
};
/**
« no previous file with comments | « ui/file_manager/file_manager/common/js/util.js ('k') | ui/file_manager/file_manager/foreground/js/directory_tree.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698