Note: The `input` key in the options was never used anywhere.
<script data-relocate="true">
require(['WoltLabSuite/Core/Acp/Ui/Trophy/Upload'], function(IconUpload) {
- new IconUpload({if $action == 'add'}0{else}{$trophy->trophyID}{/if}, '{$tmpHash}', {
- input: 'uploadIconFile'
- });
+ new IconUpload({if $action == 'add'}0{else}{$trophy->trophyID}{/if}, '{$tmpHash}');
});
</script>
</dd>
/**
* Handles the trophy image upload.
*
- * @author Joshua Ruesweg
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Acp/Ui/Trophy/Upload
+ * @author Joshua Ruesweg
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Acp/Ui/Trophy/Upload
*/
-define(['Core', 'Dom/Traverse', 'Language', 'Upload', 'Ui/Notification'], function (Core, DomTraverse, Language, Upload, UINotification) {
+define(["require", "exports", "tslib", "../../../Core", "../../../Dom/Util", "../../../Language", "../../../Ui/Notification", "../../../Upload"], function (require, exports, tslib_1, Core, Util_1, Language, UiNotification, Upload_1) {
"use strict";
- /**
- * @constructor
- */
- function TrophyUpload(trophyID, tmpHash, options) {
- options = options || {};
- this._trophyID = ~~trophyID;
- this._tmpHash = tmpHash;
- if (options.input === undefined) {
- throw new TypeError("invalid input given");
+ Core = tslib_1.__importStar(Core);
+ Util_1 = tslib_1.__importDefault(Util_1);
+ Language = tslib_1.__importStar(Language);
+ UiNotification = tslib_1.__importStar(UiNotification);
+ Upload_1 = tslib_1.__importDefault(Upload_1);
+ class TrophyUpload extends Upload_1.default {
+ constructor(trophyId, tmpHash, options) {
+ super("uploadIconFileButton", "uploadIconFileContent", Core.extend({
+ className: "wcf\\data\\trophy\\TrophyAction",
+ }, options));
+ this.trophyId = ~~trophyId;
+ this.tmpHash = tmpHash;
}
- Upload.call(this, 'uploadIconFileButton', 'uploadIconFileContent', Core.extend({
- className: 'wcf\\data\\trophy\\TrophyAction'
- }, options));
- }
- Core.inherit(TrophyUpload, Upload, {
- /**
- * @see WoltLabSuite/Core/Upload#_getParameters
- */
- _getParameters: function () {
+ _getParameters() {
return {
- trophyID: this._trophyID,
- tmpHash: this._tmpHash
+ trophyID: this.trophyId,
+ tmpHash: this.tmpHash,
};
- },
- /**
- * @see WoltLabSuite/Core/Upload#_success
- */
- _success: function (uploadId, data) {
- elInnerError(this._button, false);
- this._target.innerHTML = "<img src=\"" + data.returnValues.url + "?timestamp=" + Date.now() + "\" />";
- UINotification.show();
- },
- /**
- * @see WoltLabSuite/Core/Upload#_failure
- */
- _failure: function (uploadId, data, responseText, xhr, requestOptions) {
- elInnerError(this._button, Language.get('wcf.acp.trophy.imageUpload.error.' + data.returnValues.errorType));
- // remove previous images
+ }
+ _success(uploadId, data) {
+ Util_1.default.innerError(this._button, false);
+ this._target.innerHTML = `<img src="${data.returnValues.url}?timestamp=${Date.now()}" alt="">`;
+ UiNotification.show();
+ }
+ _failure(uploadId, data) {
+ Util_1.default.innerError(this._button, Language.get(`wcf.acp.trophy.imageUpload.error.${data.returnValues.errorType}`));
+ // remove previous images
this._target.innerHTML = "";
return false;
}
- });
+ }
+ Core.enableLegacyInheritance(TrophyUpload);
return TrophyUpload;
});
+++ /dev/null
-/**
- * Handles the trophy image upload.
- *
- * @author Joshua Ruesweg
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Acp/Ui/Trophy/Upload
- */
-define(['Core', 'Dom/Traverse', 'Language', 'Upload', 'Ui/Notification'], function(Core, DomTraverse, Language, Upload, UINotification) {
- "use strict";
-
- /**
- * @constructor
- */
- function TrophyUpload(trophyID, tmpHash, options) {
- options = options || {};
-
- this._trophyID = ~~trophyID;
- this._tmpHash = tmpHash;
-
- if (options.input === undefined) {
- throw new TypeError("invalid input given");
- }
-
- Upload.call(this, 'uploadIconFileButton', 'uploadIconFileContent', Core.extend({
- className: 'wcf\\data\\trophy\\TrophyAction'
- }, options));
- }
-
- Core.inherit(TrophyUpload, Upload, {
- /**
- * @see WoltLabSuite/Core/Upload#_getParameters
- */
- _getParameters: function() {
- return {
- trophyID: this._trophyID,
- tmpHash: this._tmpHash
- };
- },
-
- /**
- * @see WoltLabSuite/Core/Upload#_success
- */
- _success: function(uploadId, data) {
- elInnerError(this._button, false);
-
- this._target.innerHTML = "<img src=\"" + data.returnValues.url + "?timestamp=" + Date.now() + "\" />";
-
- UINotification.show();
- },
-
- /**
- * @see WoltLabSuite/Core/Upload#_failure
- */
- _failure: function(uploadId, data, responseText, xhr, requestOptions) {
- elInnerError(this._button, Language.get('wcf.acp.trophy.imageUpload.error.' + data.returnValues.errorType));
-
- // remove previous images
- this._target.innerHTML = "";
-
- return false;
- }
- });
-
- return TrophyUpload;
-});
\ No newline at end of file
--- /dev/null
+/**
+ * Handles the trophy image upload.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Acp/Ui/Trophy/Upload
+ */
+
+import * as Core from "../../../Core";
+import DomUtil from "../../../Dom/Util";
+import * as Language from "../../../Language";
+import * as UiNotification from "../../../Ui/Notification";
+import Upload from "../../../Upload";
+import { UploadOptions } from "../../../Upload/Data";
+
+interface AjaxResponse {
+ returnValues: {
+ url: string;
+ };
+}
+
+interface AjaxResponseError {
+ returnValues: {
+ errorType: string;
+ };
+}
+
+class TrophyUpload extends Upload {
+ private readonly trophyId: number;
+ private readonly tmpHash: string;
+
+ constructor(trophyId: number, tmpHash: string, options: Partial<UploadOptions>) {
+ super(
+ "uploadIconFileButton",
+ "uploadIconFileContent",
+ Core.extend(
+ {
+ className: "wcf\\data\\trophy\\TrophyAction",
+ },
+ options,
+ ),
+ );
+
+ this.trophyId = ~~trophyId;
+ this.tmpHash = tmpHash;
+ }
+
+ protected _getParameters(): ArbitraryObject {
+ return {
+ trophyID: this.trophyId,
+ tmpHash: this.tmpHash,
+ };
+ }
+
+ protected _success(uploadId: number, data: AjaxResponse): void {
+ DomUtil.innerError(this._button, false);
+
+ this._target.innerHTML = `<img src="${data.returnValues.url}?timestamp=${Date.now()}" alt="">`;
+
+ UiNotification.show();
+ }
+
+ protected _failure(uploadId: number, data: AjaxResponseError): boolean {
+ DomUtil.innerError(this._button, Language.get(`wcf.acp.trophy.imageUpload.error.${data.returnValues.errorType}`));
+
+ // remove previous images
+ this._target.innerHTML = "";
+
+ return false;
+ }
+}
+
+Core.enableLegacyInheritance(TrophyUpload);
+
+export = TrophyUpload;