| Index: chrome/browser/resources/md_bookmarks/dnd_manager.js
|
| diff --git a/chrome/browser/resources/md_bookmarks/dnd_manager.js b/chrome/browser/resources/md_bookmarks/dnd_manager.js
|
| index 5304a097925c4814a01d081614ccf30334d34101..6d2c9b66475af7ec83276c30240b9550b0bcc55e 100644
|
| --- a/chrome/browser/resources/md_bookmarks/dnd_manager.js
|
| +++ b/chrome/browser/resources/md_bookmarks/dnd_manager.js
|
| @@ -283,13 +283,49 @@ cr.define('bookmarks', function() {
|
| * @param {!Event} e
|
| */
|
| onDrop_: function(e) {
|
| - if (this.dropDestination_)
|
| + if (this.dropDestination_) {
|
| e.preventDefault();
|
|
|
| + var dropInfo = this.calculateDropInfo_(this.dropDestination_);
|
| + if (dropInfo.index != -1)
|
| + chrome.bookmarkManagerPrivate.drop(dropInfo.parentId, dropInfo.index);
|
| + else
|
| + chrome.bookmarkManagerPrivate.drop(dropInfo.parentId);
|
| + }
|
| +
|
| this.dropDestination_ = null;
|
| this.dropIndicator_.finish();
|
| },
|
|
|
| + /**
|
| + * @param {DropDestination} dropDestination
|
| + * @return {{parentId: string, index: number}}
|
| + */
|
| + calculateDropInfo_: function(dropDestination) {
|
| + var node = getBookmarkNode(dropDestination.element);
|
| + var position = dropDestination.position;
|
| + var index = -1;
|
| + var parentId = node.id;
|
| +
|
| + if (position != DropPosition.ON) {
|
| + var state = bookmarks.Store.getInstance().data;
|
| +
|
| + // Drops between items in the normal list and the sidebar use the drop
|
| + // destination node's parent.
|
| + parentId = assert(node.parentId);
|
| + index = state.nodes[parentId].children.indexOf(node.id);
|
| +
|
| + // TODO(calamity): Handle dropping to an empty bookmark list.
|
| + if (position == DropPosition.BELOW)
|
| + index++;
|
| + }
|
| +
|
| + return {
|
| + index: index,
|
| + parentId: parentId,
|
| + };
|
| + },
|
| +
|
| /** @private */
|
| clearDragData_: function() {
|
| this.dragInfo_.clearDragData();
|
|
|