OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** | |
6 * Enumeration of valid drop locations relative to an element. These are | |
7 * bit masks to allow combining multiple locations in a single value. | |
8 * @enum {number} | |
9 * @const | |
10 */ | |
11 var DropPosition = { | |
12 NONE: 0, | |
13 ABOVE: 1, | |
14 ON: 2, | |
15 BELOW: 4, | |
16 }; | |
17 | |
18 /** @typedef {{element: BookmarkElement, position: DropPosition}} */ | |
19 var DropDestination; | |
20 | |
21 cr.define('bookmarks', function() { | 5 cr.define('bookmarks', function() { |
22 /** | 6 /** |
23 * @param {BookmarkElement} element | 7 * @param {BookmarkElement} element |
24 * @return {boolean} | 8 * @return {boolean} |
25 */ | 9 */ |
26 function isBookmarkItem(element) { | 10 function isBookmarkItem(element) { |
27 return element.tagName == 'BOOKMARKS-ITEM'; | 11 return element.tagName == 'BOOKMARKS-ITEM'; |
28 } | 12 } |
29 | 13 |
30 /** | 14 /** |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 /** | 471 /** |
488 * @private | 472 * @private |
489 * @param {BookmarkElement} overElement | 473 * @param {BookmarkElement} overElement |
490 * @return {DropPosition} | 474 * @return {DropPosition} |
491 */ | 475 */ |
492 calculateDropAboveBelow_: function(overElement) { | 476 calculateDropAboveBelow_: function(overElement) { |
493 var dragInfo = this.dragInfo_; | 477 var dragInfo = this.dragInfo_; |
494 var state = bookmarks.Store.getInstance().data; | 478 var state = bookmarks.Store.getInstance().data; |
495 | 479 |
496 // We cannot drop between Bookmarks bar and Other bookmarks. | 480 // We cannot drop between Bookmarks bar and Other bookmarks. |
497 if (getBookmarkNode(overElement).parentId == bookmarks.util.ROOT_NODE_ID) | 481 if (getBookmarkNode(overElement).parentId == ROOT_NODE_ID) |
498 return DropPosition.NONE; | 482 return DropPosition.NONE; |
499 | 483 |
500 var isOverFolderNode = isBookmarkFolderNode(overElement); | 484 var isOverFolderNode = isBookmarkFolderNode(overElement); |
501 | 485 |
502 // We can only drop between items in the tree if we have any folders. | 486 // We can only drop between items in the tree if we have any folders. |
503 if (isOverFolderNode && !dragInfo.isDraggingFolders()) | 487 if (isOverFolderNode && !dragInfo.isDraggingFolders()) |
504 return DropPosition.NONE; | 488 return DropPosition.NONE; |
505 | 489 |
506 var validDropPositions = DropPosition.NONE; | 490 var validDropPositions = DropPosition.NONE; |
507 | 491 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 return !this.dragInfo_.isDraggingChildBookmark(overElement.itemId) | 530 return !this.dragInfo_.isDraggingChildBookmark(overElement.itemId) |
547 }, | 531 }, |
548 }; | 532 }; |
549 | 533 |
550 return { | 534 return { |
551 DNDManager: DNDManager, | 535 DNDManager: DNDManager, |
552 DragInfo: DragInfo, | 536 DragInfo: DragInfo, |
553 DropIndicator: DropIndicator, | 537 DropIndicator: DropIndicator, |
554 }; | 538 }; |
555 }); | 539 }); |
OLD | NEW |