]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from 1.7
authorvyshane <vyshane>
Wed, 11 Oct 2006 06:58:35 +0000 (06:58 +0000)
committervyshane <vyshane>
Wed, 11 Oct 2006 06:58:35 +0000 (06:58 +0000)
lib/ajax/section_classes.js

index 18d2832967e8595bdc366155019343cbba12d44e..42e5f047aff063f3e9c9f91fc5f2906abfbbd786 100755 (executable)
@@ -12,12 +12,14 @@ function section_class(id,group,config,isDraggable) {
 }
 YAHOO.extend(section_class, YAHOO.util.DDProxy);
 
+
 section_class.prototype.debug = true;
 
+
 section_class.prototype.init_section = function(id, group,config,isDraggable) {
     if (!id) { return; }       // id would be the html id attribute.
 
-    this.is = 'section'; 
+    this.is = 'section';
     this.sectionId = null;     // Section number. This is NOT the section id from
                             // the database.
 
@@ -40,7 +42,7 @@ section_class.prototype.init_section = function(id, group,config,isDraggable) {
     this.hidden = false;
     this.highlighted = false;
     this.showOnly = false;
-    this.resources_ul = null;        
+    this.resources_ul = null;
     this.process_section();
 
     this.viewButton = null;
@@ -117,7 +119,7 @@ section_class.prototype.process_section = function() {
     if (this.resources_ul == null) {
         this.resources_ul = document.createElement('ul');
         this.resources_ul.className='section';
-        this.content_td.insertBefore(this.resources_ul,this.content_td.childNodes[1]);
+        this.content_td.insertBefore(this.resources_ul, this.content_td.childNodes[2]);
     }
 
     var resource_count = this.resources_ul.getElementsByTagName('li').length;
@@ -173,8 +175,6 @@ section_class.prototype.move_to_section = function(target) {
     var sectionCount = main.sections.length;
     var found = null;
 
-this.debug = true;
-
     //determine if original is above or below target and adjust loop
     var oIndex=main.get_section_index(this);
     var tIndex=main.get_section_index(target);
@@ -197,13 +197,13 @@ this.debug = true;
     main.connect('post','class=section&field=move',null,'id='+this.sectionId+'&value='+(target.sectionId-this.sectionId));
 
     //move on front end
-    for (var i=loopStart;eval(loopCondition);eval(loopInc)) {
+    for (var i=loopStart; eval(loopCondition); eval(loopInc)) {
 
         if ((main.sections[i] == this)&& !found) {
             //enounter with original node
             if (this.debug)YAHOO.log("Found Original "+main.sections[i].getEl().id);
             if (main.sections[i] == this) {
-                found = true;               
+                found = true;
             }
 
         } else if (main.sections[i] == target) {
@@ -214,10 +214,10 @@ this.debug = true;
             break;
 
         } else if (found) {
-            //encounter with nodes inbetween 
+            //encounter with nodes inbetween
             main.sections[i].swap_with_section(main.sections[eval(loopmodifier)]);
-        }            
-    }  
+        }
+    }
 }
 
 
@@ -234,7 +234,7 @@ section_class.prototype.swap_with_section = function(sectionIn) {
 
     if (this.debug)YAHOO.log("Swapping "+this.getEl().id+" with "+sectionIn.getEl().id);
 
-    YAHOO.util.DDM.swapNode(this.getEl(),sectionIn.getEl());        
+    YAHOO.util.DDM.swapNode(this.getEl(), sectionIn.getEl());
 }
 
 section_class.prototype.toggle_hide = function(e,target,superficial) {
@@ -375,12 +375,12 @@ section_class.prototype.insert_resource = function(el, targetel) {
     //update model
     if (targetel == null) {
         this.resources[this.resources.length] = el;
-    } else 
+    } else {
         for (var i=0;i<resourcecount;i++) {
             if (found) {
                 tempStore = this.resources[i];
                 this.resources[i] = nextStore;
-                nextStore = tempStore;           
+                nextStore = tempStore;
 
                 if (nextStore != null)     
                     nextStore.update_index(i+1); 
@@ -395,12 +395,12 @@ section_class.prototype.insert_resource = function(el, targetel) {
                 nextStore.update_index(i+1); 
             }                              
         }
-
+       }
+       
     //update on frontend 
     if (targetel != null) { 
         this.resources_ul.insertBefore(el.getEl(),targetel.getEl());
-        this.resources_ul.insertBefore(document.createTextNode(''),targetel.getEl());        
-
+        this.resources_ul.insertBefore(document.createTextNode(''),targetel.getEl());
     } else {
         this.resources_ul.appendChild(el.getEl());
         this.resources_ul.appendChild(document.createTextNode(" "));
@@ -415,10 +415,9 @@ section_class.prototype.write_sequence_list = function(toReturn) {
         if (i != (this.resources.length-1))
             listOutput += ',';
     }
-
-    if (toReturn)
+    if (toReturn) {
         return listOutput;
-
+       }
 }   
 
 
@@ -545,7 +544,7 @@ resource_class.prototype.toggle_hide = function(target,e,superficial,force) {
 }
 
 resource_class.prototype.delete_button = function() {
-    if (this.debug)YAHOO.log("Deleteing "+this.getEl().id+"from parent "+this.parentObj.getEl().id);
+    if (this.debug)YAHOO.log("Deleting "+this.getEl().id+"from parent "+this.parentObj.getEl().id);
 
     if (!confirm(main.getString('deletecheck',main.getString(this.is)+" "+this.id))) {
         return false;