1 if (!RedactorPlugins
) var RedactorPlugins
= {};
4 * Provides file uploads for Redactor.
6 * @author Alexander Ebert
7 * @copyright 2001-2014 WoltLab GmbH
8 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
10 RedactorPlugins
.wupload
= {
12 * attachments container object
15 _attachmentsContainer
: null,
18 * Initializes the RedactorPlugins.wupload plugin.
22 this.buttonReplace('upload', 'upload', 'Upload', function() { self
._attachmentsContainer
.toggle(); });
23 this.buttonAwesome('upload', 'fa-upload');
25 this._initAttachments();
29 * Initializes the attachments user interface.
31 _initAttachments: function() {
32 this._attachmentsContainer
= $('<div class="redactorAttachmentContainer" />').hide().appendTo(this.$box
);
33 var $attachmentList
= $('<ul class="formAttachmentList clearfix" />').hide().appendTo(this._attachmentsContainer
);
34 $('<dl class="wide"><dt></dt><dd><div data-max-size="{@$attachmentHandler->getMaxSize()}"></div><small>' + WCF
.String
.unescapeHTML(WCF
.Language
.get('wcf.attachment.upload.limits')) + '</small></dd></dl>').appendTo(this._attachmentsContainer
);
36 var $options
= this.getOption('wattachment');
37 if ($options
.attachments
.length
) {
38 for (var $i
= 0; $i
< $options
.attachments
.length
; $i
++) {
39 var $attachment
= $options
.attachments
[$i
];
40 var $listItem
= $('<li class="box48" />');
41 if ($attachment
.tinyThumbnailUrl
) {
42 $('<img src="' + $attachment
.tinyThumbnailUrl
+ '" alt="" class="attachmentTinyThumbnail" />').appendTo($listItem
);
45 $('<span class="icon icon48 icon-paper-clip" />').appendTo($listItem
);
48 var $div
= $('<div />').appendTo($listItem
);
49 $('<div><p><a href="' + $attachment
.url
+ '"' + ($attachment
.isImage
? ' title="' + $attachment
.filename
+ '" class="jsImageViewer"' : '') + '>' + $attachment
.filename
+ '</a></p></div>').appendTo($div
);
50 var $list
= $('<ul />').appendTo($div
);
51 $('<li><span class="icon icon16 icon-remove pointer jsTooltip jsDeleteButton " title="' + WCF
.Language
.get('wcf.global.button.delete') + '" data-object-id="' + $attachment
.attachmentID
+ '" data-confirm-message="' + WCF
.Language
.get('wcf.attachment.delete.sure') + '"></span></li>').appendTo($list
);
52 $('<li><span class="icon icon16 icon-paste pointer jsTooltip jsButtonInsertAttachment" title="' + WCF
.Language
.get('wcf.attachment.insert') + '" data-object-id="' + $attachment
.attachmentID
+ '"></span></li>').appendTo($list
);
54 $listItem
.appendTo($attachmentList
);
56 this._attachmentsContainer
.show();
57 $attachmentList
.show();
61 new WCF
.Attachment
.Upload(this._attachmentsContainer
.find('> dl > dd > div'), this._attachmentsContainer
.children('ul'), $options
.objectType
, $options
.objectID
, $options
.tmpHash
, $options
.parentObjectID
, $options
.maxCount
, this.$source
.wcfIdentify());
62 new WCF
.Action
.Delete('wcf\\data\\attachment\\AttachmentAction', '.formAttachmentList > li');