2015-12-19 01:18:02 +01:00
|
|
|
<link rel="import" href="file-selection-behavior.html">
|
2015-12-18 17:43:46 +01:00
|
|
|
<script>
|
|
|
|
'use strict';
|
2015-12-19 01:18:02 +01:00
|
|
|
window.Chat = window.Chat || {};
|
|
|
|
Chat.FileDropBehaviorImpl = {
|
2015-12-18 17:43:46 +01:00
|
|
|
attached: function() {
|
|
|
|
var dropZone = this;
|
|
|
|
|
|
|
|
dropZone.addEventListener('dragover', function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
e.dataTransfer.dropEffect = 'copy';
|
2015-12-19 01:18:02 +01:00
|
|
|
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);
|
2015-12-18 17:43:46 +01:00
|
|
|
|
|
|
|
// Get file data on drop
|
2015-12-19 01:18:02 +01:00
|
|
|
dropZone.addEventListener('drop', function(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
event.preventDefault();
|
2015-12-23 13:57:13 +01:00
|
|
|
|
2015-12-19 01:18:02 +01:00
|
|
|
//call dragend
|
|
|
|
dragEnd();
|
|
|
|
|
|
|
|
// Get files
|
|
|
|
var files = event.dataTransfer.files;
|
|
|
|
// Notify Selection
|
|
|
|
this.notifyFilesSelection(files);
|
2015-12-18 17:43:46 +01:00
|
|
|
});
|
|
|
|
}
|
2015-12-19 01:18:02 +01:00
|
|
|
};
|
2015-12-23 13:57:13 +01:00
|
|
|
document.body.addEventListener('dragover', function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
}, false);
|
|
|
|
document.body.addEventListener('drop', function(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
2015-12-19 01:18:02 +01:00
|
|
|
Chat.FileDropBehavior = [Chat.FileDropBehaviorImpl, Chat.FileSelectionBehavior];
|
2015-12-18 17:43:46 +01:00
|
|
|
</script>
|