PairDrop/app/elements/file-sharing/file-drop-behavior.html
Robin Linus 1626875ba8 Cleanup
2016-01-03 03:08:17 +01:00

48 lines
1.4 KiB
HTML

<link rel="import" href="file-selection-behavior.html">
<script>
'use strict';
window.Chat = window.Chat || {};
Chat.FileDropBehaviorImpl = {
attached: function() {
var dropZone = this;
dropZone.addEventListener('dragover', function(e) {
e.stopPropagation();
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
dropZone.style.transform = 'scale(1.2)';
}, false);
var dragEnd = function() {
dropZone.style.transform = 'scale(1)';
};
dropZone.addEventListener('dragleave', dragEnd, false);
dropZone.addEventListener('dragexit', dragEnd, false);
dropZone.addEventListener('dragend', dragEnd, false);
// Get file data on drop
dropZone.addEventListener('drop', function(event) {
event.stopPropagation();
event.preventDefault();
//drop is a dragend
dragEnd();
// Get files
var files = event.dataTransfer.files;
// Notify Selection
this.notifyFilesSelection(files);
});
}
};
document.body.addEventListener('dragover', function(e) {
e.stopPropagation();
e.preventDefault();
}, false);
document.body.addEventListener('drop', function(event) {
event.stopPropagation();
event.preventDefault();
});
Chat.FileDropBehavior = [Chat.FileDropBehaviorImpl, Chat.FileSelectionBehavior];
</script>