Convert `Form/Builder/Field/Captcha` to TypeScript
authorMatthias Schmidt <gravatronics@live.com>
Wed, 9 Dec 2020 16:33:21 +0000 (17:33 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 15 Dec 2020 17:23:04 +0000 (18:23 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Captcha.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.js [deleted file]
wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.ts [new file with mode: 0644]

index 98c7e0b89f4ceed699778e786a9d65130ffa495e..fb346e7fdf8da0c28812ec7b9fba4d2a23a1928a 100644 (file)
@@ -1,45 +1,33 @@
 /**
  * Data handler for a captcha form builder field in an Ajax form.
  *
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module     WoltLabSuite/Core/Form/Builder/Field/Captcha
- * @since      5.2
+ * @author  Matthias Schmidt
+ * @copyright  2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module  WoltLabSuite/Core/Form/Builder/Field/Captcha
+ * @since 5.2
  */
-define(['Core', './Field', 'WoltLabSuite/Core/Controller/Captcha'], function (Core, FormBuilderField, Captcha) {
+define(["require", "exports", "tslib", "./Field", "../../../Controller/Captcha", "../../../Core"], function (require, exports, tslib_1, Field_1, Captcha_1, Core) {
     "use strict";
-    /**
-     * @constructor
-     */
-    function FormBuilderFieldCaptcha(fieldId) {
-        this.init(fieldId);
-    }
-    ;
-    Core.inherit(FormBuilderFieldCaptcha, FormBuilderField, {
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Field#getData
-         */
-        _getData: function () {
-            if (Captcha.has(this._fieldId)) {
-                return Captcha.getData(this._fieldId);
+    Field_1 = tslib_1.__importDefault(Field_1);
+    Captcha_1 = tslib_1.__importDefault(Captcha_1);
+    Core = tslib_1.__importStar(Core);
+    class Captcha extends Field_1.default {
+        _getData() {
+            if (Captcha_1.default.has(this._fieldId)) {
+                return Captcha_1.default.getData(this._fieldId);
             }
             return {};
-        },
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Field#_readField
-         */
-        _readField: function () {
+        }
+        _readField() {
             // does nothing
-        },
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Field#destroy
-         */
-        destroy: function () {
-            if (Captcha.has(this._fieldId)) {
-                Captcha.delete(this._fieldId);
+        }
+        destroy() {
+            if (Captcha_1.default.has(this._fieldId)) {
+                Captcha_1.default.delete(this._fieldId);
             }
         }
-    });
-    return FormBuilderFieldCaptcha;
+    }
+    Core.enableLegacyInheritance(Captcha);
+    return Captcha;
 });
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.js
deleted file mode 100644 (file)
index 4419c64..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Data handler for a captcha form builder field in an Ajax form.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module     WoltLabSuite/Core/Form/Builder/Field/Captcha
- * @since      5.2
- */
-define(['Core', './Field', 'WoltLabSuite/Core/Controller/Captcha'], function(Core, FormBuilderField, Captcha) {
-       "use strict";
-       
-       /**
-        * @constructor
-        */
-       function FormBuilderFieldCaptcha(fieldId) {
-               this.init(fieldId);
-       };
-       Core.inherit(FormBuilderFieldCaptcha, FormBuilderField, {
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Field#getData
-                */
-               _getData: function() {
-                       if (Captcha.has(this._fieldId)) {
-                               return Captcha.getData(this._fieldId);
-                       }
-                       
-                       return {};
-               },
-               
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Field#_readField
-                */
-               _readField: function() {
-                       // does nothing
-               },
-               
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Field#destroy
-                */
-               destroy: function() {
-                       if (Captcha.has(this._fieldId)) {
-                               Captcha.delete(this._fieldId);
-                       }
-               }
-       });
-       
-       return FormBuilderFieldCaptcha;
-});
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.ts
new file mode 100644 (file)
index 0000000..74e9c8d
--- /dev/null
@@ -0,0 +1,38 @@
+/**
+ * Data handler for a captcha form builder field in an Ajax form.
+ *
+ * @author  Matthias Schmidt
+ * @copyright  2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module  WoltLabSuite/Core/Form/Builder/Field/Captcha
+ * @since 5.2
+ */
+
+import Field from "./Field";
+import ControllerCaptcha from "../../../Controller/Captcha";
+import { FormBuilderData } from "../Data";
+import * as Core from "../../../Core";
+
+class Captcha extends Field {
+  protected _getData(): FormBuilderData {
+    if (ControllerCaptcha.has(this._fieldId)) {
+      return ControllerCaptcha.getData(this._fieldId) as FormBuilderData;
+    }
+
+    return {};
+  }
+
+  protected _readField(): void {
+    // does nothing
+  }
+
+  destroy(): void {
+    if (ControllerCaptcha.has(this._fieldId)) {
+      ControllerCaptcha.delete(this._fieldId);
+    }
+  }
+}
+
+Core.enableLegacyInheritance(Captcha);
+
+export = Captcha;