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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 10107016: Reduce blinking of icons in the preview panel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 removeChildren(self.previewThumbnails_);
2269 self.previewThumbnails_.appendChild(thumbnails);
2270 }
2271
2272 function onThumbnailLoaded() {
2273 thumbnailLoaded++;
2274 if (thumbnailLoaded == thumbnailCount)
2275 showThumbnails();
2276 }
2258 2277
2259 for (var i = 0; i < selection.indexes.length; i++) { 2278 for (var i = 0; i < selection.indexes.length; i++) {
2260 var entry = this.directoryModel_.fileList.item(selection.indexes[i]); 2279 var entry = this.directoryModel_.fileList.item(selection.indexes[i]);
2261 if (!entry) 2280 if (!entry)
2262 continue; 2281 continue;
2263 2282
2264 selection.entries.push(entry); 2283 selection.entries.push(entry);
2265 selection.urls.push(entry.toURL()); 2284 selection.urls.push(entry.toURL());
2266 2285
2267 if (selection.iconType == null) { 2286 if (selection.iconType == null) {
2268 selection.iconType = this.getIconType(entry); 2287 selection.iconType = this.getIconType(entry);
2269 } else if (selection.iconType != 'unknown') { 2288 } else if (selection.iconType != 'unknown') {
2270 var iconType = this.getIconType(entry); 2289 var iconType = this.getIconType(entry);
2271 if (selection.iconType != iconType) 2290 if (selection.iconType != iconType)
2272 selection.iconType = 'unknown'; 2291 selection.iconType = 'unknown';
2273 } 2292 }
2274 2293
2275 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) { 2294 if (thumbnailCount < MAX_PREVIEW_THUMBAIL_COUNT) {
2276 var box = this.document_.createElement('div'); 2295 var box = this.document_.createElement('div');
2277 var imageLoadCalback = thumbnailCount == 0 && 2296 function imageLoadCalback(box) {
2278 this.initThumbnailZoom_.bind(this, box); 2297 if (thumbnailCount == 0)
2279 var thumbnail = this.renderThumbnailBox_(entry, true, imageLoadCalback); 2298 self.initThumbnailZoom_(box);
2299 onThumbnailLoaded();
2300 }
2301 thumbnailCount++;
2302 var thumbnail = this.renderThumbnailBox_(entry, true,
2303 imageLoadCalback.bind(box));
dgozman 2012/04/17 13:33:43 imageLoadCallback.bind(null, box)
SeRya 2012/04/17 13:51:32 Done.
2280 box.appendChild(thumbnail); 2304 box.appendChild(thumbnail);
2281 box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i; 2305 box.style.zIndex = MAX_PREVIEW_THUMBAIL_COUNT + 1 - i;
2282 box.addEventListener('click', 2306 box.addEventListener('click',
2283 this.dispatchDefaultTask_.bind(this, selection)); 2307 this.dispatchDefaultTask_.bind(this, selection));
2284 2308
2285 this.previewThumbnails_.appendChild(box); 2309 thumbnails.appendChild(box);
2286 thumbnailCount++;
2287 } 2310 }
2288 2311
2289 selection.totalCount++; 2312 selection.totalCount++;
2290 2313
2291 if (entry.isFile) { 2314 if (entry.isFile) {
2292 selection.fileCount += 1; 2315 selection.fileCount += 1;
2293 if (!('cachedSize_' in entry)) { 2316 if (!('cachedSize_' in entry)) {
2294 // Any file that hasn't been rendered may be missing its cachedSize_ 2317 // 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 2318 // 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 2319 // to select all. In this case, we need to asynchronously get the
2297 // sizes for these files before telling the world the selection has 2320 // sizes for these files before telling the world the selection has
2298 // been summarized. See the 'computeNextFile' logic below. 2321 // been summarized. See the 'computeNextFile' logic below.
2299 pendingFiles.push(entry); 2322 pendingFiles.push(entry);
2300 } else { 2323 } else {
2301 selection.bytes += entry.cachedSize_; 2324 selection.bytes += entry.cachedSize_;
2302 selection.showBytes |= this.getFileType(entry).type != 'hosted'; 2325 selection.showBytes |= this.getFileType(entry).type != 'hosted';
2303 } 2326 }
2304 } else { 2327 } else {
2305 selection.directoryCount += 1; 2328 selection.directoryCount += 1;
2306 } 2329 }
2307 } 2330 }
2308 2331
2309 // Now this.selection is complete. Update buttons. 2332 // Now this.selection is complete. Update buttons.
2310 this.updateCommonActionButtons_(); 2333 this.updateCommonActionButtons_();
2311 this.updatePreviewPanelVisibility_(); 2334 this.updatePreviewPanelVisibility_();
2312 2335 forcedShowTimeout = setTimeout(showThumbnails, 100);
dgozman 2012/04/17 13:33:43 Cancel the previous timeout, if selection changed
SeRya 2012/04/17 13:51:32 Check the selection has not changed instead.
2313 var self = this; 2336 onThumbnailLoaded();
2314 2337
2315 function cacheNextFile(fileEntry) { 2338 function cacheNextFile(fileEntry) {
2316 if (fileEntry) { 2339 if (fileEntry) {
2317 // We're careful to modify the 'selection', rather than 'self.selection' 2340 // We're careful to modify the 'selection', rather than 'self.selection'
2318 // here, just in case the selection has changed since this summarization 2341 // here, just in case the selection has changed since this summarization
2319 // began. 2342 // began.
2320 selection.bytes += fileEntry.cachedSize_; 2343 selection.bytes += fileEntry.cachedSize_;
2321 selection.showBytes |= self.getFileType(fileEntry).type != 'hosted'; 2344 selection.showBytes |= self.getFileType(fileEntry).type != 'hosted';
2322 } 2345 }
2323 2346
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after
4422 4445
4423 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo); 4446 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo);
4424 4447
4425 if (oldValue) { 4448 if (oldValue) {
4426 event.target.removeAttribute('checked'); 4449 event.target.removeAttribute('checked');
4427 } else { 4450 } else {
4428 event.target.setAttribute('checked', 'checked'); 4451 event.target.setAttribute('checked', 'checked');
4429 } 4452 }
4430 }; 4453 };
4431 })(); 4454 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698