From: Alexander Ebert Date: Mon, 30 Nov 2020 00:39:47 +0000 (+0100) Subject: Convert `Acp/Ui/Page/Copy` to TypeScript X-Git-Tag: 5.4.0_Alpha_1~573^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=09e2c8528789008033c60dda468116b80cc980d2;p=GitHub%2FWoltLab%2FWCF.git Convert `Acp/Ui/Page/Copy` to TypeScript --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Copy.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Copy.js index f6ebe64891..65bde4ade3 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Copy.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Copy.js @@ -1,25 +1,33 @@ -define(['Language', 'Ui/Dialog'], function (Language, UiDialog) { - return { - init: function () { - elBySelAll('.jsButtonCopyPage', undefined, (function (button) { - button.addEventListener('click', this._click.bind(this)); - }).bind(this)); - }, - /** - * @param {Event} event - * @protected - */ - _click: function (event) { +define(["require", "exports", "tslib", "../../../Language", "../../../Ui/Dialog"], function (require, exports, tslib_1, Language, Dialog_1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.init = void 0; + Language = tslib_1.__importStar(Language); + Dialog_1 = tslib_1.__importDefault(Dialog_1); + class AcpUiPageCopy { + constructor() { + document.querySelectorAll(".jsButtonCopyPage").forEach((button) => { + button.addEventListener("click", (ev) => this.click(ev)); + }); + } + click(event) { event.preventDefault(); - UiDialog.open(this); - }, - _dialogSetup: function () { + Dialog_1.default.open(this); + } + _dialogSetup() { return { - id: 'acpPageCopyDialog', + id: "acpPageCopyDialog", options: { - title: Language.get('wcf.acp.page.copy') - } + title: Language.get("wcf.acp.page.copy"), + }, }; } - }; + } + let acpUiPageCopy; + function init() { + if (!acpUiPageCopy) { + acpUiPageCopy = new AcpUiPageCopy(); + } + } + exports.init = init; }); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Page/Copy.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Page/Copy.js deleted file mode 100644 index 41a1c21849..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Page/Copy.js +++ /dev/null @@ -1,28 +0,0 @@ -define(['Language', 'Ui/Dialog'], function(Language, UiDialog) { - return { - init: function () { - elBySelAll('.jsButtonCopyPage', undefined, (function(button) { - button.addEventListener('click', this._click.bind(this)); - }).bind(this)); - }, - - /** - * @param {Event} event - * @protected - */ - _click: function (event) { - event.preventDefault(); - - UiDialog.open(this); - }, - - _dialogSetup: function () { - return { - id: 'acpPageCopyDialog', - options: { - title: Language.get('wcf.acp.page.copy') - } - }; - } - }; -}); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Page/Copy.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Page/Copy.ts new file mode 100644 index 0000000000..7e256119c7 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Page/Copy.ts @@ -0,0 +1,34 @@ +import { DialogCallbackObject, DialogCallbackSetup } from "../../../Ui/Dialog/Data"; +import * as Language from "../../../Language"; +import UiDialog from "../../../Ui/Dialog"; + +class AcpUiPageCopy implements DialogCallbackObject { + constructor() { + document.querySelectorAll(".jsButtonCopyPage").forEach((button: HTMLAnchorElement) => { + button.addEventListener("click", (ev) => this.click(ev)); + }); + } + + private click(event: MouseEvent): void { + event.preventDefault(); + + UiDialog.open(this); + } + + _dialogSetup(): ReturnType { + return { + id: "acpPageCopyDialog", + options: { + title: Language.get("wcf.acp.page.copy"), + }, + }; + } +} + +let acpUiPageCopy: AcpUiPageCopy; + +export function init(): void { + if (!acpUiPageCopy) { + acpUiPageCopy = new AcpUiPageCopy(); + } +}