Allow moving (instead of copying) files into Zotero
Cmd-drag on OS X, Shift on Windows and Linux As requested in https://forums.zotero.org/discussion/31717/delete-source-file-on-import/ Unfortunately due to https://bugzilla.mozilla.org/show_bug.cgi?id=911918 (and another issue on Windows) we can't show proper cursor feedback for external file drags.
This commit is contained in:
parent
4d4d074ad9
commit
82769f0b9c
|
@ -1729,10 +1729,16 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient)
|
|||
var itemID = Zotero.Attachments.linkFromFile(file);
|
||||
}
|
||||
else {
|
||||
if (dragData.dropEffect != 'copy') {
|
||||
Components.utils.reportError("Invalid dropEffect '" + dragData.dropEffect + "' dropping file");
|
||||
}
|
||||
var itemID = Zotero.Attachments.importFromFile(file, false, targetLibraryID);
|
||||
// If moving, delete original file
|
||||
if (dragData.dropEffect == 'move') {
|
||||
try {
|
||||
file.remove(false);
|
||||
}
|
||||
catch (e) {
|
||||
Components.utils.reportError("Error deleting original file " + file.path + " after drag");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parentCollectionID) {
|
||||
|
@ -1802,7 +1808,36 @@ Zotero.CollectionTreeView.prototype.onDragOver = function (event) {
|
|||
* Called by HTML 5 Drag and Drop when dropping onto the tree
|
||||
*/
|
||||
Zotero.CollectionTreeView.prototype.onDrop = function (event) {
|
||||
Zotero.DragDrop.currentDataTransfer = event.dataTransfer;
|
||||
if (event.dataTransfer.types.contains("application/x-moz-file")) {
|
||||
Zotero.DragDrop.currentDataTransfer = event.dataTransfer;
|
||||
Zotero.safeDebug(event);
|
||||
if (Zotero.isMac) {
|
||||
if (event.metaKey) {
|
||||
if (event.altKey) {
|
||||
event.dataTransfer.dropEffect = 'link';
|
||||
}
|
||||
else {
|
||||
event.dataTransfer.dropEffect = 'move';
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.dataTransfer.dropEffect = 'copy';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (event.shiftKey) {
|
||||
if (event.ctrlKey) {
|
||||
event.dataTransfer.dropEffect = "link";
|
||||
}
|
||||
else {
|
||||
event.dataTransfer.dropEffect = "move";
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.dataTransfer.dropEffect = "copy";
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -3015,10 +3015,16 @@ Zotero.ItemTreeView.prototype.drop = function(row, orient)
|
|||
var itemID = Zotero.Attachments.linkFromFile(file, sourceItemID);
|
||||
}
|
||||
else {
|
||||
if (dragData.dropEffect != 'copy') {
|
||||
Components.utils.reportError("Invalid dropEffect '" + dragData.dropEffect + "' dropping file");
|
||||
}
|
||||
var itemID = Zotero.Attachments.importFromFile(file, sourceItemID, targetLibraryID);
|
||||
// If moving, delete original file
|
||||
if (dragData.dropEffect == 'move') {
|
||||
try {
|
||||
file.remove(false);
|
||||
}
|
||||
catch (e) {
|
||||
Components.utils.reportError("Error deleting original file " + file.path + " after drag");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parentCollectionID) {
|
||||
var col = Zotero.Collections.get(parentCollectionID);
|
||||
|
@ -3077,10 +3083,40 @@ Zotero.ItemTreeView.prototype.onDragOver = function (event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by HTML 5 Drag and Drop when dropping onto the tree
|
||||
*/
|
||||
Zotero.ItemTreeView.prototype.onDrop = function (event) {
|
||||
if (event.dataTransfer.types.contains("application/x-moz-file")) {
|
||||
Zotero.DragDrop.currentDataTransfer = event.dataTransfer;
|
||||
if (Zotero.isMac) {
|
||||
if (event.metaKey) {
|
||||
if (event.altKey) {
|
||||
event.dataTransfer.dropEffect = 'link';
|
||||
}
|
||||
else {
|
||||
event.dataTransfer.dropEffect = 'move';
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.dataTransfer.dropEffect = 'copy';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (event.shiftKey) {
|
||||
if (event.ctrlKey) {
|
||||
event.dataTransfer.dropEffect = "link";
|
||||
}
|
||||
else {
|
||||
event.dataTransfer.dropEffect = "move";
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.dataTransfer.dropEffect = "copy";
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@
|
|||
ondragstart="if (event.target.localName == 'treechildren') { ZoteroPane_Local.itemsView.onDragStart(event); }"
|
||||
ondragenter="return ZoteroPane_Local.itemsView.onDragEnter(event)"
|
||||
ondragover="return ZoteroPane_Local.itemsView.onDragOver(event)"
|
||||
ondragdrop="return ZoteroPane_Local.itemsView.onDrop(event)"
|
||||
ondrop="return ZoteroPane_Local.itemsView.onDrop(event)"
|
||||
oncommand="ZoteroPane_Local.serializePersist()"
|
||||
flex="1">
|
||||
<treecols id="zotero-items-columns-header">
|
||||
|
|
Loading…
Reference in New Issue
Block a user