Skip to content

Commit

Permalink
Drag/drop compose handler now recognizes whether drag data is text or…
Browse files Browse the repository at this point in the history
… a file

Works on FF, Chrome, and IE 10/11 (at least).
Will hide the attachment drop box if drag data is text.
  • Loading branch information
slusarz committed Jul 11, 2014
1 parent dbe3865 commit 7f6009f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions imp/js/draghandler.js
Expand Up @@ -18,23 +18,23 @@ var DragHandler = {
isFileDrag: function(e)
{
return (e.dataTransfer &&
e.dataTransfer.files &&
e.dataTransfer.files.length);
e.dataTransfer.types &&
$A(e.dataTransfer.types).include('Files'));
},

handleObserve: function(e)
{
if (this.dropelt &&
(e.dataTransfer ||
this.dropelt.visible() ||
(e.memo && e.memo.dataTransfer))) {
(e.memo && e.memo.dataTransfer) ||
this.dropelt.visible())) {
if (Prototype.Browser.IE &&
!(("onpropertychange" in document) && (!!window.matchMedia))) {
// IE 9 supports drag/drop, but not dataTransfer.files
} else {
switch (e.type) {
case 'dragleave':
this.handleLeave(e);
this.handleLeave();
break;

case 'dragover':
Expand Down Expand Up @@ -70,7 +70,7 @@ var DragHandler = {
}
},

handleLeave: function(e)
handleLeave: function()
{
clearTimeout(this.to);
this.to = this.hide.bind(this).delay(0.25);
Expand All @@ -79,14 +79,16 @@ var DragHandler = {

handleOver: function(e)
{
if (!this.dropelt.visible()) {
var file = this.isFileDrag(e);

if (file && !this.dropelt.visible()) {
this.dropelt.clonePosition(this.droptarget).show();
this.droptarget.hide();
}

this.leave = false;

if (e.target == this.dropelt) {
if (file && (e.target == this.dropelt)) {
this.dropelt.addClassName(this.hoverclass);
e.stop();
} else {
Expand Down

0 comments on commit 7f6009f

Please sign in to comment.