{foreach from=$mediaList item=media}
- <li class="jsClipboardObject mediaFile" data-object-id="{@$media->mediaID}">
+ <li class="jsClipboardObject mediaFile jsObjectActionObject" data-object-id="{@$media->getObjectID()}">
<div class="mediaThumbnail">
{@$media->getElementTag(144)}
</div>
<li class="jsMediaEditButton" data-object-id="{@$media->mediaID}">
<a><span class="icon icon16 fa-pencil jsTooltip" title="{lang}wcf.global.button.edit{/lang}"></span> <span class="invisible">{lang}wcf.global.button.edit{/lang}</span></a>
</li>
- <li class="jsDeleteButton" data-object-id="{@$media->mediaID}" data-confirm-message-html="{lang title=$__mediaTitle __encode=true}wcf.media.delete.confirmMessage{/lang}">
+ <li class="jsObjectAction" data-object-action="delete" data-confirm-message="{lang title=$__mediaTitle __encode=true}wcf.media.delete.confirmMessage{/lang}">
<a><span class="icon icon16 fa-times jsTooltip" title="{lang}wcf.global.button.delete{/lang}"></span> <span class="invisible">{lang}wcf.global.button.delete{/lang}</span></a>
</li>
{/if}
<div class="jsClipboardContainer" data-type="com.woltlab.wcf.media">
<input type="checkbox" class="jsClipboardMarkAll" style="display: none;">
- <ul class="mediaManagerMediaList">
+ <ul class="mediaManagerMediaList jsObjectActionContainer" data-object-action-class-name="wcf\data\media\MediaAction">
{include file='mediaListItems'}
</ul>
</div>
clipboardDeleteMedia: (mediaIds: number[]) => clipboardDeleteMedia(mediaIds),
} as MediaManager);
- EventHandler.add("com.woltlab.wcf.media.upload", "removedErroneousUploadRow", () => deleteCallback());
-
- // eslint-disable-next-line
- //@ts-ignore
- const deleteAction = new WCF.Action.Delete("wcf\\data\\media\\MediaAction", ".jsMediaRow");
- deleteAction.setCallback(deleteCallback);
-
addButtonEventListeners();
DomChangeListener.add("WoltLabSuite/Core/Controller/Media/List", () => addButtonEventListeners());
import MediaUpload from "../Upload";
import MediaEditor from "../Editor";
import * as MediaClipboard from "../Clipboard";
+import { ObjectActionData } from "../../Ui/Object/Data";
let mediaManagerCounter = 0;
mediaManager: this,
});
- // eslint-disable-next-line
- //@ts-ignore
- const deleteAction = new WCF.Action.Delete("wcf\\data\\media\\MediaAction", ".mediaFile");
- deleteAction._didTriggerEffect = (element) => this.removeMedia(element[0].dataset.objectId);
+ EventHandler.add("WoltLabSuite/Core/Ui/Object/Action", "delete", (data: ObjectActionData) =>
+ this.removeMedia(~~data.objectElement.dataset.objectId!),
+ );
}
if (Permission.get("admin.content.cms.canManageMedia") || this._forceClipboard) {
</a>`;
const deleteButton = document.createElement("li");
- deleteButton.className = "jsDeleteButton";
- deleteButton.dataset.objectId = media.mediaID.toString();
+ deleteButton.classList.add("jsObjectAction");
+ deleteButton.dataset.objectAction = "delete";
// use temporary title to not unescape html in filename
const uuid = Core.getUuid();
- deleteButton.dataset.confirmMessageHtml = StringUtil.unescapeHTML(
+ deleteButton.dataset.confirmMessage = StringUtil.unescapeHTML(
Language.get("wcf.media.delete.confirmMessage", {
title: uuid,
}),
cell.querySelectorAll("[data-object-id]").forEach((el: HTMLElement) => DomUtil.hide(el));
cell.querySelector(".mediaEditButton")!.classList.add("jsMediaEditButton");
- (cell.querySelector(".jsDeleteButton") as HTMLElement).dataset.confirmMessageHtml = Language.get(
- "wcf.media.delete.confirmMessage",
- {
- title: file.name,
- },
- );
+ (cell.querySelector(
+ ".jsObjectAction[data-object-action='delete']",
+ ) as HTMLElement).dataset.confirmMessage = Language.get("wcf.media.delete.confirmMessage", {
+ title: file.name,
+ });
} else if (cell.classList.contains("columnFilename")) {
// replace copied image with spinner
let image = cell.querySelector("img");
if (file.tagName === "TR") {
if (media) {
// update object id
+ file.dataset.objectId = media.mediaID.toString();
file.querySelectorAll("[data-object-id]").forEach((el: HTMLElement) => {
el.dataset.objectId = media.mediaID.toString();
el.style.removeProperty("display");
const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail")!, "SPAN")!;
this._replaceFileIcon(fileIcon, media, 144);
- file.className = "jsClipboardObject mediaFile";
+ file.classList.add("jsClipboardObject", "mediaFile", "jsObjectActionObject");
file.dataset.objectId = media.mediaID.toString();
if (this._mediaManager) {
});
});
}
+
export function setup(): void {
observeElements();
DomChangeListener.add("WoltLabSuite/Core/Ui/Empty", () => observeElements());
import * as UiConfirmation from "../Confirmation";
import * as Language from "../../Language";
import * as StringUtil from "../../StringUtil";
+import DomChangeListener from "../../Dom/Change/Listener";
const containerSelector = ".jsObjectActionContainer[data-object-action-class-name]";
const objectSelector = ".jsObjectActionObject[data-object-id]";
} as ObjectActionData);
}
-export function setup(): void {
+const actions = new Set<HTMLElement>();
+
+function registerElements(): void {
document
.querySelectorAll(`${containerSelector} ${objectSelector} ${actionSelector}`)
.forEach((action: HTMLElement) => {
- action.addEventListener("click", (ev) => executeAction(ev));
+ if (!actions.has(action)) {
+ action.addEventListener("click", (ev) => executeAction(ev));
+
+ actions.add(action);
+ }
});
+}
- // TODO: handle elements added later on
+export function setup(): void {
+ registerElements();
+ DomChangeListener.add("WoltLabSuite/Core/Ui/Empty", () => registerElements());
}
{/hascontent}
<div class="section tabularBox"{if !$objects|count} style="display: none;{/if}">
- <table class="table jsClipboardContainer" data-type="com.woltlab.wcf.media">
+ <table class="table jsClipboardContainer jsObjectActionContainer" data-object-action-class-name="wcf\data\media\MediaAction" data-type="com.woltlab.wcf.media">
<thead>
<tr>
<th class="columnMark"><label><input type="checkbox" class="jsClipboardMarkAll"></label></th>
</tr>
</thead>
- <tbody id="mediaListTableBody" data-no-items-info="noItemsInfo">
+ <tbody class="jsReloadPageWhenEmpty" id="mediaListTableBody" data-no-items-info="noItemsInfo">
{foreach from=$objects item=media}
- <tr class="jsMediaRow jsClipboardObject">
+ <tr class="jsMediaRow jsClipboardObject jsObjectActionObject" data-object-id="{@$media->getObjectID()}">
<td class="columnMark"><input type="checkbox" class="jsClipboardItem" data-object-id="{@$media->mediaID}"></td>
<td class="columnIcon">
<span class="icon icon16 fa-pencil mediaEditButton jsMediaEditButton jsTooltip pointer" title="{lang}wcf.global.button.edit{/lang}" data-object-id="{@$media->mediaID}"></span>
- <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="{@$media->mediaID}" data-confirm-message-html="{lang title=$media->filename __encode=true}wcf.media.delete.confirmMessage{/lang}"></span>
+ {objectAction action="delete" objectTitle=$media->filename}
{event name='rowButtons'}
</td>
{event name='columns'}
</tr>
{foreachelse}
- <tr class="jsMediaRow jsClipboardObject">
+ <tr class="jsMediaRow jsClipboardObject jsObjectActionObject" data-object-id="0">
<td class="columnMark"><input type="checkbox" class="jsClipboardItem" data-object-id="0"></td>
<td class="columnIcon">
<span class="icon icon16 fa-pencil mediaEditButton jsMediaEditButton jsTooltip pointer" title="{lang}wcf.global.button.edit{/lang}" data-object-id="0"></span>
- <span class="icon icon16 fa-times jsDeleteButton jsTooltip pointer" title="{lang}wcf.global.button.delete{/lang}" data-object-id="0"></span>
+ {objectAction action="delete" confirmMessage=""}
{event name='rowButtons'}
</td>
{foreach from=$mediaList item=media}
- <li class="jsClipboardObject mediaFile" data-object-id="{@$media->mediaID}">
+ <li class="jsClipboardObject mediaFile jsObjectActionObject" data-object-id="{@$media->getObjectID()}">
<div class="mediaThumbnail">
{@$media->getElementTag(144)}
</div>
<li class="jsMediaEditButton" data-object-id="{@$media->mediaID}">
<a><span class="icon icon16 fa-pencil jsTooltip" title="{lang}wcf.global.button.edit{/lang}"></span> <span class="invisible">{lang}wcf.global.button.edit{/lang}</span></a>
</li>
- <li class="jsDeleteButton" data-object-id="{@$media->mediaID}" data-confirm-message-html="{lang title=$__mediaTitle __encode=true}wcf.media.delete.confirmMessage{/lang}">
+ <li class="jsObjectAction" data-object-action="delete" data-confirm-message="{lang title=$__mediaTitle __encode=true}wcf.media.delete.confirmMessage{/lang}">
<a><span class="icon icon16 fa-times jsTooltip" title="{lang}wcf.global.button.delete{/lang}"></span> <span class="invisible">{lang}wcf.global.button.delete{/lang}</span></a>
</li>
{/if}
<div class="jsClipboardContainer" data-type="com.woltlab.wcf.media">
<input type="checkbox" class="jsClipboardMarkAll" style="display: none;">
- <ul class="mediaManagerMediaList">
+ <ul class="mediaManagerMediaList jsObjectActionContainer" data-object-action-class-name="wcf\data\media\MediaAction">
{include file='mediaListItems'}
</ul>
</div>
MediaClipboard.init("wcf\\acp\\page\\MediaListPage", options.hasMarkedItems || false, {
clipboardDeleteMedia: (mediaIds) => clipboardDeleteMedia(mediaIds),
});
- EventHandler.add("com.woltlab.wcf.media.upload", "removedErroneousUploadRow", () => deleteCallback());
- // eslint-disable-next-line
- //@ts-ignore
- const deleteAction = new WCF.Action.Delete("wcf\\data\\media\\MediaAction", ".jsMediaRow");
- deleteAction.setCallback(deleteCallback);
addButtonEventListeners();
DomChangeListener.add("WoltLabSuite/Core/Controller/Media/List", () => addButtonEventListeners());
EventHandler.add("com.woltlab.wcf.media.upload", "success", (data) => openEditorAfterUpload(data));
this._upload = new Upload_1.default(DomUtil.identify(uploadButton), DomUtil.identify(this._mediaManagerMediaList), {
mediaManager: this,
});
- // eslint-disable-next-line
- //@ts-ignore
- const deleteAction = new WCF.Action.Delete("wcf\\data\\media\\MediaAction", ".mediaFile");
- deleteAction._didTriggerEffect = (element) => this.removeMedia(element[0].dataset.objectId);
+ EventHandler.add("WoltLabSuite/Core/Ui/Object/Action", "delete", (data) => this.removeMedia(~~data.objectElement.dataset.objectId));
}
if (Permission.get("admin.content.cms.canManageMedia") || this._forceClipboard) {
MediaClipboard.init("menuManagerDialog-" + this.getMode(), this._hadInitiallyMarkedItems ? true : false, this);
<span class="invisible">${Language.get("wcf.global.button.edit")}</span>
</a>`;
const deleteButton = document.createElement("li");
- deleteButton.className = "jsDeleteButton";
- deleteButton.dataset.objectId = media.mediaID.toString();
+ deleteButton.classList.add("jsObjectAction");
+ deleteButton.dataset.objectAction = "delete";
// use temporary title to not unescape html in filename
const uuid = Core.getUuid();
- deleteButton.dataset.confirmMessageHtml = StringUtil.unescapeHTML(Language.get("wcf.media.delete.confirmMessage", {
+ deleteButton.dataset.confirmMessage = StringUtil.unescapeHTML(Language.get("wcf.media.delete.confirmMessage", {
title: uuid,
})).replace(uuid, StringUtil.escapeHTML(media.filename));
buttons.appendChild(deleteButton);
else if (cell.classList.contains("columnIcon")) {
cell.querySelectorAll("[data-object-id]").forEach((el) => DomUtil.hide(el));
cell.querySelector(".mediaEditButton").classList.add("jsMediaEditButton");
- cell.querySelector(".jsDeleteButton").dataset.confirmMessageHtml = Language.get("wcf.media.delete.confirmMessage", {
+ cell.querySelector(".jsObjectAction[data-object-action='delete']").dataset.confirmMessage = Language.get("wcf.media.delete.confirmMessage", {
title: file.name,
});
}
if (file.tagName === "TR") {
if (media) {
// update object id
+ file.dataset.objectId = media.mediaID.toString();
file.querySelectorAll("[data-object-id]").forEach((el) => {
el.dataset.objectId = media.mediaID.toString();
el.style.removeProperty("display");
if (media) {
const fileIcon = DomTraverse.childByTag(DomTraverse.childByClass(file, "mediaThumbnail"), "SPAN");
this._replaceFileIcon(fileIcon, media, 144);
- file.className = "jsClipboardObject mediaFile";
+ file.classList.add("jsClipboardObject", "mediaFile", "jsObjectActionObject");
file.dataset.objectId = media.mediaID.toString();
if (this._mediaManager) {
this._mediaManager.setupMediaElement(media, file);
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLabSuite/Core/Ui/Object/Action
*/
-define(["require", "exports", "tslib", "../../Ajax", "../../Event/Handler", "../Confirmation", "../../Language", "../../StringUtil"], function (require, exports, tslib_1, Ajax, EventHandler, UiConfirmation, Language, StringUtil) {
+define(["require", "exports", "tslib", "../../Ajax", "../../Event/Handler", "../Confirmation", "../../Language", "../../StringUtil", "../../Dom/Change/Listener"], function (require, exports, tslib_1, Ajax, EventHandler, UiConfirmation, Language, StringUtil, Listener_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setup = void 0;
UiConfirmation = tslib_1.__importStar(UiConfirmation);
Language = tslib_1.__importStar(Language);
StringUtil = tslib_1.__importStar(StringUtil);
+ Listener_1 = tslib_1.__importDefault(Listener_1);
const containerSelector = ".jsObjectActionContainer[data-object-action-class-name]";
const objectSelector = ".jsObjectActionObject[data-object-id]";
const actionSelector = ".jsObjectAction[data-object-action]";
objectElement: actionElement.closest(objectSelector),
});
}
- function setup() {
+ const actions = new Set();
+ function registerElements() {
document
.querySelectorAll(`${containerSelector} ${objectSelector} ${actionSelector}`)
.forEach((action) => {
- action.addEventListener("click", (ev) => executeAction(ev));
+ if (!actions.has(action)) {
+ action.addEventListener("click", (ev) => executeAction(ev));
+ actions.add(action);
+ }
});
- // TODO: handle elements added later on
+ }
+ function setup() {
+ registerElements();
+ Listener_1.default.add("WoltLabSuite/Core/Ui/Empty", () => registerElements());
}
exports.setup = setup;
});