From 0082df9d12dec05fcc4ca4a9ef0e7bce3a8d42ad Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Sun, 22 Sep 2013 22:11:33 +0100 Subject: [PATCH] MDL-36465 Course JavaScript: Ensure that the zero section is not draggable --- course/yui/dragdrop/dragdrop.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/course/yui/dragdrop/dragdrop.js b/course/yui/dragdrop/dragdrop.js index fc5f88d2e40..801ffc980f0 100644 --- a/course/yui/dragdrop/dragdrop.js +++ b/course/yui/dragdrop/dragdrop.js @@ -17,7 +17,8 @@ YUI.add('moodle-course-dragdrop', function(Y) { SECTION : 'section', SECTIONADDMENUS : 'section_add_menus', SECTIONHANDLE : 'section-handle', - SUMMARY : 'summary' + SUMMARY : 'summary', + SECTIONDRAGGABLE: 'sectiondraggable' }; var DRAGSECTION = function() { @@ -28,7 +29,7 @@ YUI.add('moodle-course-dragdrop', function(Y) { initializer : function(params) { // Set group for parent class - this.groups = ['section']; + this.groups = [ CSS.SECTIONDRAGGABLE ]; this.samenodeclass = M.course.format.get_sectionwrapperclass(); this.parentnodeclass = M.course.format.get_containerclass(); @@ -40,13 +41,13 @@ YUI.add('moodle-course-dragdrop', function(Y) { this.sectionlistselector = M.course.format.get_section_wrapper(Y); if (this.sectionlistselector) { this.sectionlistselector = '.'+CSS.COURSECONTENT+' '+this.sectionlistselector; + this.setup_for_section(this.sectionlistselector); // Make each li element in the lists of sections draggable - var nodeselector = this.sectionlistselector.slice(CSS.COURSECONTENT.length+2); var del = new Y.DD.Delegate({ container: '.'+CSS.COURSECONTENT, - nodes: nodeselector, + nodes: '.' + CSS.SECTIONDRAGGABLE, target: true, handles: ['.'+CSS.LEFT], dragConfig: {groups: this.groups} @@ -95,6 +96,9 @@ YUI.add('moodle-course-dragdrop', function(Y) { if (movedown) { movedown.remove(); } + + // This section can be moved - add the class to indicate this to Y.DD. + sectionnode.addClass(CSS.SECTIONDRAGGABLE); } } }, this); -- 2.43.0