Reload clipboard after deleting single media element via its delete button
authorMatthias Schmidt <gravatronics@live.com>
Sun, 11 Sep 2016 11:44:42 +0000 (13:44 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 11 Sep 2016 11:44:46 +0000 (13:44 +0200)
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js

index b0725e4824d0b7706aa77d35d39c4033afde48d9..29333adbd6344837f90a892cb56c7eb3f6d96d66 100755 (executable)
@@ -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.
         * 
index 4171c534fcd826f5c150f16eae065151e2cc39a7..08217d01f83ee431fe7fe800e7e9718504fb1eac 100644 (file)
@@ -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();