From c2e1996da33f6a629bf8e8b06b8beab40ba7d1d7 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 9 Dec 2020 17:33:21 +0100 Subject: [PATCH] Convert `Form/Builder/Field/Captcha` to TypeScript --- .../Core/Form/Builder/Field/Captcha.js | 56 ++++++++----------- .../Core/Form/Builder/Field/Captcha.js | 49 ---------------- .../Core/Form/Builder/Field/Captcha.ts | 38 +++++++++++++ 3 files changed, 60 insertions(+), 83 deletions(-) delete mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.js create mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.ts diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Captcha.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Captcha.js index 98c7e0b89f..fb346e7fdf 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Captcha.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Form/Builder/Field/Captcha.js @@ -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 - * @module WoltLabSuite/Core/Form/Builder/Field/Captcha - * @since 5.2 + * @author Matthias Schmidt + * @copyright 2001-2020 WoltLab GmbH + * @license GNU Lesser General Public License + * @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 index 4419c64b6b..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.js +++ /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 - * @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 index 0000000000..74e9c8ddb7 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Form/Builder/Field/Captcha.ts @@ -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 + * @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; -- 2.20.1