From: Alexander Ebert Date: Thu, 5 Nov 2020 10:41:09 +0000 (+0100) Subject: Improved the code readability X-Git-Tag: 5.4.0_Alpha_1~636^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c14ac6ab258c64ecb4fd1212eebbfd348cf47743;p=GitHub%2FWoltLab%2FWCF.git Improved the code readability --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.js index f20bb51347..8d851abdf3 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.js @@ -25,12 +25,7 @@ define(["require", "exports", "tslib", "../../Event/Handler", "../../Language"], 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; @@ -41,11 +36,7 @@ define(["require", "exports", "tslib", "../../Event/Handler", "../../Language"], } } 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 diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Link.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Link.js index c4c27f004b..07c6248a86 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Link.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Link.js @@ -18,7 +18,7 @@ define(["require", "exports", "tslib", "../../Dom/Util", "../../Language", "../D // 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() { diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.ts index a78eaf8e90..9fc5e8b538 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.ts @@ -34,12 +34,7 @@ function _dragOver(event: DragEvent): void { 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 @@ -50,11 +45,7 @@ function _dragOver(event: DragEvent): void { _isFile = true; } } else { - event.dataTransfer.types.forEach((type) => { - if (type === "Files") { - _isFile = true; - } - }); + _isFile = event.dataTransfer.types.some((type) => type === "Files"); } if (!_isFile) { diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/Link.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/Link.ts index 97c3734674..3ca2631b12 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/Link.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/Link.ts @@ -28,7 +28,7 @@ class UiRedactorLink implements DialogCallbackObject { if (!this.boundListener) { this.boundListener = true; - submitButton.addEventListener("click", this.submit.bind(this)); + submitButton.addEventListener("click", () => this.submit()); } }