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';
|
2016-06-23 19:03:49 +02:00
|
|
|
window.Snapdrop = window.Snapdrop || {};
|
|
|
|
Snapdrop.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
|
|
|
|
2016-01-03 03:08:17 +01:00
|
|
|
//drop is a dragend
|
2015-12-19 01:18:02 +01:00
|
|
|
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();
|
|
|
|
});
|
2016-06-23 19:03:49 +02:00
|
|
|
Snapdrop.FileDropBehavior = [Snapdrop.FileDropBehaviorImpl, Snapdrop.FileSelectionBehavior];
|
2015-12-18 17:43:46 +01:00
|
|
|
</script>
|