OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * FileManager constructor. | 6 * FileManager constructor. |
7 * | 7 * |
8 * FileManager objects encapsulate the functionality of the file selector | 8 * FileManager objects encapsulate the functionality of the file selector |
9 * dialogs, as well as the full screen file manager application (though the | 9 * dialogs, as well as the full screen file manager application (though the |
10 * latter is not yet implemented). | 10 * latter is not yet implemented). |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 var bSize = bCachedFilesystem ? bCachedFilesystem.size : 0; | 868 var bSize = bCachedFilesystem ? bCachedFilesystem.size : 0; |
869 | 869 |
870 if (aSize != bSize) return aSize - bSize; | 870 if (aSize != bSize) return aSize - bSize; |
871 return this.collator_.compare(a.name, b.name); | 871 return this.collator_.compare(a.name, b.name); |
872 }; | 872 }; |
873 | 873 |
874 /** | 874 /** |
875 * Compare by type first, then by subtype and then by name. | 875 * Compare by type first, then by subtype and then by name. |
876 */ | 876 */ |
877 FileManager.prototype.compareType_ = function(a, b) { | 877 FileManager.prototype.compareType_ = function(a, b) { |
878 var aType = FileType.getType(a); | 878 // Directories precede files. |
879 var bType = FileType.getType(b); | 879 if (a.isDirectory != b.isDirectory) |
| 880 return Number(b.isDirectory) - Number(a.isDirectory); |
880 | 881 |
| 882 var aType = this.getFileTypeString_(a); |
| 883 var bType = this.getFileTypeString_(b); |
881 | 884 |
882 // Files of unknown type follows all the others. | 885 var result = this.collator_.compare(aType, bType); |
883 var result = this.collator_.compare(aType.type || 'Z', | |
884 bType.type || 'Z'); | |
885 if (result != 0) | 886 if (result != 0) |
886 return result; | 887 return result; |
887 | 888 |
888 // If types are same both subtypes are defined of both are undefined. | |
889 result = this.collator_.compare(aType.subtype || '', | |
890 bType.subtype || ''); | |
891 if (result != 0) | |
892 return result; | |
893 | |
894 return this.collator_.compare(a.name, b.name); | 889 return this.collator_.compare(a.name, b.name); |
895 }; | 890 }; |
896 | 891 |
897 FileManager.prototype.refocus = function() { | 892 FileManager.prototype.refocus = function() { |
898 if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) | 893 if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) |
899 this.filenameInput_.focus(); | 894 this.filenameInput_.focus(); |
900 else | 895 else |
901 this.currentList_.focus(); | 896 this.currentList_.focus(); |
902 }; | 897 }; |
903 | 898 |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1984 /** | 1979 /** |
1985 * Render the Type column of the detail table. | 1980 * Render the Type column of the detail table. |
1986 * | 1981 * |
1987 * @param {Entry} entry The Entry object to render. | 1982 * @param {Entry} entry The Entry object to render. |
1988 * @param {string} columnId The id of the column to be rendered. | 1983 * @param {string} columnId The id of the column to be rendered. |
1989 * @param {cr.ui.Table} table The table doing the rendering. | 1984 * @param {cr.ui.Table} table The table doing the rendering. |
1990 */ | 1985 */ |
1991 FileManager.prototype.renderType_ = function(entry, columnId, table) { | 1986 FileManager.prototype.renderType_ = function(entry, columnId, table) { |
1992 var div = this.document_.createElement('div'); | 1987 var div = this.document_.createElement('div'); |
1993 div.className = 'type'; | 1988 div.className = 'type'; |
1994 var fileType = FileType.getType(entry); | 1989 div.textContent = this.getFileTypeString_(entry); |
1995 if (fileType.subtype) | |
1996 div.textContent = strf(fileType.name, fileType.subtype); | |
1997 else | |
1998 div.textContent = str(fileType.name); | |
1999 return div; | 1990 return div; |
2000 }; | 1991 }; |
2001 | 1992 |
2002 /** | 1993 /** |
| 1994 * @param {Entry} entry File or directory entry. |
| 1995 * @return {string} Localized string representation of file type. |
| 1996 */ |
| 1997 FileManager.prototype.getFileTypeString_ = function(entry) { |
| 1998 var fileType = FileType.getType(entry); |
| 1999 if (fileType.subtype) |
| 2000 return strf(fileType.name, fileType.subtype); |
| 2001 else |
| 2002 return str(fileType.name); |
| 2003 }; |
| 2004 |
| 2005 /** |
2003 * Render the Date column of the detail table. | 2006 * Render the Date column of the detail table. |
2004 * | 2007 * |
2005 * @param {Entry} entry The Entry object to render. | 2008 * @param {Entry} entry The Entry object to render. |
2006 * @param {string} columnId The id of the column to be rendered. | 2009 * @param {string} columnId The id of the column to be rendered. |
2007 * @param {cr.ui.Table} table The table doing the rendering. | 2010 * @param {cr.ui.Table} table The table doing the rendering. |
2008 */ | 2011 */ |
2009 FileManager.prototype.renderDate_ = function(entry, columnId, table) { | 2012 FileManager.prototype.renderDate_ = function(entry, columnId, table) { |
2010 var div = this.document_.createElement('div'); | 2013 var div = this.document_.createElement('div'); |
2011 div.className = 'date'; | 2014 div.className = 'date'; |
2012 | 2015 |
(...skipping 2740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4753 | 4756 |
4754 function closeBanner() { | 4757 function closeBanner() { |
4755 self.cleanupGDataWelcome_(); | 4758 self.cleanupGDataWelcome_(); |
4756 // Stop showing the welcome banner. | 4759 // Stop showing the welcome banner. |
4757 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; | 4760 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; |
4758 } | 4761 } |
4759 | 4762 |
4760 return maybeShowBanner; | 4763 return maybeShowBanner; |
4761 }; | 4764 }; |
4762 })(); | 4765 })(); |
OLD | NEW |