From: vyshane Date: Mon, 9 Oct 2006 08:35:39 +0000 (+0000) Subject: Fix for MDL-6889. See bug report for description. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3203f10402ac6cc5b4c37a8cddf2f5595013642c;p=moodle.git Fix for MDL-6889. See bug report for description. --- diff --git a/lib/ajax/section_classes.js b/lib/ajax/section_classes.js index 96ed8e5f4d..18d2832967 100755 --- a/lib/ajax/section_classes.js +++ b/lib/ajax/section_classes.js @@ -12,16 +12,16 @@ function section_class(id,group,config,isDraggable) { } YAHOO.extend(section_class, YAHOO.util.DDProxy); -section_class.prototype.debug = false; +section_class.prototype.debug = true; section_class.prototype.init_section = function(id, group,config,isDraggable) { - if (!id) { return; } + if (!id) { return; } // id would be the html id attribute. this.is = 'section'; - this.sectionId = null; + this.sectionId = null; // Section number. This is NOT the section id from + // the database. - - if (!isDraggable) { + if (!isDraggable) { this.initTarget(id,group,config); this.removeFromGroup('sections'); } else { @@ -33,7 +33,8 @@ section_class.prototype.init_section = function(id, group,config,isDraggable) { this.isTarget = true; this.resources = []; - this.numberDisplay = null; + this.numberDisplay = null; // Used to display the section number on the top left + // of the section. Not used in all course formats. this.summary = null; this.content_td = null; this.hidden = false; @@ -105,7 +106,9 @@ section_class.prototype.process_section = function() { this.getEl().childNodes[0].innerHTML = ''; this.getEl().childNodes[0].appendChild(this.numberDisplay); - this.sectionId = this.numberDisplay.innerHTML; + this.sectionId = this.id.replace(/section-/i, ''); // Okay, we will have to change this if we + // ever change the id attributes format + // for the sections. if (this.debug)YAHOO.log("Creating section "+this.getEl().id+" in position "+this.sectionId); //find/edit resources @@ -155,7 +158,7 @@ section_class.prototype.onDragDrop = function(e, id) { this.move_to_section(target); //add back to resources group - this.addToGroup('resources'); + this.addToGroup('resources'); } section_class.prototype.endDrag = function() { //nessicary to defeat default action @@ -170,6 +173,8 @@ 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); @@ -354,7 +359,7 @@ section_class.prototype.insert_resource = function(el, targetel) { main.connect('post', 'class=resource&field=move', null, 'id='+el.id+'&beforeId='+targetId - +'§ionId='+this.id.replace(/section-/i, '')); + +'§ionId='+this.sectionId); //if inserting into a hidden resource hide if (this.hidden) { @@ -586,7 +591,7 @@ resource_class.prototype.onDragDrop = function(e, ids) { var target = YAHOO.util.DDM.getBestMatch(id); if (this.debug) { - YAHOO.log("Dropped on section id="+target.id.replace(/section-/i, '') + YAHOO.log("Dropped on section id="+target.sectionId +", el="+this.getEl().id +", x="+YAHOO.util.Dom.getXY( this.getDragEl() )); }