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 * Global (placed in the window object) variable name to hold internal | 6 * Global (placed in the window object) variable name to hold internal |
7 * file dragging information. Needed to show visual feedback while dragging | 7 * file dragging information. Needed to show visual feedback while dragging |
8 * since DataTransfer object is in protected state. Reachable from other | 8 * since DataTransfer object is in protected state. Reachable from other |
9 * file manager instances. | 9 * file manager instances. |
10 */ | 10 */ |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1254 doc.addEventListener(command, handler); | 1254 doc.addEventListener(command, handler); |
1255 doc.execCommand(command); | 1255 doc.execCommand(command); |
1256 doc.removeEventListener(command, handler); | 1256 doc.removeEventListener(command, handler); |
1257 }; | 1257 }; |
1258 | 1258 |
1259 /** | 1259 /** |
1260 * @private | 1260 * @private |
1261 */ | 1261 */ |
1262 FileTransferController.prototype.onFileSelectionChanged_ = function() { | 1262 FileTransferController.prototype.onFileSelectionChanged_ = function() { |
1263 this.preloadedThumbnailImagePromise_ = null; | 1263 this.preloadedThumbnailImagePromise_ = null; |
1264 this.selectedAsyncData_ = {}; | 1264 // Remove file objects that are no longer in the selection. |
fukino
2017/04/26 07:14:31
It might be better to place this logic in onFileSe
tetsui2
2017/04/26 07:42:31
Done.
| |
1265 var newSelectedAsyncData = {}; | |
1266 var entries = this.selectionHandler_.selection.entries; | |
1267 for (var i = 0; i < entries.length; i++) { | |
1268 var entryUrl = entries[i].toURL(); | |
1269 if (entryUrl in this.selectedAsyncData_) { | |
1270 newSelectedAsyncData[entryUrl] = this.selectedAsyncData_[entryUrl]; | |
1271 } | |
1272 } | |
1273 this.selectedAsyncData_ = newSelectedAsyncData; | |
1265 }; | 1274 }; |
1266 | 1275 |
1267 /** | 1276 /** |
1268 * @private | 1277 * @private |
1269 */ | 1278 */ |
1270 FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() { | 1279 FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() { |
1271 var entries = this.selectionHandler_.selection.entries; | 1280 var entries = this.selectionHandler_.selection.entries; |
1272 var asyncData = this.selectedAsyncData_; | 1281 var asyncData = this.selectedAsyncData_; |
1273 var fileEntries = []; | 1282 var fileEntries = []; |
1274 for (var i = 0; i < entries.length; i++) { | 1283 for (var i = 0; i < entries.length; i++) { |
1275 if (entries[i].isFile) | 1284 if (entries[i].isFile) |
1276 fileEntries.push(entries[i]); | 1285 fileEntries.push(entries[i]); |
1277 asyncData[entries[i].toURL()] = {externalFileUrl: '', file: null}; | 1286 if (!(entries[i].toURL() in asyncData)) { |
1287 asyncData[entries[i].toURL()] = {externalFileUrl: '', file: null}; | |
1288 } | |
1278 } | 1289 } |
1279 var containsDirectory = this.selectionHandler_.selection.directoryCount > 0; | 1290 var containsDirectory = this.selectionHandler_.selection.directoryCount > 0; |
1280 | 1291 |
1281 // File object must be prepeared in advance for clipboard operations | 1292 // File object must be prepeared in advance for clipboard operations |
1282 // (copy, paste and drag). DataTransfer object closes for write after | 1293 // (copy, paste and drag). DataTransfer object closes for write after |
1283 // returning control from that handlers so they may not have | 1294 // returning control from that handlers so they may not have |
1284 // asynchronous operations. | 1295 // asynchronous operations. |
1285 if (!containsDirectory) { | 1296 if (!containsDirectory) { |
1286 for (var i = 0; i < fileEntries.length; i++) { | 1297 for (var i = 0; i < fileEntries.length; i++) { |
1287 (function(fileEntry) { | 1298 (function(fileEntry) { |
1288 fileEntry.file(function(file) { | 1299 if (!(asyncData[fileEntry.toURL()].file)) { |
1289 asyncData[fileEntry.toURL()].file = file; | 1300 fileEntry.file(function(file) { |
1290 }); | 1301 asyncData[fileEntry.toURL()].file = file; |
1302 }); | |
1303 } | |
1291 })(fileEntries[i]); | 1304 })(fileEntries[i]); |
1292 } | 1305 } |
1293 } | 1306 } |
1294 | 1307 |
1295 if (entries.length === 1) { | 1308 if (entries.length === 1) { |
1296 // For single selection, the dragged element is created in advance, | 1309 // For single selection, the dragged element is created in advance, |
1297 // otherwise an image may not be loaded at the time the 'dragstart' event | 1310 // otherwise an image may not be loaded at the time the 'dragstart' event |
1298 // comes. | 1311 // comes. |
1299 this.preloadThumbnailImage_(entries[0]); | 1312 this.preloadThumbnailImage_(entries[0]); |
1300 } | 1313 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1386 listItems.push(listItem); | 1399 listItems.push(listItem); |
1387 } | 1400 } |
1388 } | 1401 } |
1389 | 1402 |
1390 setTimeout(function() { | 1403 setTimeout(function() { |
1391 for (var i = 0; i < listItems.length; i++) { | 1404 for (var i = 0; i < listItems.length; i++) { |
1392 listItems[i].classList.remove('blink'); | 1405 listItems[i].classList.remove('blink'); |
1393 } | 1406 } |
1394 }, 100); | 1407 }, 100); |
1395 }; | 1408 }; |
OLD | NEW |