Fix clipboard-related issues in media dialog
authorMatthias Schmidt <gravatronics@live.com>
Thu, 29 Sep 2016 08:33:31 +0000 (10:33 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 29 Sep 2016 08:46:47 +0000 (10:46 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js

index bdea218138b8aef6e498bfa9ef2cb669bb53edce..6c3b637731c990220d57136987846c21e687ae8b 100644 (file)
@@ -37,6 +37,7 @@ define(
                this._mediaCache = null;
                this._mediaManagerMediaList = null;
                this._search = null;
+               this._forceClipboard = false;
                
                if (Permission.get('admin.content.cms.canManageMedia')) {
                        this._mediaEditor = new MediaEditor(this);
@@ -98,7 +99,7 @@ define(
                 */
                _dialogClose: function() {
                        // only show media clipboard if editor is open
-                       if (Permission.get('admin.content.cms.canManageMedia')) {
+                       if (Permission.get('admin.content.cms.canManageMedia') || this._forceClipboard) {
                                Clipboard.hideEditor('com.woltlab.wcf.media');
                        }
                },
@@ -133,11 +134,6 @@ define(
                                        mediaManager: this
                                });
                                
-                               Clipboard.setup({
-                                       hasMarkedItems: data.returnValues.hasMarkedItems ? true : false,
-                                       pageClassName: 'menuManagerDialog-' + this.getMode()
-                               });
-                               
                                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');
@@ -146,6 +142,16 @@ define(
                                }.bind(this);
                        }
                        
+                       if (Permission.get('admin.content.cms.canManageMedia') || this._forceClipboard) {
+                               Clipboard.setup({
+                                       hasMarkedItems: data.returnValues.hasMarkedItems ? true : false,
+                                       pageClassName: 'menuManagerDialog-' + this.getMode()
+                               });
+                       }
+                       else {
+                               this._removeClipboardCheckboxes();
+                       }
+                       
                        this._search = new MediaManagerSearch(this);
                        
                        if (!listItems.length) {
@@ -189,7 +195,7 @@ define(
                        if (!this._mediaManagerMediaList) return;
                        
                        // only show media clipboard if editor is open
-                       if (Permission.get('admin.content.cms.canManageMedia')) {
+                       if (Permission.get('admin.content.cms.canManageMedia') || this._forceClipboard) {
                                Clipboard.showEditor('com.woltlab.wcf.media');
                        }
                },
@@ -237,6 +243,16 @@ define(
                        }
                },
                
+               /**
+                * Removes all media clipboard checkboxes.
+                */
+               _removeClipboardCheckboxes: function() {
+                       var checkboxes = elByClass('mediaCheckbox', this._mediaManagerMediaList);
+                       while (checkboxes.length) {
+                               elRemove(checkboxes[0]);
+                       }
+               },
+               
                /**
                 * Sets the displayed media (after a search).
                 * 
@@ -282,7 +298,12 @@ define(
                        
                        DomChangeListener.trigger();
                        
-                       Clipboard.reload();
+                       if (Permission.get('admin.content.cms.canManageMedia') || this._forceClipboard) {
+                               Clipboard.reload();
+                       }
+                       else {
+                               this._removeClipboardCheckboxes();
+                       }
                },
                
                /**
index d37e4341649abf6fa417405cfad2f30917347cd1..56aac514ca97060287e7976796c0e26c4dc9d288 100644 (file)
@@ -20,6 +20,7 @@ define(['Core', 'Dictionary', 'Dom/Traverse', 'Language', 'Ui/Dialog', 'WoltLabS
                
                MediaManagerBase.call(this, options);
                
+               this._forceClipboard = true;
                this._activeButton = null;
                this._buttons = elByClass(this._options.buttonClass || 'jsMediaEditorButton');
                for (var i = 0, length = this._buttons.length; i < length; i++) {