commit 315d9ecbcb7076476d8e747e24abe267d3b2676c parent ae7f2d8e86aca625deca4ddbaddce394f525391e Author: Dan Stillman <dstillman@zotero.org> Date: Sat, 25 Feb 2012 18:26:59 -0500 Don't allow child items to be dragged within their own parents This caused child notes and PDFs to be moved out of their parents with the slightest drag. Diffstat:
| M | chrome/content/zotero/xpcom/itemTreeView.js | | | 28 | ++++++++++++++++++++++++++++ |
1 file changed, 28 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js @@ -2387,6 +2387,34 @@ Zotero.ItemTreeView.prototype.canDrop = function(row, orient, dragData) return false; } + // Don't allow children to be dragged within their own parents + var parentItemID = item.getSource(); + var parentIndex = this._itemRowMap[parentItemID]; + if (this.getLevel(row) > 0) { + if (this._getItemAtRow(this.getParentIndex(row)).ref.id == parentItemID) { + return false; + } + } + // Including immediately after the parent + if (orient == 1) { + if (row == parentIndex) { + return false; + } + } + // And immediately before the next parent + if (orient == -1) { + var nextParentIndex = null; + for (var i = parentIndex + 1; i < this.rowCount; i++) { + if (this.getLevel(i) == 0) { + nextParentIndex = i; + break; + } + } + if (row === nextParentIndex) { + return false; + } + } + // Disallow cross-library child drag if (item.libraryID != itemGroup.ref.libraryID) { return false;