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 var MAX_DRAG_THUMBAIL_COUNT = 4; | 5 var MAX_DRAG_THUMBAIL_COUNT = 4; |
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 */ | 64 */ |
65 attachDropTarget: function(list, opt_onlyIntoDirectories) { | 65 attachDropTarget: function(list, opt_onlyIntoDirectories) { |
66 list.addEventListener('dragover', this.onDragOver_.bind(this, | 66 list.addEventListener('dragover', this.onDragOver_.bind(this, |
67 !!opt_onlyIntoDirectories, list)); | 67 !!opt_onlyIntoDirectories, list)); |
68 list.addEventListener('dragenter', this.onDragEnterList_.bind(this, list)); | 68 list.addEventListener('dragenter', this.onDragEnterList_.bind(this, list)); |
69 list.addEventListener('dragleave', this.onDragLeave_.bind(this, list)); | 69 list.addEventListener('dragleave', this.onDragLeave_.bind(this, list)); |
70 list.addEventListener('drop', this.onDrop_.bind(this, | 70 list.addEventListener('drop', this.onDrop_.bind(this, |
71 !!opt_onlyIntoDirectories)); | 71 !!opt_onlyIntoDirectories)); |
72 }, | 72 }, |
73 | 73 |
74 attachBreadcrumbsDropTarget: function(breadcrumbs) { | 74 attachBreadcrumbsDropTarget: function(breadcrumbsController) { |
75 breadcrumbs.addEventListener('dragover', | 75 var container = breadcrumbsController.getContainer(); |
| 76 container.addEventListener('dragover', |
76 this.onDragOver_.bind(this, true, null)); | 77 this.onDragOver_.bind(this, true, null)); |
77 breadcrumbs.addEventListener('dragenter', | 78 container.addEventListener('dragenter', |
78 this.onDragEnterBreadcrumbs_.bind(this, breadcrumbs)); | 79 this.onDragEnterBreadcrumbs_.bind(this, breadcrumbsController)); |
79 breadcrumbs.addEventListener('dragleave', | 80 container.addEventListener('dragleave', |
80 this.onDragLeave_.bind(this, null)); | 81 this.onDragLeave_.bind(this, null)); |
81 breadcrumbs.addEventListener('drop', this.onDrop_.bind(this, true)); | 82 container.addEventListener('drop', this.onDrop_.bind(this, true)); |
82 }, | 83 }, |
83 | 84 |
84 /** | 85 /** |
85 * Attach handlers of copy, cut and paste operations to the document. | 86 * Attach handlers of copy, cut and paste operations to the document. |
86 * @param {HTMLDocument} doc Command dispatcher. | 87 * @param {HTMLDocument} doc Command dispatcher. |
87 */ | 88 */ |
88 attachCopyPasteHandlers: function(doc) { | 89 attachCopyPasteHandlers: function(doc) { |
89 this.document_ = doc; | 90 this.document_ = doc; |
90 doc.addEventListener('beforecopy', this.onBeforeCopy_.bind(this)); | 91 doc.addEventListener('beforecopy', this.onBeforeCopy_.bind(this)); |
91 doc.addEventListener('copy', this.onCopy_.bind(this)); | 92 doc.addEventListener('copy', this.onCopy_.bind(this)); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 262 |
262 var entry = item && list.dataModel.item(item.listIndex); | 263 var entry = item && list.dataModel.item(item.listIndex); |
263 if (entry) { | 264 if (entry) { |
264 this.setDropTarget_(item, entry.isDirectory, event.dataTransfer, | 265 this.setDropTarget_(item, entry.isDirectory, event.dataTransfer, |
265 entry.fullPath); | 266 entry.fullPath); |
266 } else { | 267 } else { |
267 this.setDropTarget_(null); | 268 this.setDropTarget_(null); |
268 } | 269 } |
269 }, | 270 }, |
270 | 271 |
271 onDragEnterBreadcrumbs_: function(breadcrumbs, event) { | 272 onDragEnterBreadcrumbs_: function(breadcrumbsContainer, event) { |
272 if (!event.target.classList.contains('breadcrumb-path')) | 273 var path = breadcrumbsContainer.getTargetPath(event); |
| 274 if (!path) |
273 return; | 275 return; |
| 276 |
274 this.dragEnterCount_++; | 277 this.dragEnterCount_++; |
275 | |
276 var items = breadcrumbs.querySelectorAll('.breadcrumb-path'); | |
277 var path = this.directoryModel_.getCurrentRootPath(); | |
278 | |
279 if (event.target != items[0]) { | |
280 for (var i = 1; items[i - 1] != event.target; i++) { | |
281 path += '/' + items[i].textContent; | |
282 } | |
283 } | |
284 | |
285 this.setDropTarget_(event.target, true, event.dataTransfer, path); | 278 this.setDropTarget_(event.target, true, event.dataTransfer, path); |
286 }, | 279 }, |
287 | 280 |
288 onDragLeave_: function(list, event) { | 281 onDragLeave_: function(list, event) { |
289 if (this.dragEnterCount_-- == 0) | 282 if (this.dragEnterCount_-- == 0) |
290 this.setDropTarget_(null); | 283 this.setDropTarget_(null); |
291 if (event.target == list) | 284 if (event.target == list) |
292 this.setScrollSpeed_(list, 0); | 285 this.setScrollSpeed_(list, 0); |
293 }, | 286 }, |
294 | 287 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 this.scrollStep_ = speed * SCROLL_INTERVAL / 1000; | 599 this.scrollStep_ = speed * SCROLL_INTERVAL / 1000; |
607 this.scrollList_ = list; | 600 this.scrollList_ = list; |
608 }, | 601 }, |
609 | 602 |
610 scroll_: function() { | 603 scroll_: function() { |
611 if (this.scrollList_) | 604 if (this.scrollList_) |
612 this.scrollList_.scrollTop += this.scrollStep_; | 605 this.scrollList_.scrollTop += this.scrollStep_; |
613 } | 606 } |
614 }; | 607 }; |
615 | 608 |
OLD | NEW |