Fix: drag and drop
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user