Improved the code readability
authorAlexander Ebert <ebert@woltlab.com>
Thu, 5 Nov 2020 10:41:09 +0000 (11:41 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 5 Nov 2020 10:41:09 +0000 (11:41 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Link.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.ts
wcfsetup/install/files/ts/WoltLabSuite/Core/Ui/Redactor/Link.ts

index f20bb51347cdaefe955cb7ab01b8938058d464cd..8d851abdf31f30c7856a5c80bbf4393a842ace44 100644 (file)
@@ -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
index c4c27f004b40e0f5a4569c469194ad5ee7012480..07c6248a86476a38f55f7e6acaa90ea274e19f52 100644 (file)
@@ -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() {
index a78eaf8e90056fa3ec42469233da8ef9f8fe3ef2..9fc5e8b5388de7298361dc579ed60f589d65a3e5 100644 (file)
@@ -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) {
index 97c373467439a6b397d3a4e7c9aafdd6c4bf97d3..3ca2631b12ab33f96fc3aed53f93903603bd3ba3 100644 (file)
@@ -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());
     }
   }