]> git.mjollnir.org Git - moodle.git/commitdiff
movement of the blocks is now handled completely seperately on the serverside and...
authorcap2501 <cap2501>
Sun, 8 Oct 2006 20:25:10 +0000 (20:25 +0000)
committercap2501 <cap2501>
Sun, 8 Oct 2006 20:25:10 +0000 (20:25 +0000)
lib/ajax/block_classes.js

index d7a48f1734cb6ecc0b9be7d6b47353d66bcd4952..a8072d0a4261322687c5725b0daa810af06884f6 100644 (file)
@@ -251,6 +251,11 @@ block_class.prototype.update_index = function(index,columnId){
        if(this.debug)YAHOO.log("updating position of "+this.getEl().id+" to index "+index+" on column "+columnId);
     }
 
+block_class.prototype.updatePosition = function(index,columnId){
+       //update the db for the position
+       main.connectQueue_add('post','class=block&field=position',null,'value='+index+'&column='+columnId+'&instanceId='+this.instanceId);
+       if(this.debug)YAHOO.log("updating position of "+this.getEl().id+" to index "+index+" on column "+columnId);               
+   }
 
 /*
  * column class, DD targets
@@ -300,27 +305,31 @@ column_class.prototype.add_block = function(el){
 
 column_class.prototype.insert_block = function(el,targetel){
         var blockcount = this.blocks.length;
-        var found = false;
+        var found = -1;
         var tempStore = nextStore = null;
         for(var i=0;i<blockcount;i++){
-            if(found){
+            if(found > 0){
                 tempStore = this.blocks[i];
                 this.blocks[i] = nextStore;
                 nextStore = tempStore;           
                                                 
             }else if(this.blocks[i] == targetel){
-                found = true;
+                found = i;
                 nextStore = this.blocks[i];
                 this.blocks[i] = el;               
                 blockcount++;
-            }      
-            this.blocks[i].update_index(i,this.ident);                        
+            }     
+            //this.blocks[i].update_index(i,this.ident);                        
         }
         
-        if(!found){//insert at end
-            el.update_index(this.blocks.length,this.ident);
-            this.add_block(el);            
+        if(found<0){//insert at end
+            //el.update_index(this.blocks.length,this.ident);
+            found = this.blocks.length; 
+            this.add_block(el);              
+                    
         }
+        
+        el.updatePosition(found,this.ident);
     }
 
 column_class.prototype.has_block = function(el){
@@ -341,7 +350,7 @@ column_class.prototype.remove_block = function(el){
                     found = true;
           
                if(i < blockcount-1){
-                   this.blocks[i+1].update_index(i,this.ident);
+                   //this.blocks[i+1].update_index(i,this.ident);
                    this.blocks[i] = this.blocks[i+1];                   
                }else{
                     this.blocks.pop();