/**
* Handles installing a project as a package.
*
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Acp/Ui/Devtools/Project/Installation/Confirmation
+ * @author Matthias Schmidt
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
});
+++ /dev/null
-/**
- * Handles installing a project as a package.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @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
--- /dev/null
+/**
+ * Handles installing a project as a package.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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));
+ });
+}