diff --git a/NEWS.md b/NEWS.md index d6e49bb87afe..bb0a50ae728f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/vendor/assets/javascripts/dragster.js b/vendor/assets/javascripts/dragster.js index 4010bd1ffc12..b71d017df377 100644 --- a/vendor/assets/javascripts/dragster.js +++ b/vendor/assets/javascripts/dragster.js @@ -1,19 +1,17 @@ (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) { @@ -21,13 +19,12 @@ 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); } }; @@ -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); } }; @@ -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;