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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 var bSize = bCachedFilesystem ? bCachedFilesystem.size : 0; | 849 var bSize = bCachedFilesystem ? bCachedFilesystem.size : 0; |
850 | 850 |
851 if (aSize != bSize) return aSize - bSize; | 851 if (aSize != bSize) return aSize - bSize; |
852 return this.collator_.compare(a.name, b.name); | 852 return this.collator_.compare(a.name, b.name); |
853 }; | 853 }; |
854 | 854 |
855 /** | 855 /** |
856 * Compare by type first, then by subtype and then by name. | 856 * Compare by type first, then by subtype and then by name. |
857 */ | 857 */ |
858 FileManager.prototype.compareType_ = function(a, b) { | 858 FileManager.prototype.compareType_ = function(a, b) { |
859 var aType = FileType.getType(a); | 859 if (a.isDirectory != b.isDirectory) |
860 var bType = FileType.getType(b); | 860 return Number(b.isDirectory) - Number(a.isDirectory); |
Vladislav Kaznacheev
2012/05/22 12:28:45
Nice trick, lets add a comment regarding the inten
SeRya
2012/05/22 12:34:35
Done.
| |
861 | 861 |
862 var aType = this.getFileTypeString_(a); | |
863 var bType = this.getFileTypeString_(b); | |
862 | 864 |
863 // Files of unknown type follows all the others. | 865 // Files of unknown type follows all the others. |
Vladislav Kaznacheev
2012/05/22 12:28:45
The comment does not seem to be relevant anymore (
SeRya
2012/05/22 12:34:35
Done.
| |
864 var result = this.collator_.compare(aType.type || 'Z', | 866 var result = this.collator_.compare(aType, bType); |
865 bType.type || 'Z'); | |
866 if (result != 0) | 867 if (result != 0) |
867 return result; | 868 return result; |
868 | 869 |
869 // If types are same both subtypes are defined of both are undefined. | |
870 result = this.collator_.compare(aType.subtype || '', | |
871 bType.subtype || ''); | |
872 if (result != 0) | |
873 return result; | |
874 | |
875 return this.collator_.compare(a.name, b.name); | 870 return this.collator_.compare(a.name, b.name); |
876 }; | 871 }; |
877 | 872 |
878 FileManager.prototype.refocus = function() { | 873 FileManager.prototype.refocus = function() { |
879 if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) | 874 if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) |
880 this.filenameInput_.focus(); | 875 this.filenameInput_.focus(); |
881 else | 876 else |
882 this.currentList_.focus(); | 877 this.currentList_.focus(); |
883 }; | 878 }; |
884 | 879 |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1965 /** | 1960 /** |
1966 * Render the Type column of the detail table. | 1961 * Render the Type column of the detail table. |
1967 * | 1962 * |
1968 * @param {Entry} entry The Entry object to render. | 1963 * @param {Entry} entry The Entry object to render. |
1969 * @param {string} columnId The id of the column to be rendered. | 1964 * @param {string} columnId The id of the column to be rendered. |
1970 * @param {cr.ui.Table} table The table doing the rendering. | 1965 * @param {cr.ui.Table} table The table doing the rendering. |
1971 */ | 1966 */ |
1972 FileManager.prototype.renderType_ = function(entry, columnId, table) { | 1967 FileManager.prototype.renderType_ = function(entry, columnId, table) { |
1973 var div = this.document_.createElement('div'); | 1968 var div = this.document_.createElement('div'); |
1974 div.className = 'type'; | 1969 div.className = 'type'; |
1975 var fileType = FileType.getType(entry); | 1970 div.textContent = this.getFileTypeString_(entry); |
1976 if (fileType.subtype) | |
1977 div.textContent = strf(fileType.name, fileType.subtype); | |
1978 else | |
1979 div.textContent = str(fileType.name); | |
1980 return div; | 1971 return div; |
1981 }; | 1972 }; |
1982 | 1973 |
1983 /** | 1974 /** |
1975 * @param {Entry} entry File or directory entry. | |
1976 * @return {string} Localized string representation of file type. | |
1977 */ | |
1978 FileManager.prototype.getFileTypeString_ = function(entry) { | |
1979 var fileType = FileType.getType(entry); | |
1980 if (fileType.subtype) | |
1981 return strf(fileType.name, fileType.subtype); | |
1982 else | |
1983 return str(fileType.name); | |
1984 }; | |
1985 | |
1986 /** | |
1984 * Render the Date column of the detail table. | 1987 * Render the Date column of the detail table. |
1985 * | 1988 * |
1986 * @param {Entry} entry The Entry object to render. | 1989 * @param {Entry} entry The Entry object to render. |
1987 * @param {string} columnId The id of the column to be rendered. | 1990 * @param {string} columnId The id of the column to be rendered. |
1988 * @param {cr.ui.Table} table The table doing the rendering. | 1991 * @param {cr.ui.Table} table The table doing the rendering. |
1989 */ | 1992 */ |
1990 FileManager.prototype.renderDate_ = function(entry, columnId, table) { | 1993 FileManager.prototype.renderDate_ = function(entry, columnId, table) { |
1991 var div = this.document_.createElement('div'); | 1994 var div = this.document_.createElement('div'); |
1992 div.className = 'date'; | 1995 div.className = 'date'; |
1993 | 1996 |
(...skipping 2704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4698 | 4701 |
4699 function closeBanner() { | 4702 function closeBanner() { |
4700 self.cleanupGDataWelcome_(); | 4703 self.cleanupGDataWelcome_(); |
4701 // Stop showing the welcome banner. | 4704 // Stop showing the welcome banner. |
4702 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; | 4705 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; |
4703 } | 4706 } |
4704 | 4707 |
4705 return maybeShowBanner; | 4708 return maybeShowBanner; |
4706 }; | 4709 }; |
4707 })(); | 4710 })(); |
OLD | NEW |