Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Drag&Drop in Internet Explorer 11 #13548

Merged
merged 5 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,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))
* Add titles (and description) to embeds in mobile viewports (#13517)
* User feed renders google maps properly when user has it enabled
* Prevent destroying modals with `keepOpenOnRouteChange` property enabled on Builder when route changes. ([Support#1293](https://github.com/CartoDB/support/issues/1293))
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