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

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

Issue 13572006: Files.app: Clear the stored destination path on clear the drop target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comment Created 7 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
« 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Global (placed in the window object) variable name to hold internal 8 * Global (placed in the window object) variable name to hold internal
9 * file dragging information. Needed to show visual feedback while dragging 9 * file dragging information. Needed to show visual feedback while dragging
10 * since DataTransfer object is in protected state. Reachable from other 10 * since DataTransfer object is in protected state. Reachable from other
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 * @param {Element} domElement Target of the drop. 470 * @param {Element} domElement Target of the drop.
471 * @param {boolean} isDirectory If the target is a directory. 471 * @param {boolean} isDirectory If the target is a directory.
472 * @param {DataTransfer} dataTransfer Data transfer object. 472 * @param {DataTransfer} dataTransfer Data transfer object.
473 * @param {string} destinationPath Destination path. 473 * @param {string} destinationPath Destination path.
474 */ 474 */
475 setDropTarget_: function(domElement, isDirectory, dataTransfer, 475 setDropTarget_: function(domElement, isDirectory, dataTransfer,
476 destinationPath) { 476 destinationPath) {
477 if (this.dropTarget_ == domElement) 477 if (this.dropTarget_ == domElement)
478 return; 478 return;
479 479
480 /** @type {string?} */ 480 // Remove the old drop target.
481 this.destinationPath_ = null; 481 this.clearDropTarget_();
482 482
483 // Add accept class if the domElement can accept the drag. 483 // Add accept class if the domElement can accept the drag.
484 if (isDirectory && 484 if (isDirectory &&
485 this.canPasteOrDrop_(dataTransfer, destinationPath)) { 485 this.canPasteOrDrop_(dataTransfer, destinationPath)) {
486 domElement.classList.add('accepts'); 486 domElement.classList.add('accepts');
487 this.destinationPath_ = destinationPath; 487 this.destinationPath_ = destinationPath;
488 } 488 }
489 489
490 // Remove the old drag target.
491 this.clearDropTarget_();
492
493 // Set the new drop target. 490 // Set the new drop target.
494 this.dropTarget_ = domElement; 491 this.dropTarget_ = domElement;
495 492
496 // Start timer changing the directory. 493 // Start timer changing the directory.
497 if (domElement && isDirectory && destinationPath && 494 if (domElement && isDirectory && destinationPath &&
498 this.canPasteOrDrop_(dataTransfer, destinationPath)) { 495 this.canPasteOrDrop_(dataTransfer, destinationPath)) {
499 this.navigateTimer_ = setTimeout(function() { 496 this.navigateTimer_ = setTimeout(function() {
500 if (domElement instanceof DirectoryItem) 497 if (domElement instanceof DirectoryItem)
501 // Do custom action. 498 // Do custom action.
502 (/** @type {DirectoryItem} */ domElement).doDropTargetAction(); 499 (/** @type {DirectoryItem} */ domElement).doDropTargetAction();
503 500
504 this.directoryModel_.changeDirectory(destinationPath); 501 this.directoryModel_.changeDirectory(destinationPath);
505 }.bind(this), 2000); 502 }.bind(this), 2000);
506 } 503 }
507 }, 504 },
508 505
509 /** 506 /**
510 * Clears the drop target. 507 * Clears the drop target.
511 * @this {FileTransferController} 508 * @this {FileTransferController}
512 */ 509 */
513 clearDropTarget_: function() { 510 clearDropTarget_: function() {
514 if (this.dropTarget_ && this.dropTarget_.classList.contains('accepts')) 511 if (this.dropTarget_ && this.dropTarget_.classList.contains('accepts'))
515 this.dropTarget_.classList.remove('accepts'); 512 this.dropTarget_.classList.remove('accepts');
516 this.dropTarget_ = null; 513 this.dropTarget_ = null;
514 this.destinationPath_ = null;
517 if (this.navigateTimer_ !== undefined) { 515 if (this.navigateTimer_ !== undefined) {
518 clearTimeout(this.navigateTimer_); 516 clearTimeout(this.navigateTimer_);
519 this.navigateTimer_ = undefined; 517 this.navigateTimer_ = undefined;
520 } 518 }
521 }, 519 },
522 520
523 /** 521 /**
524 * @this {FileTransferController} 522 * @this {FileTransferController}
525 * @return {boolean} Returns false if {@code <input type="text">} element is 523 * @return {boolean} Returns false if {@code <input type="text">} element is
526 * currently active. Otherwise, returns true. 524 * currently active. Otherwise, returns true.
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 !event.ctrlKey) { 826 !event.ctrlKey) {
829 return 'move'; 827 return 'move';
830 } 828 }
831 if (event.dataTransfer.effectAllowed == 'copyMove' && 829 if (event.dataTransfer.effectAllowed == 'copyMove' &&
832 event.shiftKey) { 830 event.shiftKey) {
833 return 'move'; 831 return 'move';
834 } 832 }
835 return 'copy'; 833 return 'copy';
836 }, 834 },
837 }; 835 };
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