var _callbackItem = null;
var _callbackUnmarkAll = null;
+ var _addPageOverlayActiveClass = false;
+
/**
* Clipboard API
*
* @param {object<string, *>} options initialization options
*/
setup: function(options) {
- _callbackCheckbox = this._mark.bind(this);
- _callbackItem = this._executeAction.bind(this);
- _callbackUnmarkAll = this._unmarkAll.bind(this);
- _options = Core.extend({
- hasMarkedItems: false,
- pageClassName: '',
- pageObjectId: 0
- }, options);
-
- if (!_options.pageClassName) {
+ if (!options.pageClassName) {
throw new Error("Expected a non-empty string for parameter 'pageClassName'.");
}
+ if (_callbackCheckbox === null) {
+ _callbackCheckbox = this._mark.bind(this);
+ _callbackItem = this._executeAction.bind(this);
+ _callbackUnmarkAll = this._unmarkAll.bind(this);
+
+ _options = Core.extend({
+ hasMarkedItems: false,
+ pageClassNames: [options.pageClassName],
+ pageObjectId: 0
+ }, options);
+
+ delete _options.pageClassName;
+ }
+ else {
+ if (options.pageObjectId) {
+ throw new Error("Cannot load secondary clipboard with page object id set.");
+ }
+
+ _options.pageClassNames.push(options.pageClassName);
+ }
+
this._initContainers();
if (_options.hasMarkedItems && _elements.length) {
Ajax.api(this, {
actionName: 'getMarkedItems',
parameters: {
- pageClassName: _options.pageClassName,
+ pageClassNames: _options.pageClassNames,
pageObjectID: _options.pageObjectId
}
});
Ajax.api(this, {
actionName: (isMarked ? 'mark' : 'unmark'),
parameters: {
- pageClassName: _options.pageClassName,
+ pageClassNames: _options.pageClassNames,
pageObjectID: _options.pageObjectId,
objectIDs: objectIds,
objectType: type
parent.classList[(markAll ? 'add' : 'remove')]('jsMarked');
}
}
+ },
+
+ /**
+ * Hides the clipboard editor for the given object type.
+ *
+ * @param {string} objectType
+ */
+ hideEditor: function(objectType) {
+ UiPageAction.remove('wcfClipboard-' + objectType);
+
+ if (_addPageOverlayActiveClass) {
+ _addPageOverlayActiveClass = false;
+
+ document.documentElement.classList.add('pageOverlayActive');
+ }
+ },
+
+ /**
+ * Shows the clipboard editor for the given object type.
+ *
+ * @param {string} objectType
+ */
+ showEditor: function(objectType) {
+ this._loadMarkedItems();
+
+ if (document.documentElement.classList.contains('pageOverlayActive')) {
+ document.documentElement.classList.remove('pageOverlayActive');
+
+ _addPageOverlayActiveClass = true;
+ }
}
};
});
}
},
+ /**
+ * Is called if the media manager dialog is closed.
+ */
+ _dialogClose: function() {
+ // only show media clipboard if editor is open
+ Clipboard.hideEditor('com.woltlab.wcf.media');
+ },
+
/**
* Returns all data to setup the media manager dialog.
*
return {
id: 'mediaManager',
options: {
+ onClose: this._dialogClose.bind(this),
+ onShow: this._dialogShow.bind(this),
title: this._options.dialogTitle
},
source: {
};
},
+ /**
+ * Is called if the media manager dialog is shown.
+ */
+ _dialogShow: function() {
+ // only show media clipboard if editor is open
+ Clipboard.showEditor('com.woltlab.wcf.media');
+ },
+
/**
* Opens the media editor for a media file.
*
/**
* Returns items for clipboard editor.
*
- * @param string $page
- * @param integer $pageObjectID
+ * @param string|string[] $page
+ * @param integer $pageObjectID
* @return mixed[][]
* @throws SystemException
*/
public function getEditorItems($page, $pageObjectID) {
- $this->pageObjectID = 0;
+ $pages = $page;
+ if (!is_array($pages)) {
+ $pages = [$page];
+ }
- // ignore unknown pages
- if (!isset($this->pageCache[$page])) return null;
+ $this->pageObjectID = 0;
// get objects
$this->loadMarkedItems();
// fetch action ids
$this->loadActionCache();
$actionIDs = [];
- foreach ($this->pageCache[$page] as $actionID) {
- if (isset($this->actionCache[$actionID])) {
- $actionIDs[] = $actionID;
+ foreach ($pages as $page) {
+ foreach ($this->pageCache[$page] as $actionID) {
+ if (isset($this->actionCache[$actionID])) {
+ $actionIDs[] = $actionID;
+ }
}
}
$actionIDs = array_unique($actionIDs);