-<div class="inputAddon" id="mediaManagerSearch">
- <input type="text" id="mediaManagerSearchField" placeholder="{lang}wcf.media.search.placeholder{/lang}">
+<div class="inputAddon mediaManagerSearch">
+ <input type="text" class="mediaManagerSearchField" placeholder="{lang}wcf.media.search.placeholder{/lang}">
<span class="inputSuffix">
- <span id="mediaManagerSearchCancelButton" class="icon icon16 fa-times pointer jsTooltip" title="{lang}wcf.media.search.cancel{/lang}"></span>
+ <span class="icon icon16 fa-times mediaManagerSearchCancelButton pointer jsTooltip" title="{lang}wcf.media.search.cancel{/lang}"></span>
</span>
</div>
{if $__wcf->session->getPermission('admin.content.cms.canManageMedia')}
- <div id="mediaManagerMediaUploadButton"></div>
+ <div class="mediaManagerMediaUploadButton"></div>
{/if}
<div class="jsClipboardContainer" data-type="com.woltlab.wcf.media">
<input type="checkbox" class="jsClipboardMarkAll" style="display: none;">
- <ul id="mediaManagerMediaList">
+ <ul class="mediaManagerMediaList">
{include file='mediaListItems'}
</ul>
</div>
-<div class="inputAddon" id="mediaManagerSearch">
- <input type="text" id="mediaManagerSearchField" placeholder="{lang}wcf.media.search.placeholder{/lang}">
+<div class="inputAddon mediaManagerSearch">
+ <input type="text" class="mediaManagerSearchField" placeholder="{lang}wcf.media.search.placeholder{/lang}">
<span class="inputSuffix">
- <span id="mediaManagerSearchCancelButton" class="icon icon16 fa-times pointer jsTooltip" title="{lang}wcf.media.search.cancel{/lang}"></span>
+ <span class="icon icon16 fa-times mediaManagerSearchCancelButton pointer jsTooltip" title="{lang}wcf.media.search.cancel{/lang}"></span>
</span>
</div>
{if $__wcf->session->getPermission('admin.content.cms.canManageMedia')}
- <div id="mediaManagerMediaUploadButton"></div>
+ <div class="mediaManagerMediaUploadButton"></div>
{/if}
<div class="jsClipboardContainer" data-type="com.woltlab.wcf.media">
<input type="checkbox" class="jsClipboardMarkAll" style="display: none;">
- <ul id="mediaManagerMediaList">
+ <ul class="mediaManagerMediaList">
{include file='mediaListItems'}
</ul>
</div>
{
"use strict";
+ var _mediaManagerCounter = 0;
+
/**
* @constructor
*/
minSearchLength: 3
}, options);
+ this._id = 'mediaManager' + _mediaManagerCounter++;
this._listItems = new Dictionary();
this._media = new Dictionary();
this._mediaCache = null;
this._mediaManagerMediaList = null;
this._search = null;
this._forceClipboard = false;
+ this._hadInitiallyMarkedItems = false;
if (Permission.get('admin.content.cms.canManageMedia')) {
this._mediaEditor = new MediaEditor(this);
}
}
- 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._listItems.set(~~elData(listItem, 'object-id'), listItem);
- }
-
- if (Permission.get('admin.content.cms.canManageMedia')) {
- new MediaUpload('mediaManagerMediaUploadButton', 'mediaManagerMediaList', {
- mediaManager: this
- });
-
- var deleteAction = new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.mediaFile');
- deleteAction._didTriggerEffect = function(element) {
- this.removeMedia(elData(element[0], 'object-id'), true);
- }.bind(this);
- }
-
- if (Permission.get('admin.content.cms.canManageMedia') || this._forceClipboard) {
- EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', this._clipboardAction.bind(this));
-
- Clipboard.setup({
- hasMarkedItems: data.returnValues.hasMarkedItems ? true : false,
- pageClassName: 'menuManagerDialog-' + this.getMode()
- });
- }
- else {
- this._removeClipboardCheckboxes();
- }
-
- this._search = new MediaManagerSearch(this);
-
- if (!listItems.length) {
- this._search.hideSearch();
- }
-
- this._dialogShow();
+ this._hadInitiallyMarkedItems = data.returnValues.hasMarkedItems;
},
/**
*/
_dialogSetup: function() {
return {
- id: 'mediaManager',
+ id: this._id,
options: {
onClose: this._dialogClose.bind(this),
onShow: this._dialogShow.bind(this),
* Is called if the media manager dialog is shown.
*/
_dialogShow: function() {
- if (!this._mediaManagerMediaList) return;
+ if (!this._mediaManagerMediaList) {
+ this._mediaManagerMediaList = elByClass('mediaManagerMediaList', UiDialog.getDialog(this).dialog)[0];
+
+ // 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._listItems.set(~~elData(listItem, 'object-id'), listItem);
+ }
+
+ if (Permission.get('admin.content.cms.canManageMedia')) {
+ var uploadButton = elByClass('mediaManagerMediaUploadButton', UiDialog.getDialog(this).dialog)[0];
+ new MediaUpload(DomUtil.identify(uploadButton), DomUtil.identify(this._mediaManagerMediaList), {
+ mediaManager: this
+ });
+
+ var deleteAction = new WCF.Action.Delete('wcf\\data\\media\\MediaAction', '.mediaFile');
+ deleteAction._didTriggerEffect = function(element) {
+ this.removeMedia(elData(element[0], 'object-id'), true);
+ }.bind(this);
+ }
+
+ if (Permission.get('admin.content.cms.canManageMedia') || this._forceClipboard) {
+ EventHandler.add('com.woltlab.wcf.clipboard', 'com.woltlab.wcf.media', this._clipboardAction.bind(this));
+
+ Clipboard.setup({
+ hasMarkedItems: this._hadInitiallyMarkedItems ? true : false,
+ pageClassName: 'menuManagerDialog-' + this.getMode()
+ });
+ }
+ else {
+ this._removeClipboardCheckboxes();
+ }
+
+ this._search = new MediaManagerSearch(this);
+
+ if (!listItems.length) {
+ this._search.hideSearch();
+ }
+ }
// only show media clipboard if editor is open
if (Permission.get('admin.content.cms.canManageMedia') || this._forceClipboard) {
throw new Error("You are not allowed to edit media files.");
}
- UiDialog.close('mediaManager');
+ UiDialog.close(this);
this._mediaEditor.edit(this._media.get(~~elData(event.currentTarget, 'object-id')));
},
}
},
+ /**
+ * Returns the media manager dialog element.
+ *
+ * @return {Element} media manager dialog
+ */
+ getDialog: function() {
+ return UiDialog.getDialog(this).dialog;
+ },
+
/**
* Returns the mode of the media manager.
*
this._mediaManager = mediaManager;
this._searchMode = false;
- this._input = elById('mediaManagerSearchField');
+ this._searchContainer = elByClass('mediaManagerSearch', mediaManager.getDialog())[0];
+ this._input = elByClass('mediaManagerSearchField', mediaManager.getDialog())[0];
this._input.addEventListener('keypress', this._keyPress.bind(this));
- this._cancelButton = elById('mediaManagerSearchCancelButton');
+ this._cancelButton = elByClass('mediaManagerSearchCancelButton', mediaManager.getDialog())[0];
this._cancelButton.addEventListener(WCF_CLICK_EVENT, this._cancelSearch.bind(this));
}
MediaManagerSearch.prototype = {
* Hides the media search.
*/
hideSearch: function() {
- elHide(elById('mediaManagerSearch'));
+ elHide(this._searchContainer);
},
/**
* Shows the media search.
*/
showSearch: function() {
- elShow(elById('mediaManagerSearch'));
+ elShow(this._searchContainer);
}
};