}
},
+ /**
+ * Removes an attachment from WYSIWYG view.
+ *
+ * @param integer attachmentID
+ */
+ removeAttachment: function(attachmentID) {
+ if (!this.opts.visual) {
+ // we're not going to mess with the code view
+ return;
+ }
+
+ this.$editor.find('img.redactorEmbeddedAttachment').each(function(index, attachment) {
+ var $attachment = $(attachment);
+ if ($attachment.data('attachmentID') == attachmentID) {
+ $attachment.remove();
+ }
+ });
+ },
+
/**
* Returns a list of attachments representing an image.
*
*/
init: function(buttonSelector, fileListSelector, objectType, objectID, tmpHash, parentObjectID, maxUploads, wysiwygContainerID) {
this._super(buttonSelector, fileListSelector, 'wcf\\data\\attachment\\AttachmentAction', { multiple: true, maxUploads: maxUploads });
- console.debug(wysiwygContainerID);
+
this._autoInsert = [ ];
this._objectType = objectType;
this._objectID = objectID;
this._fileListSelector.find('.jsButtonAttachmentInsertThumbnail').click($.proxy(this._insert, this));
this._fileListSelector.find('.jsButtonAttachmentInsertFull').click($.proxy(this._insert, this));
- WCF.DOMNodeRemovedHandler.addCallback('WCF.Attachment.Upload', $.proxy(this._removeLimitError, this));
+ //WCF.DOMNodeRemovedHandler.addCallback('WCF.Attachment.Upload', $.proxy(this._removeLimitError, this));
+ WCF.System.Event.addListener('com.woltlab.wcf.action.delete', 'attachment_' + this._wysiwygContainerID, $.proxy(this._removeLimitError, this));
this._makeSortable();
/**
* Removes the limit error message.
*
- * @param object event
+ * @param object data
*/
- _removeLimitError: function(event) {
- var $target = $(event.target);
- if ($target.is('li.box48') && $target.parent().wcfIdentify() === this._fileListSelector.wcfIdentify()) {
- this._buttonSelector.next('small.innerError').remove();
- }
-
+ _removeLimitError: function(data) {
var $listItems = this._fileListSelector.children('li');
if (!$listItems.filter(':not(.uploadFailed)').length) {
this._insertAllButton.hide();
this._fileListSelector.wcfBlindOut();
}).bind(this), 250);
}
+
+ if (this._wysiwygContainerID) {
+ $('#' + this._wysiwygContainerID).redactor('wbbcode.removeAttachment', data.button.data('objectID'));
+ }
},
/**
// init buttons
var $buttonList = $li.find('ul').addClass('buttonGroup');
- var $deleteButton = $('<li><span class="button small jsDeleteButton" data-object-id="'+data.returnValues.attachments[$internalFileID]['attachmentID']+'" data-confirm-message="'+WCF.Language.get('wcf.attachment.delete.sure')+'">' + WCF.Language.get('wcf.global.button.delete') + '</span></li>');
+ var $deleteButton = $('<li><span class="button small jsDeleteButton" data-object-id="'+data.returnValues.attachments[$internalFileID]['attachmentID']+'" data-confirm-message="'+WCF.Language.get('wcf.attachment.delete.sure')+'" data-event-name="attachment_' + this._wysiwygContainerID + '">' + WCF.Language.get('wcf.global.button.delete') + '</span></li>');
$buttonList.append($deleteButton);
$li.data('objectID', data.returnValues.attachments[$internalFileID].attachmentID);
triggerEffect: function(objectIDs) {
for (var $index in this._containers) {
var $container = $('#' + this._containers[$index]);
- if (WCF.inArray($container.find(this._buttonSelector).data('objectID'), objectIDs)) {
+ var $button = $container.find(this._buttonSelector);
+ if (WCF.inArray($button.data('objectID'), objectIDs)) {
var self = this;
$container.wcfBlindOut('up',function() {
- $(this).remove();
- self._containers.splice(self._containers.indexOf($(this).wcfIdentify()), 1);
- self._didTriggerEffect($(this));
+ var $container = $(this).remove();
+ self._containers.splice(self._containers.indexOf($container.wcfIdentify()), 1);
+ self._didTriggerEffect($container);
+
+ if ($button.data('eventName')) {
+ WCF.System.Event.fireEvent('com.woltlab.wcf.action.delete', $button.data('eventName'), {
+ button: $button,
+ container: $container
+ });
+ }
});
}
}