From ee9e4388dd08ec9306c7e9b3cb503d81a84cead3 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 11 Sep 2016 13:44:42 +0200 Subject: [PATCH] Reload clipboard after deleting single media element via its delete button --- wcfsetup/install/files/js/WCF.js | 24 +++++++++++++++++++ .../Core/Controller/Media/List.js | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index b0725e4824..29333adbd6 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -1664,6 +1664,12 @@ WCF.Action.Delete = Class.extend({ */ _buttonSelector: '', + /** + * callback function called prior to triggering the delete effect + * @var function + */ + _callback: null, + /** * action class name * @var string @@ -1693,6 +1699,7 @@ WCF.Action.Delete = Class.extend({ this._containerSelector = containerSelector; this._className = className; this._buttonSelector = (buttonSelector) ? buttonSelector : '.jsDeleteButton'; + this._callback = null; this.proxy = new WCF.Action.Proxy({ success: $.proxy(this._success, this) @@ -1788,9 +1795,26 @@ WCF.Action.Delete = Class.extend({ * @param object jqXHR */ _success: function(data, textStatus, jqXHR) { + if (this._callback) { + this._callback(data.objectIDs); + } + this.triggerEffect(data.objectIDs); }, + /** + * Sets a callback function called prior to triggering the delete effect. + * + * @param {function} callback + */ + setCallback: function(callback) { + if (typeof callback !== 'function') { + throw new TypeError("[WCF.Action.Delete] Expected a valid callback for '" + this._className + "'."); + } + + this._callback = callback; + }, + /** * Triggers the delete effect for the objects with the given ids. * diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js index 4171c534fc..08217d01f8 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js @@ -26,7 +26,8 @@ define(['EventHandler', 'WoltLabSuite/Core/Controller/Clipboard', 'WoltLabSuite/ EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', this._clipboardAction.bind(this)); - new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.jsMediaRow'); + var deleteAction = new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.jsMediaRow'); + deleteAction.setCallback(Clipboard.reload.bind(Clipboard)); _mediaEditor = new MediaEditor(); -- 2.20.1