Skip to content

Commit

Permalink
Merge pull request #13548 from CartoDB/876-ie11-drag&drop
Browse files Browse the repository at this point in the history
Fix Drag&Drop in Internet Explorer 11
  • Loading branch information
jesusbotella authored Feb 15, 2018
2 parents 147e879 + fd92ddf commit e3d918b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ ion for time-series (#12670)
* Use carto.js v4.0.0-beta.13

### Bug fixes / enhancements
* Fix IE11 Drag&Drop ([Support#876](https://github.com/CartoDB/support/issues/876))
* Removed references to analytics JS files in static pages (#13543)
* Add titles (and description) to embeds in mobile viewports (#13517)
* User feed renders google maps properly when user has it enabled
Expand Down
47 changes: 17 additions & 30 deletions vendor/assets/javascripts/dragster.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@

(function() {
var Dragster,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

Dragster = (function() {
function Dragster(el) {
this.el = el;
this.dragleave = __bind(this.dragleave, this);
this.dragenter = __bind(this.dragenter, this);
if (this.supportsEventConstructors()) {
this.first = false;
this.second = false;
this.el.addEventListener("dragenter", this.dragenter, false);
this.el.addEventListener("dragleave", this.dragleave, false);
}
this.first = false;
this.second = false;
this.el.addEventListener("dragenter", this.dragenter, false);
this.el.addEventListener("dragleave", this.dragleave, false);
}

Dragster.prototype.dragenter = function(event) {
if (this.first) {
return this.second = true;
} else {
this.first = true;
return this.el.dispatchEvent(new CustomEvent("dragster:enter", {
bubbles: true,
cancelable: true,
detail: {
dataTransfer: event.dataTransfer
}
}));
this.customEvent = document.createEvent("CustomEvent");
this.customEvent.initCustomEvent("dragster:enter", true, true, {
dataTransfer: event.dataTransfer,
sourceEvent: event
});
return this.el.dispatchEvent(this.customEvent);
}
};

Expand All @@ -38,13 +35,12 @@
this.first = false;
}
if (!this.first && !this.second) {
return this.el.dispatchEvent(new CustomEvent("dragster:leave", {
bubbles: true,
cancelable: true,
detail: {
dataTransfer: event.dataTransfer
}
}));
this.customEvent = document.createEvent("CustomEvent");
this.customEvent.initCustomEvent("dragster:leave", true, true, {
dataTransfer: event.dataTransfer,
sourceEvent: event
});
return this.el.dispatchEvent(this.customEvent);
}
};

Expand All @@ -53,15 +49,6 @@
return this.el.removeEventListener("dragleave", this.dragleave, false);
};

Dragster.prototype.supportsEventConstructors = function() {
try {
new CustomEvent("z");
} catch (_error) {
return false;
}
return true;
};

Dragster.prototype.reset = function() {
this.first = false;
return this.second = false;
Expand Down

0 comments on commit e3d918b

Please sign in to comment.