From 92eeecdc07e14729fa89556f963e76787e55e419 Mon Sep 17 00:00:00 2001 From: Gareth J Barnard Date: Sat, 2 Mar 2013 13:05:12 +0000 Subject: [PATCH] MDL-37901 format_topics & format_weeks: Fix drag icon tooltip after move. --- course/format/topics/format.js | 16 +++++++++++++++- course/format/weeks/format.js | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/course/format/topics/format.js b/course/format/topics/format.js index 172d1d9e9c5..94bc3710aef 100644 --- a/course/format/topics/format.js +++ b/course/format/topics/format.js @@ -56,6 +56,9 @@ M.course.format.swap_sections = function(Y, node1, node2) { M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) { var CSS = { SECTIONNAME : 'sectionname' + }, + SELECTORS = { + SECTIONLEFTSIDE : '.left .section-handle img' }; if (response.action == 'move') { @@ -65,9 +68,20 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro sectionto = sectionfrom; sectionfrom = temp; } - // Update titles in all affected sections. + + // Update titles and move icons in all affected sections. + var ele, str, stridx, newstr; + 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. } } } diff --git a/course/format/weeks/format.js b/course/format/weeks/format.js index 64337026d43..1c36994e3bf 100644 --- a/course/format/weeks/format.js +++ b/course/format/weeks/format.js @@ -56,6 +56,9 @@ M.course.format.swap_sections = function(Y, node1, node2) { M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) { var CSS = { SECTIONNAME : 'sectionname' + }, + SELECTORS = { + SECTIONLEFTSIDE : '.left .section-handle img' }; if (response.action == 'move') { @@ -65,9 +68,20 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro sectionto = sectionfrom; sectionfrom = temp; } - // Update titles in all affected sections. + + // Update titles and move icons in all affected sections. + var ele, str, stridx, newstr; + 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. } } }