Reset editor state on reply
authorAlexander Ebert <ebert@woltlab.com>
Sun, 18 Sep 2016 11:33:45 +0000 (13:33 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 18 Sep 2016 11:33:50 +0000 (13:33 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabButton.js
wcfsetup/install/files/js/WCF.Message.js

index 73354b3d4d31b1094f3937a2a4ef5c66fe028afb..617ffa7c58654a3712612be116626359fa4437cb 100644 (file)
@@ -160,9 +160,10 @@ $.Redactor.prototype.WoltLabButton = function() {
                        elData(_toggleButton, 'show-on-mobile', true);
                        
                        var icon = _toggleButton.children[0].children[0];
-                       
-                       _toggleButton.children[0].addEventListener('mousedown', (function (event) {
-                               event.preventDefault();
+                       var toggle = (function (event) {
+                               if (event instanceof Event) {
+                                       event.preventDefault();
+                               }
                                
                                if (this.$toolbar[0].classList.toggle('redactorToolbarOverride')) {
                                        // this prevents mobile browser from refocusing another element
@@ -173,9 +174,17 @@ $.Redactor.prototype.WoltLabButton = function() {
                                
                                icon.classList.toggle('fa-caret-down');
                                icon.classList.toggle('fa-caret-up');
-                       }).bind(this));
+                       }).bind(this);
+                       
+                       _toggleButton.children[0].addEventListener('mousedown', toggle);
                        
                        this.$toolbar[0].appendChild(_toggleButton);
+                       
+                       WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'reset_' + this.$element[0].id, (function () {
+                               if (this.$toolbar[0].classList.contains('redactorToolbarOverride')) {
+                                       toggle();
+                               }
+                       }).bind(this));
                }
        };
 };
index 18219151d1dfd66be5fb7985b128f4cdbc426227..d82db7f4162f5b76a95deb91b9ec0e3fdc07d0d4 100644 (file)
@@ -2114,6 +2114,16 @@ $.widget('wcf.messageTabMenu', {
                if ($collapsible !== undefined) {
                        this.options.collapsible = $collapsible;
                }
+               
+               var wysiwygContainerId = elData(this.element[0], 'wysiwyg-container-id');
+               if (wysiwygContainerId) {
+                       WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'reset_' + wysiwygContainerId, (function () {
+                               for (var i = 0, length = this._tabs.length; i < length; i++) {
+                                       this._tabs[i].container.removeClass('active');
+                                       this._tabs[i].tab.removeClass('active');
+                               }
+                       }).bind(this));
+               }
        },
        
        /**