Added button to insert all attachments at once (position not clear yet)
authorAlexander Ebert <ebert@woltlab.com>
Thu, 22 May 2014 23:26:08 +0000 (01:26 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 22 May 2014 23:26:08 +0000 (01:26 +0200)
com.woltlab.wcf/templates/messageFormAttachments.tpl
com.woltlab.wcf/templates/wysiwyg.tpl
wcfsetup/install/files/js/WCF.Attachment.js
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 9ca15aa3667338d2b0ebf68ace9428b649c75614..70586ef8cea7f7d0ec0ce48a044606934876bbe5 100644 (file)
@@ -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}'
                });
                
index 84705c8af2f32ea61ec73f3e0f3bfb3e54d0a15d..d8c30281caa88b5a2ab77d18fe573b7c5a072838 100644 (file)
@@ -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}'
                });
index 1e8bbd84f0552b15b92de43b6cf7051d88e27d72..0dc4e26521970e11ca1ba96dd5927dba6c9c9591 100644 (file)
@@ -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 = $('<p class="button">' + WCF.Language.get('wcf.attachment.insertAll') + '</p>').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()
         */
index 3209341e1debeed6b8e14b13f3afea6d6050fba8..5e2b6d8ad982c46752384984b8e6b611f002e7ec 100644 (file)
@@ -1492,6 +1492,7 @@ Klicken Sie hier, um sich mit Ihrem neuen Kennwort anzumelden: {link controller=
 Maximale Dateigröße: {@$attachmentHandler->getMaxSize()|filesize}<br />
 Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExtensions()}]]></item>
                <item name="wcf.attachment.insert"><![CDATA[In Text einfügen]]></item>
+               <item name="wcf.attachment.insertAll"><![CDATA[Alle einfügen]]></item>
                <item name="wcf.attachment.delete.sure"><![CDATA[Wollen Sie den Dateianhang wirklich löschen?]]></item>
                <item name="wcf.attachment.filename"><![CDATA[Dateiname]]></item>
                <item name="wcf.attachment.uploadTime"><![CDATA[Hochgeladen]]></item>
index 98e98ddad85ab2dc81832d339f0f719e3e0bd4cc..eb778f0ca5eefc1c8e54e47e5f82a8b2b7514685 100644 (file)
@@ -1463,6 +1463,7 @@ Login with your new password: {link controller='Login' isEmail=true}{/link}]]></
 Maximum file size: {@$attachmentHandler->getMaxSize()|filesize}<br />
 Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensions()}]]></item>
                <item name="wcf.attachment.insert"><![CDATA[Insert into message]]></item>
+               <item name="wcf.attachment.insertAll"><![CDATA[Insert All]]></item>
                <item name="wcf.attachment.filename"><![CDATA[Filename]]></item>
                <item name="wcf.attachment.uploadTime"><![CDATA[Upload Time]]></item>
                <item name="wcf.attachment.filesize"><![CDATA[Size]]></item>