Language.addObject({
'wcf.global.button.insert': '{lang}wcf.global.button.insert{/lang}',
+ 'wcf.media.delete.confirmMessage': '{lang __encode=true}wcf.media.delete.confirmMessage{/lang}',
'wcf.media.insert': '{lang}wcf.media.insert{/lang}',
'wcf.media.insert.imageSize': '{lang}wcf.media.insert.imageSize{/lang}',
'wcf.media.insert.imageSize.small': '{lang}wcf.media.insert.imageSize.small{/lang}',
{foreach from=$mediaList item=media}
- <li class="jsClipboardObject" data-object-id="{@$media->mediaID}">
+ <li class="jsClipboardObject mediaFile" data-object-id="{@$media->mediaID}">
<div class="mediaThumbnail">
{@$media->getElementTag(144)}
</div>
<a><span class="icon icon16 fa-pencil jsTooltip jsMediaEditIcon" data-object-id="{@$media->mediaID}" title="{lang}wcf.global.button.edit{/lang}"></span></a>
</li>
<li>
- <a><span class="icon icon16 fa-times jsTooltip jsMediaDeleteIcon" data-object-id="{@$media->mediaID}" title="{lang}wcf.global.button.delete{/lang}"></span></a>
+ <a><span class="icon icon16 fa-times jsTooltip jsDeleteButton" data-object-id="{@$media->mediaID}" title="{lang}wcf.global.button.delete{/lang}" data-confirm-message-html="{lang __encode=true}wcf.media.delete.confirmMessage{/lang}"></span></a>
</li>
{/if}
{if $mode == 'editor'}
Language.addObject({
'wcf.global.button.insert': '{lang}wcf.global.button.insert{/lang}',
+ 'wcf.media.delete.confirmMessage': '{lang __encode=true}wcf.media.delete.confirmMessage{/lang}',
'wcf.media.insert': '{lang}wcf.media.insert{/lang}',
'wcf.media.insert.imageSize': '{lang}wcf.media.insert.imageSize{/lang}',
'wcf.media.insert.imageSize.small': '{lang}wcf.media.insert.imageSize.small{/lang}',
{foreach from=$mediaList item=media}
- <li class="jsClipboardObject" data-object-id="{@$media->mediaID}">
+ <li class="jsClipboardObject mediaFile" data-object-id="{@$media->mediaID}">
<div class="mediaThumbnail">
{@$media->getElementTag(144)}
</div>
<a><span class="icon icon16 fa-pencil jsTooltip jsMediaEditIcon" data-object-id="{@$media->mediaID}" title="{lang}wcf.global.button.edit{/lang}"></span></a>
</li>
<li>
- <a><span class="icon icon16 fa-times jsTooltip jsMediaDeleteIcon" data-object-id="{@$media->mediaID}" title="{lang}wcf.global.button.delete{/lang}"></span></a>
+ <a><span class="icon icon16 fa-times jsTooltip jsDeleteButton" data-object-id="{@$media->mediaID}" title="{lang}wcf.global.button.delete{/lang}" data-confirm-message-html="{lang __encode=true}wcf.media.delete.confirmMessage{/lang}"></span></a>
</li>
{/if}
{if $mode == 'editor'}
*/
_clipboardAction: function(actionData) {
// only consider events if the action has been executed
- if (actionData.data.actionName === 'com.woltlab.wcf.media.delete' && actionData.responseData === null) {
+ if (actionData.data.actionName === 'com.woltlab.wcf.media.delete' && actionData.responseData !== null) {
var mediaIds = actionData.responseData.objectIDs;
for (var i = 0, length = mediaIds.length; i < length; i++) {
this.removeMedia(~~mediaIds[i], true);
});
EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', this._clipboardAction.bind(this));
+
+ var deleteAction = new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.mediaFile');
+ deleteAction._didTriggerEffect = function(element) {
+ this.removeMedia(elData(element[0], 'object-id'), true);
+ }.bind(this);
}
this._search = new MediaManagerSearch(this);
removeMedia: function(mediaId, checkCache) {
if (this._media.has(mediaId)) {
// remove list item
- elRemove(this._media.get(mediaId));
+ try {
+ elRemove(this._media.get(mediaId));
+ }
+ catch (e) {
+ // ignore errors if item has already been removed like by WCF.Action.Delete
+ }
this._media.delete(mediaId);
this._mediaData.delete(mediaId);
listItem.appendChild(a);
icon = elCreate('span');
- icon.className = 'icon icon16 fa-times jsTooltip jsMediaDeleteIcon';
+ icon.className = 'icon icon16 fa-times jsTooltip jsDeleteButton';
elData(icon, 'object-id', media.mediaID);
+ elData(icon, 'confirm-message-html', Language.get('wcf.media.delete.confirmMessage'));
elAttr(icon, 'title', Language.get('wcf.global.button.delete'));
a.appendChild(icon);
}
fileIcon.classList.add(FileUtil.getIconClassByMimeType(media.fileType));
}
- file.className = 'jsClipboardObject';
+ file.className = 'jsClipboardObject mediaFile';
elData(file, 'object-id', media.mediaID);
if (this._mediaManager) {