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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 /** | 474 /** |
491 * @private | 475 * @private |
492 * @param {BookmarkElement} overElement | 476 * @param {BookmarkElement} overElement |
493 * @return {DropPosition} | 477 * @return {DropPosition} |
494 */ | 478 */ |
495 calculateDropAboveBelow_: function(overElement) { | 479 calculateDropAboveBelow_: function(overElement) { |
496 var dragInfo = this.dragInfo_; | 480 var dragInfo = this.dragInfo_; |
497 var state = bookmarks.Store.getInstance().data; | 481 var state = bookmarks.Store.getInstance().data; |
498 | 482 |
499 // We cannot drop between Bookmarks bar and Other bookmarks. | 483 // We cannot drop between Bookmarks bar and Other bookmarks. |
500 if (getBookmarkNode(overElement).parentId == bookmarks.util.ROOT_NODE_ID) | 484 if (getBookmarkNode(overElement).parentId == ROOT_NODE_ID) |
501 return DropPosition.NONE; | 485 return DropPosition.NONE; |
502 | 486 |
503 var isOverFolderNode = isBookmarkFolderNode(overElement); | 487 var isOverFolderNode = isBookmarkFolderNode(overElement); |
504 | 488 |
505 // We can only drop between items in the tree if we have any folders. | 489 // We can only drop between items in the tree if we have any folders. |
506 if (isOverFolderNode && !dragInfo.isDraggingFolders()) | 490 if (isOverFolderNode && !dragInfo.isDraggingFolders()) |
507 return DropPosition.NONE; | 491 return DropPosition.NONE; |
508 | 492 |
509 var validDropPositions = DropPosition.NONE; | 493 var validDropPositions = DropPosition.NONE; |
510 | 494 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 return !this.dragInfo_.isDraggingChildBookmark(overElement.itemId) | 533 return !this.dragInfo_.isDraggingChildBookmark(overElement.itemId) |
550 }, | 534 }, |
551 }; | 535 }; |
552 | 536 |
553 return { | 537 return { |
554 DNDManager: DNDManager, | 538 DNDManager: DNDManager, |
555 DragInfo: DragInfo, | 539 DragInfo: DragInfo, |
556 DropIndicator: DropIndicator, | 540 DropIndicator: DropIndicator, |
557 }; | 541 }; |
558 }); | 542 }); |
OLD | NEW |