Fixed scrolling when setting the editor text programatically
authorAlexander Ebert <ebert@woltlab.com>
Wed, 17 Sep 2014 13:28:44 +0000 (15:28 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 17 Sep 2014 13:28:44 +0000 (15:28 +0200)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wutil.js

index 0ab965bee3a8f30ba4549d7edda234406b591e8d..bc5612dacc91d9b9dd3dc95c552d3ca4f21175d2 100644 (file)
@@ -445,6 +445,7 @@ RedactorPlugins.wutil = {
         */
        replaceText: function(value) {
                var $wasInWysiwygMode = false;
+               var $offsetTop = $(document).scrollTop();
                if (this.inWysiwygMode()) {
                        this.toggle();
                        $wasInWysiwygMode = true;
@@ -454,6 +455,9 @@ RedactorPlugins.wutil = {
                
                if ($wasInWysiwygMode) {
                        this.toggle();
+                       
+                       // restore scrolling since editor receives the focus
+                       $(document).scrollTop($offsetTop);
                }
        }
 };