snapdrop/app/elements/file-sharing/file-drop-behavior.html
2015-12-23 13:57:13 +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();
//call 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>