import MediaManagerEditor from "./Manager/Editor";
import * as Clipboard from "../Controller/Clipboard";
import * as UiNotification from "../Ui/Notification";
-import * as UiDialog from "../Ui/Dialog";
import * as EventHandler from "../Event/Handler";
-import * as Language from "../Language";
+import { getPhrase } from "../Language";
import * as Ajax from "../Ajax";
import { AjaxCallbackObject, AjaxCallbackSetup } from "../Ajax/Data";
-import { DialogCallbackObject, DialogCallbackSetup } from "../Ui/Dialog/Data";
+import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
+import WoltlabCoreDialogElement from "WoltLabSuite/Core/Element/woltlab-core-dialog";
let _mediaManager: MediaManager;
let _didInit = false;
-class MediaClipboard implements AjaxCallbackObject, DialogCallbackObject {
+class MediaClipboard implements AjaxCallbackObject {
+ #dialog?: WoltlabCoreDialogElement;
+
public _ajaxSetup(): ReturnType<AjaxCallbackSetup> {
return {
data: {
public _ajaxSuccess(data): void {
switch (data.actionName) {
case "getSetCategoryDialog":
- UiDialog.open(this, data.returnValues.template);
+ this.#dialog = dialogFactory().fromHtml(data.returnValues.template).asConfirmation();
+ this.#dialog.show(getPhrase("wcf.media.setCategory"));
+ this.#dialog.addEventListener("primary", () => {
+ const category = this.#dialog!.content.querySelector('select[name="categoryID"]') as HTMLSelectElement;
+ setCategory(~~category.value);
+ });
break;
case "setCategory":
- UiDialog.close(this);
+ this.#dialog?.close();
UiNotification.show();
break;
}
}
-
- public _dialogSetup(): ReturnType<DialogCallbackSetup> {
- return {
- id: "mediaSetCategoryDialog",
- options: {
- onSetup: (content) => {
- content.querySelector("button")!.addEventListener("click", (event) => {
- event.preventDefault();
-
- const category = content.querySelector('select[name="categoryID"]') as HTMLSelectElement;
- setCategory(~~category.value);
-
- const target = event.currentTarget as HTMLButtonElement;
- target.disabled = true;
- });
- },
- title: Language.get("wcf.media.setCategory"),
- },
- source: null,
- };
- }
}
const ajax = new MediaClipboard();
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @woltlabExcludeBundle tiny
*/
-define(["require", "exports", "tslib", "../Controller/Clipboard", "../Ui/Notification", "../Ui/Dialog", "../Event/Handler", "../Language", "../Ajax"], function (require, exports, tslib_1, Clipboard, UiNotification, UiDialog, EventHandler, Language, Ajax) {
+define(["require", "exports", "tslib", "../Controller/Clipboard", "../Ui/Notification", "../Event/Handler", "../Language", "../Ajax", "WoltLabSuite/Core/Component/Dialog"], function (require, exports, tslib_1, Clipboard, UiNotification, EventHandler, Language_1, Ajax, Dialog_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setMediaManager = exports.init = void 0;
Clipboard = tslib_1.__importStar(Clipboard);
UiNotification = tslib_1.__importStar(UiNotification);
- UiDialog = tslib_1.__importStar(UiDialog);
EventHandler = tslib_1.__importStar(EventHandler);
- Language = tslib_1.__importStar(Language);
Ajax = tslib_1.__importStar(Ajax);
let _mediaManager;
let _didInit = false;
class MediaClipboard {
+ #dialog;
_ajaxSetup() {
return {
data: {
_ajaxSuccess(data) {
switch (data.actionName) {
case "getSetCategoryDialog":
- UiDialog.open(this, data.returnValues.template);
+ this.#dialog = (0, Dialog_1.dialogFactory)().fromHtml(data.returnValues.template).asConfirmation();
+ this.#dialog.show((0, Language_1.getPhrase)("wcf.media.setCategory"));
+ this.#dialog.addEventListener("primary", () => {
+ const category = this.#dialog.content.querySelector('select[name="categoryID"]');
+ setCategory(~~category.value);
+ });
break;
case "setCategory":
- UiDialog.close(this);
+ this.#dialog?.close();
UiNotification.show();
Clipboard.reload();
break;
}
}
- _dialogSetup() {
- return {
- id: "mediaSetCategoryDialog",
- options: {
- onSetup: (content) => {
- content.querySelector("button").addEventListener("click", (event) => {
- event.preventDefault();
- const category = content.querySelector('select[name="categoryID"]');
- setCategory(~~category.value);
- const target = event.currentTarget;
- target.disabled = true;
- });
- },
- title: Language.get("wcf.media.setCategory"),
- },
- source: null,
- };
- }
}
const ajax = new MediaClipboard();
let clipboardObjectIds = [];