From: nicolasconnault Date: Mon, 27 Aug 2007 16:59:04 +0000 (+0000) Subject: MDL-7574 Applying Matthew Davidson's patch. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9837bd1d2ccae13179bc693c65b14e8931a8a9a5;p=moodle.git MDL-7574 Applying Matthew Davidson's patch. --- diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index d551508198..f3c35b34f5 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -191,17 +191,8 @@ echo ''; echo ' '; - - if (ajaxenabled() && $editing) { - // Temporarily hide the dates for the weeks. We do it this way - // for now. Eventually, we'll have to modify the javascript code - // to handle re-calculation of dates when sections are moved - // around. For now, just hide all the dates to avoid confusion. - $weekperiod = ''; - } else { - $weekperiod = $weekday.' - '.$endweekday; - } - + $weekperiod = $weekday.' - '.$endweekday; + echo ''; if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) { // Hidden for students diff --git a/lib/ajax/section_classes.js b/lib/ajax/section_classes.js index 64b2f10796..9c0add9077 100755 --- a/lib/ajax/section_classes.js +++ b/lib/ajax/section_classes.js @@ -237,13 +237,15 @@ section_class.prototype.move_to_section = function(target) { } else if (main.sections[i] == target) { //encounter with target node if (this.debug) { - YAHOO.log("Found target "+main.sections[i].getEl().id); - } + YAHOO.log("Found target "+main.sections[i].getEl().id); + } + main.sections[i].swap_dates(main.sections[eval(loopmodifier)]); main.sections[i].swap_with_section(main.sections[eval(loopmodifier)]); found = false; break; } else if (found) { //encounter with nodes inbetween + main.sections[i].swap_dates(main.sections[eval(loopmodifier)]); main.sections[i].swap_with_section(main.sections[eval(loopmodifier)]); } } @@ -878,3 +880,28 @@ resource_class.prototype.onDragDrop = function(e, ids) { resource_class.prototype.endDrag = function() { // Eliminates default action } + +section_class.prototype.swap_dates = function(el){ + var i=0; + while(this.getEl().getElementsByTagName("div")[i]) { + if (this.getEl().getElementsByTagName("div")[i].className == "weekdates") { + var tempdate = this.getEl().getElementsByTagName("div")[i].innerHTML; + var permi = i; + } + i++; + } + + var j=0; + while(el.getEl().getElementsByTagName("div")[j]) { + if (el.getEl().getElementsByTagName("div")[j].className == "weekdates") { + var permj = j; + } + j++; + } + + if(tempdate) { + this.getEl().getElementsByTagName("div")[permi].innerHTML = el.getEl().getElementsByTagName("div")[permj].innerHTML; + el.getEl().getElementsByTagName("div")[permj].innerHTML = tempdate; + } +} +