From ffc8209ae30697fdccede12353dfa7f7f5aebffc Mon Sep 17 00:00:00 2001 From: Tom Gilder Date: Wed, 26 Oct 2005 10:59:44 +0000 Subject: [PATCH] (*fanfare*) added scripting to save the position of the edit box scrollbar on preview --- includes/EditPage.php | 8 ++++++-- skins/common/wikibits.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 8e22eb036e..f8730411ab 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -318,6 +318,9 @@ class EditPage { $this->edittime = $request->getVal( 'wpEdittime' ); $this->starttime = $request->getVal( 'wpStarttime' ); + + $this->scrolltop = htmlentities( $request->getVal( 'wpScrolltop' ) ); + if( is_null( $this->edittime ) ) { # If the form is incomplete, force to preview. wfDebug( "$fname: Form data appears to be incomplete\n" ); @@ -844,7 +847,7 @@ END $wgOut->addHTML( << END . htmlspecialchars( $this->safeUnicodeOutput( $this->textbox1 ) ) . @@ -870,7 +873,8 @@ END $wgOut->addHTML( " section ) . "\" name=\"wpSection\" /> starttime}\" name=\"wpStarttime\" />\n -edittime}\" name=\"wpEdittime\" />\n" ); +edittime}\" name=\"wpEdittime\" />\n +scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n" ); if ( $wgUser->isLoggedIn() ) { /** diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 32194ed816..4bb674ba33 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -32,6 +32,7 @@ function runOnloadHook() unhidetzbutton(); tabbedprefs(); akeytt(); + scrollEditBox(); // Run any added-on functions for ( var i = 0; i < onloadFuncts.length; i++ ) @@ -491,3 +492,20 @@ function considerChangingExpiryFocus() { else field.style.display = 'none'; } + +function scrollEditBox() { + + var editBoxEl = document.getElementById("wpTextbox1"); + var scrollTopEl = document.getElementById("wpScrolltop"); + var editFormEl = document.getElementById("editform"); + + if ( editBoxEl && scrollTopEl ) { + + if (scrollTopEl.value) editBoxEl.scrollTop = scrollTopEl.value; + editFormEl.onsubmit = function() { + document.getElementById("wpScrolltop").value = document.getElementById("wpTextbox1").scrollTop; + } + } +} + +hookEvent( "load", scrollEditBox ); \ No newline at end of file -- 2.20.1