Code

Added permanent scroll position saver to sortable lists
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Jan 2010 11:24:25 +0000 (11:24 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 19 Jan 2010 11:24:25 +0000 (11:24 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15195 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_sortableListing.inc

index 0e346f8ade48a520d03a9116d2218963bb11839b..8ebd88c4b42b80eef9aa9c8745c3eac14c6d0603 100644 (file)
@@ -40,6 +40,7 @@ class sortableListing {
   private $mapping;
   private $current_mapping;
   private $active_index;
+  private $scrollPosition= 0;
 
   private $acl= "";
   private $modified= false;
@@ -218,9 +219,7 @@ class sortableListing {
     $result.= ' }';
     $result.= 'Position.includeScrollOffsets = true;';
     $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.= '$("scroll_'.$this->id.'").scrollTop= '.$this->scrollPosition.';';
     $result.= 'var box = $("scroll_'.$this->id.'").onscroll= function() {$("position_'.$this->id.'").value= this.scrollTop;}';
     $result.= '</script>';
 
@@ -233,6 +232,10 @@ class sortableListing {
     // Do not do anything if we're not posted - or have no permission
     if (strpos($this->acl, 'w') !== false && isset($_POST['reorder_'.$this->id])){
 
+      if (isset($_POST['position_'.$this->id]) && is_numeric($_POST['position_'.$this->id])) {
+        $this->scrollPosition= $_POST['position_'.$this->id];
+      }
+
       // Move requested?
       $move= $_POST['reorder_'.$this->id];
       if ($move != "") {