Fix: drag and drop

This commit is contained in:
Thaum Rystra
2020-04-25 11:17:42 +02:00
parent 8b30c7b6d0
commit 3ab73f62bf
2 changed files with 27 additions and 27 deletions

View File

@@ -258,7 +258,7 @@ Template.inventoryItem.helpers({
},
});
Template.layout.events({
Template.inventory.events({
"dragstart .inventoryItem": function(event, instance){
event.originalEvent.dataTransfer.setData("dicecloud-id/items", this._id);
Session.set("inventory.dragItemId", this._id);
@@ -281,12 +281,6 @@ Template.layout.events({
event.preventDefault();
}
},
"dragover .characterRepresentative, dragenter .characterRepresentative":
function(event, instance){
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
event.preventDefault();
}
},
"dragend .inventoryItem": function(event, instance){
Session.set("inventory.dragItemId", null);
},
@@ -330,24 +324,4 @@ Template.layout.events({
}
Session.set("inventory.dragItemId", null);
},
"drop .characterRepresentative": function(event, instance) {
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
var itemId = event.originalEvent.dataTransfer.getData("dicecloud-id/items");
if (event.ctrlKey){
//split the stack to the container
pushDialogStack({
template: "splitStackDialog",
data: {
id: itemId,
parentCollection: "Characters",
parentId: this._id,
},
});
} else {
//move item to the character
Meteor.call("moveItemToCharacter", itemId, this._id);
}
Session.set("inventory.dragItemId", null);
}
},
});

View File

@@ -48,4 +48,30 @@ Template.characterSideList.events({
}
instance.openedParties.set(openedParties);
},
"dragover .characterRepresentative, dragenter .characterRepresentative":
function(event, instance){
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
event.preventDefault();
}
},
"drop .characterRepresentative": function(event, instance) {
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
var itemId = event.originalEvent.dataTransfer.getData("dicecloud-id/items");
if (event.ctrlKey){
//split the stack to the container
pushDialogStack({
template: "splitStackDialog",
data: {
id: itemId,
parentCollection: "Characters",
parentId: this._id,
},
});
} else {
//move item to the character
Meteor.call("moveItemToCharacter", itemId, this._id);
}
Session.set("inventory.dragItemId", null);
}
},
});