Code

Save scroll position
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Jan 2010 09:26:11 +0000 (09:26 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Jan 2010 09:26:11 +0000 (09:26 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15191 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_sortableListing.inc

index 9ea6d40eebcdd508b8c146c382221db2527daa32..0e346f8ade48a520d03a9116d2218963bb11839b 100644 (file)
@@ -205,6 +205,7 @@ class sortableListing {
     }
 
     $result.= " </tbody>\n</table>\n</div>\n";
+    $result.= " <input type='hidden' name='position_".$this->id."' id='position_".$this->id."'>\n";
     $result.= " <input type='hidden' name='reorder_".$this->id."' id='reorder_".$this->id."'>\n";
 
     // Append script stuff if needed
@@ -216,7 +217,11 @@ class sortableListing {
     $result.= '    document.mainform.submit();';
     $result.= ' }';
     $result.= 'Position.includeScrollOffsets = true;';
-    $result.= ' Sortable.create(\''.$this->id.'\',{tag:\'tr\', ghosting:false,constraint:\'vertical\', scroll:\'scroll_'.$this->id.'\',onUpdate : updateOrder})';
+    $result.= ' Sortable.create(\''.$this->id.'\',{tag:\'tr\', ghosting:false, constraint:\'vertical\', scroll:\'scroll_'.$this->id.'\',onUpdate : updateOrder});';
+    if (isset($_POST['position_'.$this->id]) && is_numeric($_POST['position_'.$this->id])) {
+      $result.= '$("scroll_'.$this->id.'").scrollTop= '.$_POST['position_'.$this->id].';';
+    }
+    $result.= 'var box = $("scroll_'.$this->id.'").onscroll= function() {$("position_'.$this->id.'").value= this.scrollTop;}';
     $result.= '</script>';
 
     return $result;