Fixed a few issues related to quotes
authorAlexander Ebert <ebert@woltlab.com>
Tue, 26 Aug 2014 17:57:13 +0000 (19:57 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 26 Aug 2014 17:57:13 +0000 (19:57 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wbbcode.js
wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js

index 6807649af6aa2bb3bc05072cec69f007129159e7..a299afe43369a2a374c1bdc44e0bbb5580cb084b 100644 (file)
@@ -616,6 +616,9 @@ RedactorPlugins.wbbcode = {
                data = data.replace(/(\[quote.*?\])/gi, '$1\n');
                data = data.replace(/(\[\/quote\])/gi, '\n$1');
                
+               // drop trailing line breaks
+               data = data.replace(/\n*$/, '');
+               
                // convert line breaks into <p></p> or empty lines to <p><br></p>
                var $tmp = data.split("\n");
                data = '';
@@ -689,14 +692,18 @@ RedactorPlugins.wbbcode = {
                                                                + '<a class="redactorQuoteEdit"></a>'
                                                        + '</header>';
                                        
-                                       var $lines = innerContent.split('\n');
+                                       innerContent = $.trim(innerContent);
                                        var $tmp = '';
-                                       for (var $i = 0; $i < $lines.length; $i++) {
-                                               $tmp += '<div>' + $lines[$i] + '</div>';
-                                       }
                                        
-                                       if (!$tmp) {
-                                               $tmp = '<div>' + this.opts.invisibleSpace + '</div>';
+                                       if (innerContent.length) {
+                                               var $lines = innerContent.split('\n');
+                                               
+                                               for (var $i = 0; $i < $lines.length; $i++) {
+                                                       $tmp += '<div>' + $lines[$i] + '</div>';
+                                               }
+                                       }
+                                       else {
+                                               $tmp = '<div>' + self.opts.invisibleSpace + '</div>';
                                        }
                                        
                                        $quote += $tmp;
@@ -1030,6 +1037,8 @@ RedactorPlugins.wbbcode = {
                        
                        this.selectionStart($container[0]);
                        this._observeQuotes();
+                       
+                       this.$toolbar.find('a.re-__wcf_quote').addClass('redactor_button_disabled');
                }
                else {
                        var $bbcode = '[quote]';
index 281513cc416e68f1f8c33a0e4656acf01dddd831..d10659901c21284c010cf0d61ecd82e20c2869b4 100644 (file)
@@ -166,7 +166,7 @@ RedactorPlugins.wmonkeypatch = {
                if (parent && parent.closest('blockquote.quoteBox', this.$editor.get()[0]).length != 0) {
                        this.$toolbar.find('a.re-__wcf_quote').addClass('redactor_button_disabled');
                }
-               else {
+               else if (this.opts.visual) {
                        this.$toolbar.find('a.re-__wcf_quote').removeClass('redactor_button_disabled');
                }
        },