Skip to content

Commit

Permalink
Merge branch 'MDL-65539-m37' of https://github.com/NeillM/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_37_STABLE
  • Loading branch information
sarjona committed Apr 6, 2020
2 parents c7c9844 + 316d6c9 commit b6e8c88
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 43 deletions.
12 changes: 7 additions & 5 deletions course/format/topics/format.js
Expand Up @@ -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
Expand Down Expand Up @@ -76,13 +77,14 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
// Update section title.
var content = Y.Node.create('<span>' + response.sectiontitles[i] + '</span>');
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());
}
}
}
12 changes: 7 additions & 5 deletions course/format/weeks/format.js
Expand Up @@ -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
Expand Down Expand Up @@ -77,13 +78,14 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
var content = Y.Node.create('<span>' + response.sectiontitles[i] + '</span>');
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');
Expand Down
Expand Up @@ -48,6 +48,8 @@ Y.extend(DRAGSECTION, M.core.dragdrop, {
this.groups = [CSS.SECTIONDRAGGABLE];
this.samenodeclass = M.course.format.get_sectionwrapperclass();
this.parentnodeclass = M.course.format.get_containerclass();
// Detect the direction of travel.
this.detectkeyboarddirection = true;

// Check if we are in single section mode
if (Y.Node.one('.' + CSS.JUMPMENU)) {
Expand Down Expand Up @@ -147,6 +149,14 @@ Y.extend(DRAGSECTION, M.core.dragdrop, {
drag_start: function(e) {
// Get our drag object
var drag = e.target;
// This is the node that the user started to drag.
var node = drag.get('node');
// This is the container node that will follow the mouse around,
// or during a keyboard drag and drop the original node.
var dragnode = drag.get('dragNode');
if (node === dragnode) {
return;
}
// Creat a dummy structure of the outer elemnents for clean styles application
var containernode = Y.Node.create('<' + M.course.format.get_containernode() +
'></' + M.course.format.get_containernode() + '>');
Expand All @@ -155,10 +165,10 @@ Y.extend(DRAGSECTION, M.core.dragdrop, {
'></' + M.course.format.get_sectionwrappernode() + '>');
sectionnode.addClass(M.course.format.get_sectionwrapperclass());
sectionnode.setStyle('margin', 0);
sectionnode.setContent(drag.get('node').get('innerHTML'));
sectionnode.setContent(node.get('innerHTML'));
containernode.appendChild(sectionnode);
drag.get('dragNode').setContent(containernode);
drag.get('dragNode').addClass(CSS.COURSECONTENT);
dragnode.setContent(containernode);
dragnode.addClass(CSS.COURSECONTENT);
},

drag_dropmiss: function(e) {
Expand Down Expand Up @@ -431,6 +441,11 @@ Y.extend(DRAGRESOURCE, M.core.dragdrop, {
drag_start: function(e) {
// Get our drag object
var drag = e.target;
if (drag.get('dragNode') === drag.get('node')) {
// We do not want to modify the contents of the real node.
// They will be the same during a keyboard drag and drop.
return;
}
drag.get('dragNode').setContent(drag.get('node').get('innerHTML'));
drag.get('dragNode').all('img.iconsmall').setStyle('vertical-align', 'baseline');
},
Expand Down

0 comments on commit b6e8c88

Please sign in to comment.