Browse files

Merge branch 'wip-MDL-34798_M24-2' of git://github.com/gjb2048/moodle…

… into MOODLE_24_STABLE
  • Loading branch information...
2 parents 6cf9f04 + cac8708 commit 09931f8158094a4df88411145ff41273c8edccb7 @danpoltawski danpoltawski committed Feb 12, 2013
Showing with 16 additions and 4 deletions.
  1. +8 −2 course/format/topics/format.js
  2. +8 −2 course/format/weeks/format.js
View
10 course/format/topics/format.js
@@ -40,7 +40,7 @@ M.course.format.swap_sections = function(Y, node1, node2) {
};
var sectionlist = Y.Node.all('.'+CSS.COURSECONTENT+' '+M.course.format.get_section_selector(Y));
- // Swap menus
+ // Swap menus.
sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.'+CSS.SECTIONADDMENUS));
}
@@ -59,7 +59,13 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
};
if (response.action == 'move') {
- // update titles in all affected sections
+ // If moving up swap around 'sectionfrom' and 'sectionto' so the that loop operates.
+ if (sectionfrom > sectionto) {
+ var temp = sectionto;
+ sectionto = sectionfrom;
+ sectionfrom = temp;
+ }
+ // Update titles in all affected sections.
for (var i = sectionfrom; i <= sectionto; i++) {
sectionlist.item(i).one('.'+CSS.SECTIONNAME).setContent(response.sectiontitles[i]);
}
View
10 course/format/weeks/format.js
@@ -40,7 +40,7 @@ M.course.format.swap_sections = function(Y, node1, node2) {
};
var sectionlist = Y.Node.all('.'+CSS.COURSECONTENT+' '+M.course.format.get_section_selector(Y));
- // Swap menus
+ // Swap menus.
sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.'+CSS.SECTIONADDMENUS));
}
@@ -59,7 +59,13 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
};
if (response.action == 'move') {
- // update titles in all affected sections
+ // If moving up swap around 'sectionfrom' and 'sectionto' so the that loop operates.
+ if (sectionfrom > sectionto) {
+ var temp = sectionto;
+ sectionto = sectionfrom;
+ sectionfrom = temp;
+ }
+ // Update titles in all affected sections.
for (var i = sectionfrom; i <= sectionto; i++) {
sectionlist.item(i).one('.'+CSS.SECTIONNAME).setContent(response.sectiontitles[i]);
}

0 comments on commit 09931f8

Please sign in to comment.