Convert `Form/Builder/Field/Dependency/IsNotClicked` to TypeScript
authorMatthias Schmidt <gravatronics@live.com>
Sat, 12 Dec 2020 15:07:29 +0000 (16:07 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 15 Dec 2020 17:23:06 +0000 (18:23 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js [deleted file]
wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.ts [new file with mode: 0644]

index 6d8c273fcecef5e6b35c753b79828e27186ef46f..c13fc9aeacc6022e51063f24f8143d3c161583e1 100644 (file)
@@ -1,33 +1,33 @@
 /**
  * Form field dependency implementation that requires that a button has not been clicked.
  *
- * @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/Dependency/IsNotClicked
- * @see         module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
- * @since       5.4
+ * @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/Dependency/IsNotClicked
+ * @see module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
+ * @since 5.4
  */
-define(['./Abstract', 'Core', './Manager'], function (Abstract, Core, DependencyManager) {
+define(["require", "exports", "tslib", "./Abstract", "./Manager", "../../../../Core"], function (require, exports, tslib_1, Abstract_1, Manager_1, Core) {
     "use strict";
-    /**
-     * @constructor
-     */
-    function IsNotClicked(dependentElementId, fieldId) {
-        this.init(dependentElementId, fieldId);
-        this._field.addEventListener('click', () => {
-            this._field.dataset.isClicked = 1;
-            DependencyManager.checkDependencies();
-        });
-    }
-    ;
-    Core.inherit(IsNotClicked, Abstract, {
-        /**
-         * @see        WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract#checkDependency
-         */
-        checkDependency: function () {
+    Abstract_1 = tslib_1.__importDefault(Abstract_1);
+    Manager_1 = tslib_1.__importDefault(Manager_1);
+    Core = tslib_1.__importStar(Core);
+    class IsNotClicked extends Abstract_1.default {
+        constructor(dependentElementId, fieldId) {
+            super(dependentElementId, fieldId);
+            // To check for clicks after they occured, set `isClicked` in the field's data set and then
+            // explicitly check the dependencies as the dependency manager itself does to listen to click
+            // events.
+            this._field.addEventListener("click", () => {
+                this._field.dataset.isClicked = "1";
+                Manager_1.default.checkDependencies();
+            });
+        }
+        checkDependency() {
             return this._field.dataset.isClicked !== "1";
         }
-    });
+    }
+    Core.enableLegacyInheritance(IsNotClicked);
     return IsNotClicked;
 });
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js
deleted file mode 100644 (file)
index f2b53f3..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Form field dependency implementation that requires that a button has not been clicked.
- * 
- * @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/Dependency/IsNotClicked
- * @see         module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
- * @since       5.4
- */
-define(['./Abstract', 'Core', './Manager'], function(Abstract, Core, DependencyManager) {
-       "use strict";
-       
-       /**
-        * @constructor
-        */
-       function IsNotClicked(dependentElementId, fieldId) {
-               this.init(dependentElementId, fieldId);
-               
-               this._field.addEventListener('click', () => {
-                       this._field.dataset.isClicked = 1;
-                       
-                       DependencyManager.checkDependencies();
-               });
-       };
-       Core.inherit(IsNotClicked, Abstract, {
-               /**
-                * @see WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract#checkDependency
-                */
-               checkDependency: function() {
-                       return this._field.dataset.isClicked !== "1";
-               }
-       });
-       
-       return IsNotClicked;
-});
diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.ts
new file mode 100644 (file)
index 0000000..08d5e2b
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * Form field dependency implementation that requires that a button has not been clicked.
+ *
+ * @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/Dependency/IsNotClicked
+ * @see module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
+ * @since 5.4
+ */
+
+import Abstract from "./Abstract";
+import Manager from "./Manager";
+import * as Core from "../../../../Core";
+
+class IsNotClicked extends Abstract {
+  constructor(dependentElementId: string, fieldId: string) {
+    super(dependentElementId, fieldId);
+
+    // To check for clicks after they occured, set `isClicked` in the field's data set and then
+    // explicitly check the dependencies as the dependency manager itself does to listen to click
+    // events.
+    this._field.addEventListener("click", () => {
+      this._field.dataset.isClicked = "1";
+
+      Manager.checkDependencies();
+    });
+  }
+
+  checkDependency(): boolean {
+    return this._field.dataset.isClicked !== "1";
+  }
+}
+
+Core.enableLegacyInheritance(IsNotClicked);
+
+export = IsNotClicked;