save scroll position in edit page

This commit is contained in:
Roland Gruber 2013-05-01 16:55:59 +00:00
parent ada2967854
commit 16c1e2f0e1
2 changed files with 40 additions and 8 deletions

View File

@ -791,6 +791,9 @@ class accountContainer {
* It prints the HTML code of each account page. * It prints the HTML code of each account page.
*/ */
function continue_main() { function continue_main() {
$oldPage = $this->current_page;
$oldSubpage = $this->subpage;
$post = $_POST;
$result = array(); $result = array();
$stopProcessing = false; // when set to true, no module options are displayed $stopProcessing = false; // when set to true, no module options are displayed
$errorsOccured = false; $errorsOccured = false;
@ -927,6 +930,17 @@ class accountContainer {
$this->titleBarSubtitle = $typeObject->getTitleBarSubtitle($this); $this->titleBarSubtitle = $typeObject->getTitleBarSubtitle($this);
// prints a module content page // prints a module content page
$this->printModuleContent($result, $stopProcessing); $this->printModuleContent($result, $stopProcessing);
if (!$errorsOccured && ($oldPage == $this->current_page) && ($oldSubpage == $this->subpage)
&& isset($_POST['scrollPositionTop']) && isset($_POST['scrollPositionLeft'])) {
// scroll to last position
echo '<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(window).scrollTop(' . $_POST['scrollPositionTop'] . ');
jQuery(window).scrollLeft('. $_POST['scrollPositionLeft'] . ');
});
</script>';
}
$this->printPageFooter();
} }
/** /**
@ -945,7 +959,6 @@ class accountContainer {
call_user_func_array("StatusMessage", $result[$i]); call_user_func_array("StatusMessage", $result[$i]);
} }
if ($stopProcessing) { if ($stopProcessing) {
$this->printPageFooter();
return; return;
} }
} }
@ -1010,7 +1023,6 @@ class accountContainer {
echo "</td></tr>\n"; echo "</td></tr>\n";
// Display rest of html-page // Display rest of html-page
echo "</table>\n"; echo "</table>\n";
$this->printPageFooter();
} }
/** /**
@ -1238,12 +1250,12 @@ class accountContainer {
*/ */
private function printPageHeader() { private function printPageHeader() {
include '../main_header.php'; include '../main_header.php';
echo '<script type="text/javascript">'; echo '<script type="text/javascript">
echo 'jQuery(document).ready(function() {'; jQuery(document).ready(function() {
echo ' jQuery("#inputForm").validationEngine();'; jQuery("#inputForm").validationEngine();
echo '});'; });
echo '</script>'; </script>';
echo "<form id=\"inputForm\" enctype=\"multipart/form-data\" action=\"edit.php\" method=\"post\">\n"; echo "<form id=\"inputForm\" enctype=\"multipart/form-data\" action=\"edit.php\" method=\"post\" onSubmit=\"saveScrollPosition('inputForm')\">\n";
} }
/** /**

View File

@ -403,3 +403,23 @@ function showDistributionDialog(title, okText, cancelText, scope, type, selectFi
} }
} }
/**
* Stores the current scroll position in the form.
*
* @param formName ID of form
*/
function saveScrollPosition(formName) {
var top = jQuery(window).scrollTop();
var left = jQuery(window).scrollLeft();
jQuery('<input>').attr({
type: 'hidden',
name: 'scrollPositionTop',
value: top
}).appendTo(jQuery('#' + formName));
jQuery('<input>').attr({
type: 'hidden',
name: 'scrollPositionLeft',
value: left
}).appendTo(jQuery('#' + formName));
}