From 2aa6024286304b46cd7fe0d474410d05ea1636e2 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 12 Dec 2020 16:07:29 +0100 Subject: [PATCH] Convert `Form/Builder/Field/Dependency/IsNotClicked` to TypeScript --- .../Builder/Field/Dependency/IsNotClicked.js | 48 +++++++++---------- .../Builder/Field/Dependency/IsNotClicked.js | 36 -------------- .../Builder/Field/Dependency/IsNotClicked.ts | 37 ++++++++++++++ 3 files changed, 61 insertions(+), 60 deletions(-) delete mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.js create mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Dependency/IsNotClicked.ts 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; -- 2.20.1