From: Matthias Schmidt Date: Thu, 29 Sep 2016 08:33:31 +0000 (+0200) Subject: Fix clipboard-related issues in media dialog X-Git-Tag: 3.0.0_Beta_2~71 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=59a192695205b3333b489255cf23e1eb91983931;p=GitHub%2FWoltLab%2FWCF.git Fix clipboard-related issues in media dialog --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js index bdea218138..6c3b637731 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js @@ -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(); + } }, /** diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js index d37e434164..56aac514ca 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js @@ -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++) {