commit d0d7aec4b0306cf846e5fcf59ed9373a1864a2e3
parent 704e8ffeea7555499fe7a09d4edd84bf86e54fd9
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 4 Mar 2017 04:17:51 -0500
Set 'copy' cursor feedback on cross-library collection drag
Diffstat:
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -2519,7 +2519,7 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) {
var itemIDs = this.getSelectedItems(true);
event.dataTransfer.setData("zotero/item", itemIDs);
// dataTransfer.mozSourceNode doesn't seem to be properly set anymore (tested in 50), so store
- // target separately
+ // event target separately
if (!event.dataTransfer.mozSourceNode) {
Zotero.debug("mozSourceNode not set -- storing source node");
Zotero.DragDrop.currentSourceNode = event.target;
diff --git a/chrome/content/zotero/xpcom/libraryTreeView.js b/chrome/content/zotero/xpcom/libraryTreeView.js
@@ -357,6 +357,32 @@ Zotero.LibraryTreeView.prototype = {
this._setDropEffect(event, "copy");
}
}
+ else if (event.dataTransfer.getData("zotero/collection")) {
+ let collectionID = Zotero.DragDrop.getDataFromDataTransfer(event.dataTransfer).data[0];
+ let { libraryID: sourceLibraryID } = Zotero.Collections.getLibraryAndKeyFromID(collectionID);
+
+ if (this.type == 'collection') {
+ var targetCollectionTreeRow = Zotero.DragDrop.getDragTarget(event);
+ }
+ else {
+ throw new Error("Invalid type '" + this.type + "'");
+ }
+
+ // For now, all cross-library drags are copies
+ if (sourceLibraryID != targetCollectionTreeRow.ref.libraryID) {
+ /*if ((Zotero.isMac && event.metaKey) || (!Zotero.isMac && event.shiftKey)) {
+ this._setDropEffect(event, "move");
+ }
+ else {
+ this._setDropEffect(event, "copy");
+ }*/
+ this._setDropEffect(event, "copy");
+ return false;
+ }
+
+ // And everything else is a move
+ this._setDropEffect(event, "move");
+ }
else if (event.dataTransfer.types.contains("application/x-moz-file")) {
// As of Aug. 2013 nightlies:
//