Set 'copy' cursor feedback on cross-library collection drag

This commit is contained in:
Dan Stillman 2017-03-04 04:17:51 -05:00
parent 704e8ffeea
commit d0d7aec4b0
2 changed files with 27 additions and 1 deletions

View file

@ -2519,7 +2519,7 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) {
var itemIDs = this.getSelectedItems(true); var itemIDs = this.getSelectedItems(true);
event.dataTransfer.setData("zotero/item", itemIDs); event.dataTransfer.setData("zotero/item", itemIDs);
// dataTransfer.mozSourceNode doesn't seem to be properly set anymore (tested in 50), so store // dataTransfer.mozSourceNode doesn't seem to be properly set anymore (tested in 50), so store
// target separately // event target separately
if (!event.dataTransfer.mozSourceNode) { if (!event.dataTransfer.mozSourceNode) {
Zotero.debug("mozSourceNode not set -- storing source node"); Zotero.debug("mozSourceNode not set -- storing source node");
Zotero.DragDrop.currentSourceNode = event.target; Zotero.DragDrop.currentSourceNode = event.target;

View file

@ -357,6 +357,32 @@ Zotero.LibraryTreeView.prototype = {
this._setDropEffect(event, "copy"); 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")) { else if (event.dataTransfer.types.contains("application/x-moz-file")) {
// As of Aug. 2013 nightlies: // As of Aug. 2013 nightlies:
// //