MDL-33546: course: Fix current week hightlighting after dragging the section

This commit is contained in:
Ruslan Kabalin 2013-02-01 11:41:08 +00:00 committed by Marina Glancy
parent 5883de26ae
commit f81d63553e
2 changed files with 14 additions and 1 deletions

View File

@ -75,6 +75,7 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
for (var i = sectionfrom; i <= sectionto; i++) {
// Update section title.
sectionlist.item(i).one('.'+CSS.SECTIONNAME).setContent(response.sectiontitles[i]);
// Update move icon.
ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE);
str = ele.getAttribute('alt');
@ -82,6 +83,14 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
newstr = str.substr(0, stridx +1) + i;
ele.setAttribute('alt', newstr);
ele.setAttribute('title', newstr); // For FireFox as 'alt' is not refreshed.
// Remove the current class as section has been moved.
sectionlist.item(i).removeClass('current');
}
// If there is a current section, apply corresponding class in order to highlight it.
if (response.current !== -1) {
// Add current class to the required section.
sectionlist.item(response.current).addClass('current');
}
}
}

View File

@ -162,15 +162,19 @@ class format_weeks extends format_base {
function ajax_section_move() {
global $PAGE;
$titles = array();
$current = -1;
$course = $this->get_course();
$modinfo = get_fast_modinfo($course);
$renderer = $this->get_renderer($PAGE);
if ($renderer && ($sections = $modinfo->get_section_info_all())) {
foreach ($sections as $number => $section) {
$titles[$number] = $renderer->section_title($section, $course);
if ($this->is_section_current($section)) {
$current = $number;
}
}
}
return array('sectiontitles' => $titles, 'action' => 'move');
return array('sectiontitles' => $titles, 'current' => $current, 'action' => 'move');
}
/**