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 // Setting the src of an img to an empty string can crash the browser, so we | 5 // Setting the src of an img to an empty string can crash the browser, so we |
6 // use an empty 1x1 gif instead. | 6 // use an empty 1x1 gif instead. |
7 | 7 |
8 /** | 8 /** |
9 * FileManager constructor. | 9 * FileManager constructor. |
10 * | 10 * |
(...skipping 2231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2242 }; | 2242 }; |
2243 | 2243 |
2244 if (!selection.indexes.length) { | 2244 if (!selection.indexes.length) { |
2245 this.updateCommonActionButtons_(); | 2245 this.updateCommonActionButtons_(); |
2246 this.updatePreviewPanelVisibility_(); | 2246 this.updatePreviewPanelVisibility_(); |
2247 cr.dispatchSimpleEvent(this, 'selection-summarized'); | 2247 cr.dispatchSimpleEvent(this, 'selection-summarized'); |
2248 return; | 2248 return; |
2249 } | 2249 } |
2250 | 2250 |
2251 this.previewSummary_.textContent = str('COMPUTING_SELECTION'); | 2251 this.previewSummary_.textContent = str('COMPUTING_SELECTION'); |
2252 removeChildren(this.previewThumbnails_); | 2252 var thumbnails = this.document_.createDocumentFragment(); |
2253 | 2253 |
2254 var fileCount = 0; | 2254 var fileCount = 0; |
2255 var byteCount = 0; | 2255 var byteCount = 0; |
2256 var pendingFiles = []; | 2256 var pendingFiles = []; |
2257 var thumbnailCount = 0; | 2257 var thumbnailCount = 0; |
2258 var thumbnailLoaded = -1; | |
2259 var forcedShowTimeout = null; | |
2260 var self = this; | |
2261 | |
2262 function showThumbnails() { | |
2263 if (forcedShowTimeout === null) | |
2264 return; | |
2265 clearTimeout(forcedShowTimeout); | |
2266 forcedShowTimeout = null; | |
2267 | |
2268 if (self.selection == selection) { | |
dgozman
2012/04/17 14:07:44
Comment this line please.
SeRya
2012/04/17 14:12:32
Done.
| |
2269 removeChildren(self.previewThumbnails_); | |
2270 self.previewThumbnails_.appendChild(thumbnails); | |
2271 } | |
2272 } | |
2273 | |
2274 function onThumbnailLoaded() { | |
2275 thumbnailLoaded++; | |
2276 if (thumbnailLoaded == thumbnailCount) | |
2277 showThumbnails(); | |
2278 } | |
2258 | 2279 |
2259 for (var i = 0; i < selection.indexes.length; i++) { | 2280 for (var i = 0; i < selection.indexes.length; i++) { |
2260 var entry = this.directoryModel_.fileList.item(selection.indexes[i]); | 2281 var entry = this.directoryModel_.fileList.item(selection.indexes[i]); |
2261 if (!entry) | 2282 if (!entry) |
2262 continue; | 2283 continue; |
2263 | 2284 |
2264 selection.entries.push(entry); | 2285 selection.entries.push(entry); |
2265 selection.urls.push(entry.toURL()); | 2286 selection.urls.push(entry.toURL()); |
2266 | 2287 |
2267 if (selection.iconType == null) { | 2288 if (selection.iconType == null) { |
2268 selection.iconType = this.getIconType(entry); | 2289 selection.iconType = this.getIconType(entry); |
2269 } else if (selection.iconType != 'unknown') { | 2290 } else if (selection.iconType != 'unknown') { |
2270 var iconType = this.getIconType(entry); | 2291 var iconType = this.getIconType(entry); |
2271 if (selection.iconType != iconType) | 2292 if (selection.iconType != iconType) |
2272 selection.iconType = 'unknown'; | 2293 selection.iconType = 'unknown'; |
2273 } | 2294 } |
2274 | 2295 |
2275 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { | 2296 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { |
2276 var box = this.document_.createElement('div'); | 2297 var box = this.document_.createElement('div'); |
2277 var imageLoadCalback = thumbnailCount == 0 && | 2298 function imageLoadCalback(index, box, img, transform) { |
2278 this.initThumbnailZoom_.bind(this, box); | 2299 if (index == 0) |
2279 var thumbnail = this.renderThumbnailBox_(entry, true, imageLoadCalback); | 2300 self.initThumbnailZoom_(box, img, transform); |
2301 onThumbnailLoaded(); | |
2302 } | |
2303 var thumbnail = this.renderThumbnailBox_(entry, true, | |
2304 imageLoadCalback.bind(null, thumbnailCount, box)); | |
2305 thumbnailCount++; | |
2280 box.appendChild(thumbnail); | 2306 box.appendChild(thumbnail); |
2281 box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i; | 2307 box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i; |
2282 box.addEventListener('click', | 2308 box.addEventListener('click', |
2283 this.dispatchDefaultTask_.bind(this, selection)); | 2309 this.dispatchDefaultTask_.bind(this, selection)); |
2284 | 2310 |
2285 this.previewThumbnails_.appendChild(box); | 2311 thumbnails.appendChild(box); |
2286 thumbnailCount++; | |
2287 } | 2312 } |
2288 | 2313 |
2289 selection.totalCount++; | 2314 selection.totalCount++; |
2290 | 2315 |
2291 if (entry.isFile) { | 2316 if (entry.isFile) { |
2292 selection.fileCount += 1; | 2317 selection.fileCount += 1; |
2293 if (!('cachedSize_' in entry)) { | 2318 if (!('cachedSize_' in entry)) { |
2294 // Any file that hasn't been rendered may be missing its cachedSize_ | 2319 // Any file that hasn't been rendered may be missing its cachedSize_ |
2295 // property. For example, visit a large file list, and press ctrl-a | 2320 // property. For example, visit a large file list, and press ctrl-a |
2296 // to select all. In this case, we need to asynchronously get the | 2321 // to select all. In this case, we need to asynchronously get the |
2297 // sizes for these files before telling the world the selection has | 2322 // sizes for these files before telling the world the selection has |
2298 // been summarized. See the 'computeNextFile' logic below. | 2323 // been summarized. See the 'computeNextFile' logic below. |
2299 pendingFiles.push(entry); | 2324 pendingFiles.push(entry); |
2300 } else { | 2325 } else { |
2301 selection.bytes += entry.cachedSize_; | 2326 selection.bytes += entry.cachedSize_; |
2302 selection.showBytes |= this.getFileType(entry).type != 'hosted'; | 2327 selection.showBytes |= this.getFileType(entry).type != 'hosted'; |
2303 } | 2328 } |
2304 } else { | 2329 } else { |
2305 selection.directoryCount += 1; | 2330 selection.directoryCount += 1; |
2306 } | 2331 } |
2307 } | 2332 } |
2308 | 2333 |
2309 // Now this.selection is complete. Update buttons. | 2334 // Now this.selection is complete. Update buttons. |
2310 this.updateCommonActionButtons_(); | 2335 this.updateCommonActionButtons_(); |
2311 this.updatePreviewPanelVisibility_(); | 2336 this.updatePreviewPanelVisibility_(); |
2312 | 2337 forcedShowTimeout = setTimeout(showThumbnails, 100); |
2313 var self = this; | 2338 onThumbnailLoaded(); |
2314 | 2339 |
2315 function cacheNextFile(fileEntry) { | 2340 function cacheNextFile(fileEntry) { |
2316 if (fileEntry) { | 2341 if (fileEntry) { |
2317 // We're careful to modify the 'selection', rather than 'self.selection' | 2342 // We're careful to modify the 'selection', rather than 'self.selection' |
2318 // here, just in case the selection has changed since this summarization | 2343 // here, just in case the selection has changed since this summarization |
2319 // began. | 2344 // began. |
2320 selection.bytes += fileEntry.cachedSize_; | 2345 selection.bytes += fileEntry.cachedSize_; |
2321 selection.showBytes |= self.getFileType(fileEntry).type != 'hosted'; | 2346 selection.showBytes |= self.getFileType(fileEntry).type != 'hosted'; |
2322 } | 2347 } |
2323 | 2348 |
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4422 | 4447 |
4423 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo); | 4448 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo); |
4424 | 4449 |
4425 if (oldValue) { | 4450 if (oldValue) { |
4426 event.target.removeAttribute('checked'); | 4451 event.target.removeAttribute('checked'); |
4427 } else { | 4452 } else { |
4428 event.target.setAttribute('checked', 'checked'); | 4453 event.target.setAttribute('checked', 'checked'); |
4429 } | 4454 } |
4430 }; | 4455 }; |
4431 })(); | 4456 })(); |
OLD | NEW |