From: Matthias Schmidt Date: Sun, 17 Jul 2016 10:46:59 +0000 (+0200) Subject: Fix order of Clipboard-related code for media dialog X-Git-Tag: 3.0.0_Beta_1~1077 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c402081386614192c3f6a6e58370d8155ddb276e;p=GitHub%2FWoltLab%2FWCF.git Fix order of Clipboard-related code for media dialog First `setup` the clipboard, then call `showEditor`. --- diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js b/wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js index d9d013dcb5..4d53faaadc 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js @@ -100,6 +100,53 @@ define( Clipboard.hideEditor('com.woltlab.wcf.media'); }, + /** + * Initializes the dialog when first loaded. + * + * @param {string} content dialog content + * @param {object} data AJAX request's response data + */ + _dialogInit: function(content, data) { + // store media data locally + var media = data.returnValues.media || { }; + for (var mediaId in media) { + if (objOwns(media, mediaId)) { + this._mediaData.set(~~mediaId, media[mediaId]); + } + } + + this._mediaManagerMediaList = elById('mediaManagerMediaList'); + + // store list items locally + var listItems = DomTraverse.childrenByTag(this._mediaManagerMediaList, 'LI'); + for (var i = 0, length = listItems.length; i < length; i++) { + var listItem = listItems[i]; + + this._media.set(~~elData(listItem, 'object-id'), listItem); + } + + if (Permission.get('admin.content.cms.canManageMedia')) { + new MediaUpload('mediaManagerMediaUploadButton', 'mediaManagerMediaList', { + 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)); + } + + this._search = new MediaManagerSearch(this); + + if (!listItems.length) { + this._search.hideSearch(); + } + + this._dialogShow(); + }, + /** * Returns all data to setup the media manager dialog. * @@ -114,7 +161,7 @@ define( title: this._options.dialogTitle }, source: { - after: this._initDialog.bind(this), + after: this._dialogInit.bind(this), data: { actionName: 'getManagementDialog', className: 'wcf\\data\\media\\MediaAction', @@ -131,6 +178,8 @@ define( * Is called if the media manager dialog is shown. */ _dialogShow: function() { + if (!this._mediaManagerMediaList) return; + // only show media clipboard if editor is open Clipboard.showEditor('com.woltlab.wcf.media'); }, @@ -178,51 +227,6 @@ define( } }, - /** - * Initializes the dialog when first loaded. - * - * @param {string} content dialog content - * @param {object} data AJAX request's response data - */ - _initDialog: function(content, data) { - // store media data locally - var media = data.returnValues.media || { }; - for (var mediaId in media) { - if (objOwns(media, mediaId)) { - this._mediaData.set(~~mediaId, media[mediaId]); - } - } - - this._mediaManagerMediaList = elById('mediaManagerMediaList'); - - // store list items locally - var listItems = DomTraverse.childrenByTag(this._mediaManagerMediaList, 'LI'); - for (var i = 0, length = listItems.length; i < length; i++) { - var listItem = listItems[i]; - - this._media.set(~~elData(listItem, 'object-id'), listItem); - } - - if (Permission.get('admin.content.cms.canManageMedia')) { - new MediaUpload('mediaManagerMediaUploadButton', 'mediaManagerMediaList', { - 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)); - } - - this._search = new MediaManagerSearch(this); - - if (!listItems.length) { - this._search.hideSearch(); - } - }, - /** * Sets the displayed media (after a search). *