From f81d63553edbd449bf583fdd63ed25fa7a7fc7be Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Fri, 1 Feb 2013 11:41:08 +0000 Subject: [PATCH] MDL-33546: course: Fix current week hightlighting after dragging the section --- course/format/weeks/format.js | 9 +++++++++ course/format/weeks/lib.php | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/course/format/weeks/format.js b/course/format/weeks/format.js index 1c36994e3bf..eb5e1060896 100644 --- a/course/format/weeks/format.js +++ b/course/format/weeks/format.js @@ -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'); } } } diff --git a/course/format/weeks/lib.php b/course/format/weeks/lib.php index d31128b9add..ded5ef0416f 100644 --- a/course/format/weeks/lib.php +++ b/course/format/weeks/lib.php @@ -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'); } /**