From: Alexander Ebert Date: Thu, 22 May 2014 23:26:08 +0000 (+0200) Subject: Added button to insert all attachments at once (position not clear yet) X-Git-Tag: 2.1.0_Alpha_1~806^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5b2bda56c2f7a1eb5d60b146b93cfaacac66a345;p=GitHub%2FWoltLab%2FWCF.git Added button to insert all attachments at once (position not clear yet) --- diff --git a/com.woltlab.wcf/templates/messageFormAttachments.tpl b/com.woltlab.wcf/templates/messageFormAttachments.tpl index 9ca15aa366..70586ef8ce 100644 --- a/com.woltlab.wcf/templates/messageFormAttachments.tpl +++ b/com.woltlab.wcf/templates/messageFormAttachments.tpl @@ -46,6 +46,7 @@ 'wcf.attachment.upload.error.uploadFailed': '{lang}wcf.attachment.upload.error.uploadFailed{/lang}', 'wcf.global.button.upload': '{lang}wcf.global.button.upload{/lang}', 'wcf.attachment.insert': '{lang}wcf.attachment.insert{/lang}', + 'wcf.attachment.insertAll': '{lang}wcf.attachment.insertAll{/lang}', 'wcf.attachment.delete.sure': '{lang}wcf.attachment.delete.sure{/lang}' }); diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index 84705c8af2..d8c30281ca 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -20,6 +20,7 @@ $(function() { 'wcf.attachment.upload.error.uploadFailed': '{lang}wcf.attachment.upload.error.uploadFailed{/lang}', 'wcf.global.button.upload': '{lang}wcf.global.button.upload{/lang}', 'wcf.attachment.insert': '{lang}wcf.attachment.insert{/lang}', + 'wcf.attachment.insertAll': '{lang}wcf.attachment.insertAll{/lang}', 'wcf.attachment.delete.sure': '{lang}wcf.attachment.delete.sure{/lang}', 'wcf.attachment.upload.limits': '{'wcf.attachment.upload.limits'|language|encodeJS}' }); diff --git a/wcfsetup/install/files/js/WCF.Attachment.js b/wcfsetup/install/files/js/WCF.Attachment.js index 1e8bbd84f0..0dc4e26521 100644 --- a/wcfsetup/install/files/js/WCF.Attachment.js +++ b/wcfsetup/install/files/js/WCF.Attachment.js @@ -9,6 +9,12 @@ WCF.Attachment = {}; * @see WCF.Upload */ WCF.Attachment.Upload = WCF.Upload.extend({ + /** + * reference to 'Insert All' button + * @var jQuery + */ + _insertAllButton: null, + /** * object type of the object the uploaded attachments belong to * @var string @@ -57,6 +63,9 @@ WCF.Attachment.Upload = WCF.Upload.extend({ WCF.DOMNodeRemovedHandler.addCallback('WCF.Attachment.Upload', $.proxy(this._removeLimitError, this)); this._makeSortable(); + + this._insertAllButton = $('

' + WCF.Language.get('wcf.attachment.insertAll') + '

').appendTo(this._buttonSelector); + this._insertAllButton.click($.proxy(this._insertAll, this)); }, /** @@ -241,30 +250,26 @@ WCF.Attachment.Upload = WCF.Upload.extend({ * Inserts an attachment into WYSIWYG editor contents. * * @param object event + * @param integer attachmentID */ - _insert: function(event) { - var $attachmentID = $(event.currentTarget).data('objectID'); + _insert: function(event, attachmentID) { + var $attachmentID = (event === null) ? attachmentID : $(event.currentTarget).data('objectID'); var $bbcode = '[attach=' + $attachmentID + '][/attach]'; - var $ckEditor = ($.browser.mobile) ? null : $('#' + this._wysiwygContainerID).ckeditorGet(); - if ($ckEditor !== null && $ckEditor.mode === 'wysiwyg') { - // in design mode - $ckEditor.insertText($bbcode); - } - else { - // in source mode - var $textarea = ($.browser.mobile) ? $('#' + this._wysiwygContainerID) : $('#' + this._wysiwygContainerID).next('.cke_editor_text').find('textarea'); - var $value = $textarea.val(); - if ($value.length == 0) { - $textarea.val($bbcode); - } - else { - var $position = $textarea.getCaret(); - $textarea.val( $value.substr(0, $position) + $bbcode + $value.substr($position) ); - } + if ($.browser.redactor) { + $('#' + this._wysiwygContainerID).redactor('insertDynamic', $bbcode); } }, + /** + * Inserts all attachments at once. + */ + _insertAll: function() { + this._fileListSelector.children('li:not(.uploadFailed)').each($.proxy(function(index, attachment) { + this._insert(null, $(attachment).data('objectID')); + }, this)); + }, + /** * @see WCF.Upload._error() */ diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 3209341e1d..5e2b6d8ad9 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1492,6 +1492,7 @@ Klicken Sie hier, um sich mit Ihrem neuen Kennwort anzumelden: {link controller= Maximale Dateigröße: {@$attachmentHandler->getMaxSize()|filesize}
Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExtensions()}]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 98e98ddad8..eb778f0ca5 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1463,6 +1463,7 @@ Login with your new password: {link controller='Login' isEmail=true}{/link}]]>getMaxSize()|filesize}
Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensions()}]]> +