diff --git a/course/format/topics/format.js b/course/format/topics/format.js index c7e69419c5b..9b4807fd6a1 100644 --- a/course/format/topics/format.js +++ b/course/format/topics/format.js @@ -48,6 +48,7 @@ M.course.format.swap_sections = function(Y, node1, node2) { * Process sections after ajax response * * @param {YUI} Y YUI3 instance + * @param {NodeList} sectionlist of sections * @param {array} response ajax response * @param {string} sectionfrom first affected section * @param {string} sectionto last affected section @@ -76,13 +77,14 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro // Update section title. var content = Y.Node.create('' + response.sectiontitles[i] + ''); sectionlist.item(i).all('.'+CSS.SECTIONNAME).setHTML(content); - // Update move icon. - ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE); - str = ele.getAttribute('alt'); + // Update the drag handle. + ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE).ancestor('.section-handle'); + str = ele.getAttribute('title'); 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. + ele.setAttribute('title', newstr); + // Update the aria-label for the section. + sectionlist.item(i).setAttribute('aria-label', content.get('innerText').trim()); } } } diff --git a/course/format/weeks/format.js b/course/format/weeks/format.js index 1fb0c8ed7fd..b37f233456f 100644 --- a/course/format/weeks/format.js +++ b/course/format/weeks/format.js @@ -48,6 +48,7 @@ M.course.format.swap_sections = function(Y, node1, node2) { * Process sections after ajax response * * @param {YUI} Y YUI3 instance + * @param {NodeList} sectionlist of sections * @param {array} response ajax response * @param {string} sectionfrom first affected section * @param {string} sectionto last affected section @@ -77,13 +78,14 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro var content = Y.Node.create('' + response.sectiontitles[i] + ''); sectionlist.item(i).all('.'+CSS.SECTIONNAME).setHTML(content); - // Update move icon. - ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE); - str = ele.getAttribute('alt'); + // Update the drag handle. + ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE).ancestor('.section-handle'); + str = ele.getAttribute('title'); 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. + ele.setAttribute('title', newstr); + // Update the aria-label for the section. + sectionlist.item(i).setAttribute('aria-label', content.get('innerText').trim()); // Remove the current class as section has been moved. sectionlist.item(i).removeClass('current');