From: Matthias Schmidt Date: Sun, 11 Sep 2016 11:44:42 +0000 (+0200) Subject: Reload clipboard after deleting single media element via its delete button X-Git-Tag: 3.0.0_Beta_1~221 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ee9e4388dd08ec9306c7e9b3cb503d81a84cead3;p=GitHub%2FWoltLab%2FWCF.git Reload clipboard after deleting single media element via its delete button --- 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();