Permalink
Browse files

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

…section
  • Loading branch information...
kabalin authored and marinaglancy committed Feb 1, 2013
1 parent 5883de2 commit f81d63553edbd449bf583fdd63ed25fa7a7fc7be
Showing with 14 additions and 1 deletion.
  1. +9 −0 course/format/weeks/format.js
  2. +5 −1 course/format/weeks/lib.php
@@ -75,13 +75,22 @@ 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');
stridx = str.lastIndexOf(' ');
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');
}
}
}
@@ -162,15 +162,19 @@ public function extend_course_navigation($navigation, navigation_node $node) {
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');
}
/**

0 comments on commit f81d635

Please sign in to comment.