Delete old user cover photo upload/delete
authorCyperghost <olaf_schmitz_1@t-online.de>
Fri, 29 Nov 2024 13:10:42 +0000 (14:10 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Fri, 29 Nov 2024 13:10:42 +0000 (14:10 +0100)
com.woltlab.wcf/fileDelete.xml
ts/WoltLabSuite/Core/Ui/User/CoverPhoto/Delete.ts [deleted file]
ts/WoltLabSuite/Core/Ui/User/CoverPhoto/Upload.ts [deleted file]
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/CoverPhoto/Delete.js [deleted file]
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/CoverPhoto/Upload.js [deleted file]

index 5355eec8445f24e8bf3d3b694ed5818719916575..f16eecbadb4f9a2a82608ed350c47df8d6721c25 100644 (file)
                <file>js/WoltLabSuite/Core/Ui/Redactor/RuntimeStyle.js</file>
                <file>js/WoltLabSuite/Core/Ui/Redactor/Spoiler.js</file>
                <file>js/WoltLabSuite/Core/Ui/Redactor/Table.js</file>
+               <file>js/WoltLabSuite/Core/Ui/User/CoverPhoto/Delete.js</file>
+               <file>js/WoltLabSuite/Core/Ui/User/CoverPhoto/Upload.js</file>
                <file>js/WoltLabSuite/Core/Ui/User/Menu/DropDown.js</file>
                <file>js/WoltLabSuite/WebComponent/fa-brand.js</file>
                <file>js/WoltLabSuite/WebComponent/fa-icon.js</file>
diff --git a/ts/WoltLabSuite/Core/Ui/User/CoverPhoto/Delete.ts b/ts/WoltLabSuite/Core/Ui/User/CoverPhoto/Delete.ts
deleted file mode 100644 (file)
index 7398feb..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Deletes the current user cover photo.
- *
- * @author  Alexander Ebert
- * @copyright  2001-2019 WoltLab GmbH
- * @license  GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @woltlabExcludeBundle all
- */
-
-import * as Ajax from "../../../Ajax";
-import { AjaxCallbackObject, AjaxCallbackSetup, ResponseData } from "../../../Ajax/Data";
-import DomUtil from "../../../Dom/Util";
-import * as EventHandler from "../../../Event/Handler";
-import * as Language from "../../../Language";
-import * as UiConfirmation from "../../Confirmation";
-import * as UiNotification from "../../Notification";
-
-interface AjaxResponse extends ResponseData {
-  returnValues: {
-    url: string;
-  };
-}
-
-class UiUserCoverPhotoDelete implements AjaxCallbackObject {
-  private readonly button: HTMLAnchorElement;
-  private readonly userId: number;
-
-  /**
-   * Initializes the delete handler and enables the delete button on upload.
-   */
-  constructor(userId: number) {
-    const button = document.querySelector<HTMLAnchorElement>(".jsButtonDeleteCoverPhoto");
-    if (button === null) {
-      return;
-    }
-
-    this.button = button;
-    this.button.addEventListener("click", (ev) => this._click(ev));
-    this.userId = userId;
-
-    EventHandler.add("com.woltlab.wcf.user", "coverPhoto", (data) => {
-      if (typeof data.url === "string" && data.url.length > 0) {
-        DomUtil.show(this.button.parentElement!);
-      }
-    });
-  }
-
-  /**
-   * Handles clicks on the delete button.
-   */
-  _click(event: MouseEvent): void {
-    event.preventDefault();
-
-    UiConfirmation.show({
-      confirm: () => Ajax.api(this),
-      message: Language.get("wcf.user.coverPhoto.delete.confirmMessage"),
-    });
-  }
-
-  _ajaxSuccess(data: AjaxResponse): void {
-    const photo = document.querySelector(".userProfileCoverPhoto") as HTMLElement;
-    photo.style.setProperty("background-image", `url(${data.returnValues.url})`, "");
-
-    DomUtil.hide(this.button.parentElement!);
-
-    UiNotification.show();
-  }
-
-  _ajaxSetup(): ReturnType<AjaxCallbackSetup> {
-    return {
-      data: {
-        actionName: "deleteCoverPhoto",
-        className: "wcf\\data\\user\\UserProfileAction",
-        parameters: {
-          userID: this.userId,
-        },
-      },
-    };
-  }
-}
-
-let uiUserCoverPhotoDelete: UiUserCoverPhotoDelete | undefined;
-
-/**
- * Initializes the delete handler and enables the delete button on upload.
- */
-export function init(userId: number): void {
-  if (!uiUserCoverPhotoDelete) {
-    uiUserCoverPhotoDelete = new UiUserCoverPhotoDelete(userId);
-  }
-}
diff --git a/ts/WoltLabSuite/Core/Ui/User/CoverPhoto/Upload.ts b/ts/WoltLabSuite/Core/Ui/User/CoverPhoto/Upload.ts
deleted file mode 100644 (file)
index b54cfc1..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * Uploads the user cover photo via AJAX.
- *
- * @author  Alexander Ebert
- * @copyright  2001-2019 WoltLab GmbH
- * @license  GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @woltlabExcludeBundle all
- */
-
-import DomUtil from "../../../Dom/Util";
-import * as EventHandler from "../../../Event/Handler";
-import { ResponseData } from "../../../Ajax/Data";
-import * as UiDialog from "../../Dialog";
-import * as UiNotification from "../../Notification";
-import Upload from "../../../Upload";
-
-interface AjaxResponse extends ResponseData {
-  returnValues: {
-    errorMessage?: string;
-    url?: string;
-  };
-}
-
-/**
- * @constructor
- */
-class UiUserCoverPhotoUpload extends Upload {
-  private readonly userId: number;
-
-  constructor(userId: number) {
-    super("coverPhotoUploadButtonContainer", "coverPhotoUploadPreview", {
-      action: "uploadCoverPhoto",
-      className: "wcf\\data\\user\\UserProfileAction",
-    });
-
-    this.userId = userId;
-  }
-
-  protected _getParameters(): ArbitraryObject {
-    return {
-      userID: this.userId,
-    };
-  }
-
-  protected _success(uploadId: number, data: AjaxResponse): void {
-    // remove or display the error message
-    DomUtil.innerError(this._button, data.returnValues.errorMessage);
-
-    // remove the upload progress
-    this._target.innerHTML = "";
-
-    if (data.returnValues.url) {
-      const photo = document.querySelector(".userProfileCoverPhoto") as HTMLElement;
-      photo.style.setProperty("background-image", `url(${data.returnValues.url})`, "");
-
-      UiDialog.close("userProfileCoverPhotoUpload");
-      UiNotification.show();
-
-      EventHandler.fire("com.woltlab.wcf.user", "coverPhoto", {
-        url: data.returnValues.url,
-      });
-    }
-  }
-}
-
-export = UiUserCoverPhotoUpload;
diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/CoverPhoto/Delete.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/CoverPhoto/Delete.js
deleted file mode 100644 (file)
index 17a5f94..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Deletes the current user cover photo.
- *
- * @author  Alexander Ebert
- * @copyright  2001-2019 WoltLab GmbH
- * @license  GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @woltlabExcludeBundle all
- */
-define(["require", "exports", "tslib", "../../../Ajax", "../../../Dom/Util", "../../../Event/Handler", "../../../Language", "../../Confirmation", "../../Notification"], function (require, exports, tslib_1, Ajax, Util_1, EventHandler, Language, UiConfirmation, UiNotification) {
-    "use strict";
-    Object.defineProperty(exports, "__esModule", { value: true });
-    exports.init = init;
-    Ajax = tslib_1.__importStar(Ajax);
-    Util_1 = tslib_1.__importDefault(Util_1);
-    EventHandler = tslib_1.__importStar(EventHandler);
-    Language = tslib_1.__importStar(Language);
-    UiConfirmation = tslib_1.__importStar(UiConfirmation);
-    UiNotification = tslib_1.__importStar(UiNotification);
-    class UiUserCoverPhotoDelete {
-        button;
-        userId;
-        /**
-         * Initializes the delete handler and enables the delete button on upload.
-         */
-        constructor(userId) {
-            const button = document.querySelector(".jsButtonDeleteCoverPhoto");
-            if (button === null) {
-                return;
-            }
-            this.button = button;
-            this.button.addEventListener("click", (ev) => this._click(ev));
-            this.userId = userId;
-            EventHandler.add("com.woltlab.wcf.user", "coverPhoto", (data) => {
-                if (typeof data.url === "string" && data.url.length > 0) {
-                    Util_1.default.show(this.button.parentElement);
-                }
-            });
-        }
-        /**
-         * Handles clicks on the delete button.
-         */
-        _click(event) {
-            event.preventDefault();
-            UiConfirmation.show({
-                confirm: () => Ajax.api(this),
-                message: Language.get("wcf.user.coverPhoto.delete.confirmMessage"),
-            });
-        }
-        _ajaxSuccess(data) {
-            const photo = document.querySelector(".userProfileCoverPhoto");
-            photo.style.setProperty("background-image", `url(${data.returnValues.url})`, "");
-            Util_1.default.hide(this.button.parentElement);
-            UiNotification.show();
-        }
-        _ajaxSetup() {
-            return {
-                data: {
-                    actionName: "deleteCoverPhoto",
-                    className: "wcf\\data\\user\\UserProfileAction",
-                    parameters: {
-                        userID: this.userId,
-                    },
-                },
-            };
-        }
-    }
-    let uiUserCoverPhotoDelete;
-    /**
-     * Initializes the delete handler and enables the delete button on upload.
-     */
-    function init(userId) {
-        if (!uiUserCoverPhotoDelete) {
-            uiUserCoverPhotoDelete = new UiUserCoverPhotoDelete(userId);
-        }
-    }
-});
diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/CoverPhoto/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/CoverPhoto/Upload.js
deleted file mode 100644 (file)
index 872ce78..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Uploads the user cover photo via AJAX.
- *
- * @author  Alexander Ebert
- * @copyright  2001-2019 WoltLab GmbH
- * @license  GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @woltlabExcludeBundle all
- */
-define(["require", "exports", "tslib", "../../../Dom/Util", "../../../Event/Handler", "../../Dialog", "../../Notification", "../../../Upload"], function (require, exports, tslib_1, Util_1, EventHandler, UiDialog, UiNotification, Upload_1) {
-    "use strict";
-    Util_1 = tslib_1.__importDefault(Util_1);
-    EventHandler = tslib_1.__importStar(EventHandler);
-    UiDialog = tslib_1.__importStar(UiDialog);
-    UiNotification = tslib_1.__importStar(UiNotification);
-    Upload_1 = tslib_1.__importDefault(Upload_1);
-    /**
-     * @constructor
-     */
-    class UiUserCoverPhotoUpload extends Upload_1.default {
-        userId;
-        constructor(userId) {
-            super("coverPhotoUploadButtonContainer", "coverPhotoUploadPreview", {
-                action: "uploadCoverPhoto",
-                className: "wcf\\data\\user\\UserProfileAction",
-            });
-            this.userId = userId;
-        }
-        _getParameters() {
-            return {
-                userID: this.userId,
-            };
-        }
-        _success(uploadId, data) {
-            // remove or display the error message
-            Util_1.default.innerError(this._button, data.returnValues.errorMessage);
-            // remove the upload progress
-            this._target.innerHTML = "";
-            if (data.returnValues.url) {
-                const photo = document.querySelector(".userProfileCoverPhoto");
-                photo.style.setProperty("background-image", `url(${data.returnValues.url})`, "");
-                UiDialog.close("userProfileCoverPhotoUpload");
-                UiNotification.show();
-                EventHandler.fire("com.woltlab.wcf.user", "coverPhoto", {
-                    url: data.returnValues.url,
-                });
-            }
-        }
-    }
-    return UiUserCoverPhotoUpload;
-});