Preserve the scroll position in styleGlobalValues when saving
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 15 Jun 2020 08:23:31 +0000 (10:23 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 15 Jun 2020 08:33:12 +0000 (10:33 +0200)
Closes #3267

wcfsetup/install/files/acp/templates/styleGlobalValues.tpl
wcfsetup/install/files/lib/acp/form/StyleGlobalValuesForm.class.php

index 0408d87e34e2161cd78d6c453a89ffec5ae3f1dd..51e53478cb67154ce4f32be80400e29dd2c145a0 100644 (file)
@@ -28,6 +28,7 @@
                        <dd>
                                <div dir="ltr">
                                        <textarea id="styles" rows="20" cols="40" name="styles" style="visibility: hidden">{$styles}</textarea>
+                                       <input class="codeMirrorScrollOffset" name="stylesScrollOffset" value="{$stylesScrollOffset}" type="hidden">
                                </div>
                        </dd>
                </dl>
index 491d76b578ea49d5ba958c3b8cedb543b5a60680..a86b2b551e1dc5415220dbc799f81f024f4a9fab 100644 (file)
@@ -26,6 +26,12 @@ class StyleGlobalValuesForm extends AbstractForm {
         * @var string
         */
        public $styles = '';
+
+       /**
+        * current scroll offset before submitting the form
+        * @var integer
+        */
+       public $stylesScrollOffset = 0;
        
        /**
         * @inheritDoc
@@ -36,6 +42,9 @@ class StyleGlobalValuesForm extends AbstractForm {
                if (isset($_POST['styles'])) {
                        $this->styles = StringUtil::unifyNewlines(StringUtil::trim($_POST['styles']));
                }
+               if (isset($_POST['stylesScrollOffset'])) {
+                       $this->stylesScrollOffset = intval($_POST['stylesScrollOffset']);
+               }
        }
        
        /**
@@ -84,7 +93,8 @@ class StyleGlobalValuesForm extends AbstractForm {
                parent::assignVariables();
                
                WCF::getTPL()->assign([
-                       'styles' => $this->styles
+                       'styles' => $this->styles,
+                       'stylesScrollOffset' => $this->stylesScrollOffset,
                ]);
        }
 }