]> git.mjollnir.org Git - moodle.git/commitdiff
Some fixes for MDL-6674. This should fix moving activities (resources).
authorvyshane <vyshane>
Fri, 6 Oct 2006 07:56:37 +0000 (07:56 +0000)
committervyshane <vyshane>
Fri, 6 Oct 2006 07:56:37 +0000 (07:56 +0000)
Thanks to Dan Poltawski for suggestions.

lib/ajax/section_classes.js

index c147b00937c2a710fc6079abdb7dc6db8f977763..934ab5145198481a68baa981f0b22cd6d270e9ab 100755 (executable)
@@ -29,7 +29,7 @@ section_class.prototype.init_section = function(id, group,config,isDraggable) {
         this.handle = null;           
     }
 
-    this.createFrame();     
+    this.createFrame();
     this.isTarget = true;
 
     this.resources = [];
@@ -341,20 +341,20 @@ section_class.prototype.remove_resource = function(el) {
 
 }   
 
-section_class.prototype.insert_resource = function(el,targetel) {
+section_class.prototype.insert_resource = function(el, targetel) {
     var resourcecount = this.resources.length;
     var found = false;
     var tempStore = nextStore = null;
 
     //update in backend
-    targetId='';
-    if (targetel !=null) {
-        targetId=targetel.id;
-    }
-
-    main.connect('post','class=resource&field=move',null,'id='+el.id+'&beforeId='+targetId+'&sectionId='+this.sectionId);
-
+       targetId = '';
+       if (targetel != null) {
+               targetId = targetel.id;
+       }
 
+       main.connect('post', 'class=resource&field=move', null,
+                       'id='+el.id+'&beforeId='+targetId
+                       +'&sectionId='+this.id.replace(/section-/i, ''));
 
     //if inserting into a hidden resource hide
     if (this.hidden) {
@@ -572,40 +572,44 @@ resource_class.prototype.startDrag = function(x, y) {
 resource_class.prototype.onDragDrop = function(e, ids) {
     // best fit Id
     var id=[];
-    for (var i=0;i<ids.length;i++)
-        if (ids[i].is == 'resource')
-            id[id.length] = ids[i];
 
-    if (id.length == 0)
+    for (var i=0; i<ids.length; i++) {
+        if (ids[i].is == 'resource') {
+            id[id.length] = ids[i];
+               }
+       }
+    if (id.length == 0) {
         id = ids;
-
+       }
 
     // get the drag and drop object that was targeted
     var target = YAHOO.util.DDM.getBestMatch(id);
 
-    if (this.debug)YAHOO.log("dropped on id="+target+" el = "+this.getEl().id+" x="+YAHOO.util.Dom.getXY(this.getDragEl()));
-
-    this.parentObj.remove_resource(this);    
-
-    if (target.is == 'resource'||target.is == 'activity') {             
-        target.parentObj.insert_resource(this,target);
+    if (this.debug) {
+               YAHOO.log("Dropped on section id="+target.id.replace(/section-/i, '')
+                                               +", el="+this.getEl().id
+                                               +", x="+YAHOO.util.Dom.getXY( this.getDragEl() ));
+       }
+/*     var oldid = this.parentObj.id;
+       this.previousId = oldid.replace(/section-/i, '');*/
+    this.parentObj.remove_resource(this);
 
-    } else if (target.is =='section') {
+    if (target.is == 'resource' || target.is == 'activity') {
+        target.parentObj.insert_resource(this, target);
+    } else if (target.is == 'section') {
         target.insert_resource(this);
-
     }
-
     return;
-}    
+}
 
 resource_class.prototype.endDrag = function() {
-    //eliminates default action
+    // Eliminates default action
 }
 
-/*
- * activity Class extends resource class
- */    
 
+/**
+ * activity Class extends resource class
+ */
 
 function activity_class(id,group,config,parentObj) {
     this.init_activity(id,group,config,parentObj);