if (!event.dataTransfer || !event.dataTransfer.types) {
return;
}
- let isFirefox = false;
- Object.keys(event.dataTransfer).forEach((property) => {
- if (property.startsWith("moz")) {
- isFirefox = true;
- }
- });
+ const isFirefox = Object.keys(event.dataTransfer).some((property) => property.startsWith("moz"));
// IE and WebKit set 'Files', Firefox sets 'application/x-moz-file' for files being dragged
// and Safari just provides 'Files' along with a huge list of garbage
_isFile = false;
}
}
else {
- event.dataTransfer.types.forEach((type) => {
- if (type === "Files") {
- _isFile = true;
- }
- });
+ _isFile = event.dataTransfer.types.some((type) => type === "Files");
}
if (!_isFile) {
// user is just dragging around some garbage, ignore it
// Redactor might modify the button, thus we cannot bind it in the dialog's `onSetup()` callback.
if (!this.boundListener) {
this.boundListener = true;
- submitButton.addEventListener("click", this.submit.bind(this));
+ submitButton.addEventListener("click", () => this.submit());
}
}
submit() {
return;
}
- let isFirefox = false;
- Object.keys(event.dataTransfer).forEach((property) => {
- if (property.startsWith("moz")) {
- isFirefox = true;
- }
- });
+ const isFirefox = Object.keys(event.dataTransfer).some((property) => property.startsWith("moz"));
// IE and WebKit set 'Files', Firefox sets 'application/x-moz-file' for files being dragged
// and Safari just provides 'Files' along with a huge list of garbage
_isFile = true;
}
} else {
- event.dataTransfer.types.forEach((type) => {
- if (type === "Files") {
- _isFile = true;
- }
- });
+ _isFile = event.dataTransfer.types.some((type) => type === "Files");
}
if (!_isFile) {
if (!this.boundListener) {
this.boundListener = true;
- submitButton.addEventListener("click", this.submit.bind(this));
+ submitButton.addEventListener("click", () => this.submit());
}
}