2 * Initializes modules required for media clipboard.
4 * @author Matthias Schmidt
5 * @copyright 2001-2018 WoltLab GmbH
6 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7 * @module WoltLabSuite/Core/Media/Clipboard
16 'WoltLabSuite/Core/Controller/Clipboard',
17 'WoltLabSuite/Core/Media/Editor',
18 'WoltLabSuite/Core/Media/List/Upload'
33 if (!COMPILER_TARGET_DEFAULT
) {
34 var Fake = function() {};
37 _ajaxSetup: function() {},
38 _ajaxSuccess: function() {},
39 _clipboardAction: function() {},
40 _dialogSetup: function() {},
42 _setCategory: function() {}
47 var _clipboardObjectIds
= [];
51 * @exports WoltLabSuite/Core/Media/Clipboard
54 init: function(pageClassName
, hasMarkedItems
, mediaManager
) {
56 hasMarkedItems
: hasMarkedItems
,
57 pageClassName
: pageClassName
60 _mediaManager
= mediaManager
;
62 EventHandler
.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', this._clipboardAction
.bind(this));
66 * Returns the data used to setup the AJAX request object.
68 * @return {object} setup data
70 _ajaxSetup: function() {
73 className
: 'wcf\\data\\media\\MediaAction'
79 * Handles successful AJAX request.
81 * @param {object} data response data
83 _ajaxSuccess: function(data
) {
84 switch (data
.actionName
) {
85 case 'getSetCategoryDialog':
86 UiDialog
.open(this, data
.returnValues
.template
);
93 UiNotification
.show();
102 * Returns the data used to setup the dialog.
104 * @return {object} setup data
106 _dialogSetup: function() {
108 id
: 'mediaSetCategoryDialog',
110 onSetup: function(content
) {
111 elBySel('button', content
).addEventListener(WCF_CLICK_EVENT
, function(event
) {
112 event
.preventDefault();
114 this._setCategory(~~elBySel('select[name="categoryID"]', content
).value
);
116 event
.currentTarget
.disabled
= true;
119 title
: Language
.get('wcf.media.setCategory')
126 * Handles successful clipboard actions.
128 * @param {object} actionData
130 _clipboardAction: function(actionData
) {
131 var mediaIds
= actionData
.data
.parameters
.objectIDs
;
133 switch (actionData
.data
.actionName
) {
134 case 'com.woltlab.wcf.media.delete':
135 // only consider events if the action has been executed
136 if (actionData
.responseData
!== null) {
137 _mediaManager
.clipboardDeleteMedia(mediaIds
);
142 case 'com.woltlab.wcf.media.insert':
143 _mediaManager
.clipboardInsertMedia(mediaIds
);
147 case 'com.woltlab.wcf.media.setCategory':
148 _clipboardObjectIds
= mediaIds
;
151 actionName
: 'getSetCategoryDialog'
159 * Sets the category of the marked media files.
161 * @param {int} categoryID selected category id
163 _setCategory: function(categoryID
) {
165 actionName
: 'setCategory',
166 objectIDs
: _clipboardObjectIds
,
168 categoryID
: categoryID