Add drag and drop for attachments

Files can be dragged and dropped on the bottom in order to be added as
attachments.

Resolves: #260
This commit is contained in:
OdysseasKr 2015-12-04 00:27:29 +02:00 committed by lilia
parent 4e416c6cbf
commit cbbb8dfa24

View file

@ -22,7 +22,10 @@
events: {
'change': 'previewImages',
'click .close': 'deleteFiles',
'click .choose-file': 'open'
'click .choose-file': 'open',
'drop': 'openDropped',
'dragover': 'showArea',
'dragleave': 'hideArea'
},
open: function() {
@ -228,6 +231,26 @@
this.$input.wrap('<form>').parent('form').trigger('reset');
this.$input.unwrap();
this.file = null;
},
openDropped: function(e) {
e.stopPropagation();
e.preventDefault();
this.file = e.originalEvent.dataTransfer.files[0];
this.previewImages();
this.$el.removeClass("dropoff");
},
showArea: function(e) {
e.stopPropagation();
e.preventDefault();
this.$el.addClass("dropoff");
},
hideArea: function(e) {
e.stopPropagation();
e.preventDefault();
this.$el.removeClass("dropoff");
}
});
})();