From: Alexander Ebert Date: Sun, 3 Jan 2021 14:41:10 +0000 (+0100) Subject: Convert `Acp/Ui/Devtools/Project/Installation/Confirmation` to TypeScript X-Git-Tag: 5.4.0_Alpha_1~484^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=672d794e465bec8768128ef5fe3191ea71fd6af4;p=GitHub%2FWoltLab%2FWCF.git Convert `Acp/Ui/Devtools/Project/Installation/Confirmation` to TypeScript --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.js index ed469abaf9..6df3e25fb9 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.js @@ -1,56 +1,58 @@ /** * Handles installing a project as a package. * - * @author Matthias Schmidt - * @copyright 2001-2019 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation + * @author Matthias Schmidt + * @copyright 2001-2019 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation */ -define(['Ajax', 'Language', 'Ui/Confirmation'], function (Ajax, Language, UiConfirmation) { +define(["require", "exports", "tslib", "../../../../../Ajax", "../../../../../Language", "../../../../../Ui/Confirmation"], function (require, exports, tslib_1, Ajax, Language, UiConfirmation) { "use strict"; - var _projectId; - var _projectName; - return { - /** - * Initializes the confirmation to install a project as a package. - * - * @param {int} projectId id of the installed project - * @param {string} projectName name of the installed project - */ - init: function (projectId, projectName) { - _projectId = projectId; - _projectName = projectName; - [].forEach.call(elByClass('jsDevtoolsInstallPackage'), function (element) { - element.addEventListener('click', this._showConfirmation.bind(this)); - }.bind(this)); - }, - /** - * Starts the package installation. - */ - _installPackage: function () { - Ajax.apiOnce({ - data: { - actionName: 'installPackage', - className: 'wcf\\data\\devtools\\project\\DevtoolsProjectAction', - objectIDs: [_projectId] - }, - success: function (data) { - var packageInstallation = new WCF.ACP.Package.Installation(data.returnValues.queueID, 'DevtoolsInstallPackage', data.returnValues.isApplication, false, { projectID: _projectId }); - packageInstallation.prepareInstallation(); - } - }); - }, - /** - * Shows the confirmation to start package installation. - */ - _showConfirmation: function () { - UiConfirmation.show({ - confirm: this._installPackage.bind(this), - message: Language.get('wcf.acp.devtools.project.installPackage.confirmMessage', { - packageIdentifier: _projectName - }), - messageIsHtml: true - }); - } - }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.init = void 0; + Ajax = tslib_1.__importStar(Ajax); + Language = tslib_1.__importStar(Language); + UiConfirmation = tslib_1.__importStar(UiConfirmation); + let _projectId; + let _projectName; + /** + * Starts the package installation. + */ + function installPackage() { + Ajax.apiOnce({ + data: { + actionName: "installPackage", + className: "wcf\\data\\devtools\\project\\DevtoolsProjectAction", + objectIDs: [_projectId], + }, + success: (data) => { + const packageInstallation = new window.WCF.ACP.Package.Installation(data.returnValues.queueID, "DevtoolsInstallPackage", data.returnValues.isApplication, false, { projectID: _projectId }); + packageInstallation.prepareInstallation(); + }, + }); + } + /** + * Shows the confirmation to start package installation. + */ + function showConfirmation(event) { + event.preventDefault(); + UiConfirmation.show({ + confirm: () => installPackage(), + message: Language.get("wcf.acp.devtools.project.installPackage.confirmMessage", { + packageIdentifier: _projectName, + }), + messageIsHtml: true, + }); + } + /** + * Initializes the confirmation to install a project as a package. + */ + function init(projectId, projectName) { + _projectId = projectId; + _projectName = projectName; + document.querySelectorAll(".jsDevtoolsInstallPackage").forEach((element) => { + element.addEventListener("click", (ev) => showConfirmation(ev)); + }); + } + exports.init = init; }); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.js deleted file mode 100644 index 0e463c88ce..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Handles installing a project as a package. - * - * @author Matthias Schmidt - * @copyright 2001-2019 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation - */ -define(['Ajax', 'Language', 'Ui/Confirmation'], function(Ajax, Language, UiConfirmation) { - "use strict"; - - var _projectId; - var _projectName; - - return { - /** - * Initializes the confirmation to install a project as a package. - * - * @param {int} projectId id of the installed project - * @param {string} projectName name of the installed project - */ - init: function(projectId, projectName) { - _projectId = projectId; - _projectName = projectName; - - [].forEach.call(elByClass('jsDevtoolsInstallPackage'), function(element) { - element.addEventListener('click', this._showConfirmation.bind(this)); - }.bind(this)); - }, - - /** - * Starts the package installation. - */ - _installPackage: function() { - Ajax.apiOnce({ - data: { - actionName: 'installPackage', - className: 'wcf\\data\\devtools\\project\\DevtoolsProjectAction', - objectIDs: [ _projectId ] - }, - success: function(data) { - var packageInstallation = new WCF.ACP.Package.Installation( - data.returnValues.queueID, - 'DevtoolsInstallPackage', - data.returnValues.isApplication, - false, - {projectID: _projectId} - ); - - packageInstallation.prepareInstallation(); - } - }); - }, - - /** - * Shows the confirmation to start package installation. - */ - _showConfirmation: function() { - UiConfirmation.show({ - confirm: this._installPackage.bind(this), - message: Language.get('wcf.acp.devtools.project.installPackage.confirmMessage', { - packageIdentifier: _projectName - }), - messageIsHtml: true - }); - } - }; -}); \ No newline at end of file diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.ts new file mode 100644 index 0000000000..eb6d245099 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation.ts @@ -0,0 +1,66 @@ +/** + * Handles installing a project as a package. + * + * @author Matthias Schmidt + * @copyright 2001-2019 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation + */ + +import * as Ajax from "../../../../../Ajax"; +import * as Language from "../../../../../Language"; +import * as UiConfirmation from "../../../../../Ui/Confirmation"; + +let _projectId: number; +let _projectName: string; + +/** + * Starts the package installation. + */ +function installPackage(): void { + Ajax.apiOnce({ + data: { + actionName: "installPackage", + className: "wcf\\data\\devtools\\project\\DevtoolsProjectAction", + objectIDs: [_projectId], + }, + success: (data) => { + const packageInstallation = new window.WCF.ACP.Package.Installation( + data.returnValues.queueID, + "DevtoolsInstallPackage", + data.returnValues.isApplication, + false, + { projectID: _projectId }, + ); + + packageInstallation.prepareInstallation(); + }, + }); +} + +/** + * Shows the confirmation to start package installation. + */ +function showConfirmation(event: Event): void { + event.preventDefault(); + + UiConfirmation.show({ + confirm: () => installPackage(), + message: Language.get("wcf.acp.devtools.project.installPackage.confirmMessage", { + packageIdentifier: _projectName, + }), + messageIsHtml: true, + }); +} + +/** + * Initializes the confirmation to install a project as a package. + */ +export function init(projectId: number, projectName: string): void { + _projectId = projectId; + _projectName = projectName; + + document.querySelectorAll(".jsDevtoolsInstallPackage").forEach((element: HTMLElement) => { + element.addEventListener("click", (ev) => showConfirmation(ev)); + }); +}