* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @module WoltLab/WCF/Media/Manager/Select
*/
-define(['Core', 'Dom/Traverse', 'Language', 'ObjectMap', 'Ui/Dialog', 'WoltLab/WCF/Media/Manager/Base'], function(Core, DomTraverse, Language, ObjectMap, UiDialog, MediaManagerBase) {
+define(['Core', 'Dom/Traverse', 'Dom/Util', 'Language', 'ObjectMap', 'Ui/Dialog', 'WoltLab/WCF/Media/Manager/Base'], function(Core, DomTraverse, DomUtil, Language, ObjectMap, UiDialog, MediaManagerBase) {
"use strict";
/**
this._buttons[i].addEventListener(WCF_CLICK_EVENT, this._click.bind(this));
this._storeElements.set(button, storeElement);
+
+ // add remove button
+ var removeButton = elCreate('p');
+ removeButton.className = 'button';
+ DomUtil.insertAfter(removeButton, button);
+
+ var icon = elCreate('span');
+ icon.className = 'icon icon16 fa-times';
+ removeButton.appendChild(icon);
+
+ if (!storeElement.value) elHide(removeButton);
+ removeButton.addEventListener(WCF_CLICK_EVENT, this._removeMedia.bind(this));
}
}
}
}
}
+ // show remove button
+ elShow(this._activeButton.nextElementSibling);
+
UiDialog.close('mediaManager');
},
* @see WoltLab/WCF/Media/Manager/Base#_click
*/
_click: function(event) {
+ event.preventDefault();
this._activeButton = event.currentTarget;
MediaManagerSelect._super.prototype._click.call(this, event);
elData(icon, 'object-id', media.mediaID);
elAttr(icon, 'title', Language.get('wcf.media.button.choose'));
a.appendChild(icon);
+ },
+
+ /**
+ * Handles clicking on the remove button.
+ *
+ * @param {Event} event click event
+ */
+ _removeMedia: function(event) {
+ event.preventDefault();
+
+ var removeButton = event.currentTarget;
+ elHide(removeButton);
+
+ var button = removeButton.previousElementSibling;
+ elById(elData(button, 'store')).value = 0;
+ var display = elData(button, 'display');
+ if (display) {
+ var displayElement = elById(display);
+ if (displayElement) {
+ displayElement.innerHTML = '';
+ }
+ }
}
});