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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Namespace for utility functions. | 8 * Namespace for utility functions. |
9 */ | 9 */ |
10 var filelist = {}; | 10 var filelist = {}; |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 }; | 950 }; |
951 | 951 |
952 /** | 952 /** |
953 * Common item decoration for table's and grid's items. | 953 * Common item decoration for table's and grid's items. |
954 * @param {ListItem} li List item. | 954 * @param {ListItem} li List item. |
955 * @param {Entry} entry The entry. | 955 * @param {Entry} entry The entry. |
956 * @param {MetadataCache} metadataCache Cache to retrieve metadada. | 956 * @param {MetadataCache} metadataCache Cache to retrieve metadada. |
957 */ | 957 */ |
958 filelist.decorateListItem = function(li, entry, metadataCache) { | 958 filelist.decorateListItem = function(li, entry, metadataCache) { |
959 li.classList.add(entry.isDirectory ? 'directory' : 'file'); | 959 li.classList.add(entry.isDirectory ? 'directory' : 'file'); |
960 // TODO(mtomasz): Use Entry instead of paths. | 960 // The metadata may not yet be ready. In that case, the list item will be |
961 if (PathUtil.isDriveBasedPath(entry.fullPath)) { | 961 // updated when the metadata is ready via updateListItemsMetadata. For files |
962 // The metadata may not yet be ready. In that case, the list item will be | 962 // not on Drive, driveProps is not available. |
963 // updated when the metadata is ready via updateListItemsMetadata. | 963 var driveProps = metadataCache.getCached(entry, 'drive'); |
964 var driveProps = metadataCache.getCached(entry, 'drive'); | 964 if (driveProps) |
965 if (driveProps) | 965 filelist.updateListItemDriveProps(li, driveProps); |
966 filelist.updateListItemDriveProps(li, driveProps); | |
967 } | |
968 | 966 |
969 // Overriding the default role 'list' to 'listbox' for better | 967 // Overriding the default role 'list' to 'listbox' for better |
970 // accessibility on ChromeOS. | 968 // accessibility on ChromeOS. |
971 li.setAttribute('role', 'option'); | 969 li.setAttribute('role', 'option'); |
972 | 970 |
973 Object.defineProperty(li, 'selected', { | 971 Object.defineProperty(li, 'selected', { |
974 /** | 972 /** |
975 * @this {ListItem} | 973 * @this {ListItem} |
976 * @return {boolean} True if the list item is selected. | 974 * @return {boolean} True if the list item is selected. |
977 */ | 975 */ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 // crbug.com/246611. | 1026 // crbug.com/246611. |
1029 } | 1027 } |
1030 | 1028 |
1031 if (driveProps.customIconUrl) { | 1029 if (driveProps.customIconUrl) { |
1032 var iconDiv = li.querySelector('.detail-icon'); | 1030 var iconDiv = li.querySelector('.detail-icon'); |
1033 if (!iconDiv) | 1031 if (!iconDiv) |
1034 return; | 1032 return; |
1035 iconDiv.style.backgroundImage = 'url(' + driveProps.customIconUrl + ')'; | 1033 iconDiv.style.backgroundImage = 'url(' + driveProps.customIconUrl + ')'; |
1036 } | 1034 } |
1037 }; | 1035 }; |
OLD | NEW |