From: Matthias Schmidt Date: Sat, 12 Dec 2020 15:07:29 +0000 (+0100) Subject: Convert `Form/Builder/Field/Dependency/IsNotClicked` to TypeScript X-Git-Tag: 5.4.0_Alpha_1~526^2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2aa6024286304b46cd7fe0d474410d05ea1636e2;p=GitHub%2FWoltLab%2FWCF.git Convert `Form/Builder/Field/Dependency/IsNotClicked` to TypeScript --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js index 6d8c273fce..c13fc9aeac 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js @@ -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 - * @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 + * @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 index f2b53f34a8..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js +++ /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 - * @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 index 0000000000..08d5e2b475 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.ts @@ -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 + * @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;