diff --git a/course/yui/dragdrop/dragdrop.js b/course/yui/dragdrop/dragdrop.js index 431408d1ae1..fc93fbed48b 100644 --- a/course/yui/dragdrop/dragdrop.js +++ b/course/yui/dragdrop/dragdrop.js @@ -41,6 +41,26 @@ YUI.add('moodle-course-dragdrop', function(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, + target: true, + handles: ['.'+CSS.LEFT], + dragConfig: {groups: this.groups} + }); + del.dd.plug(Y.Plugin.DDProxy, { + // Don't move the node at the end of the drag + moveOnEnd: false + }); + del.dd.plug(Y.Plugin.DDConstrained, { + // Keep it inside the .course-content + constrain: '#'+CSS.PAGECONTENT, + stickY: true + }); + del.dd.plug(Y.Plugin.DDWinScroll); } }, @@ -76,22 +96,6 @@ YUI.add('moodle-course-dragdrop', function(Y) { if (movedown) { movedown.remove(); } - - // Make each li element in the lists of sections draggable - var dd = new Y.DD.Drag({ - node: sectionnode, - // Make each li a Drop target too - groups: this.groups, - target: true, - handles: ['.'+CSS.LEFT] - }).plug(Y.Plugin.DDProxy, { - // Don't move the node at the end of the drag - moveOnEnd: false - }).plug(Y.Plugin.DDConstrained, { - // Keep it inside the .course-content - constrain: '#'+CSS.PAGECONTENT, - stickY: true - }).plug(Y.Plugin.DDWinScroll); } } }, this); @@ -244,12 +248,33 @@ YUI.add('moodle-course-dragdrop', function(Y) { this.groups = ['resource']; this.samenodeclass = CSS.ACTIVITY; this.parentnodeclass = CSS.SECTION; + this.resourcedraghandle = this.get_drag_handle(M.str.moodle.move, CSS.EDITINGMOVE, CSS.ICONCLASS); // Go through all sections var sectionlistselector = M.course.format.get_section_selector(Y); if (sectionlistselector) { sectionlistselector = '.'+CSS.COURSECONTENT+' '+sectionlistselector; this.setup_for_section(sectionlistselector); + + // Initialise drag & drop for all resources/activities + var nodeselector = sectionlistselector.slice(CSS.COURSECONTENT.length+2)+' li.'+CSS.ACTIVITY; + var del = new Y.DD.Delegate({ + container: '.'+CSS.COURSECONTENT, + nodes: nodeselector, + target: true, + handles: ['.' + CSS.EDITINGMOVE], + dragConfig: {groups: this.groups} + }); + del.dd.plug(Y.Plugin.DDProxy, { + // Don't move the node at the end of the drag + moveOnEnd: false + }); + del.dd.plug(Y.Plugin.DDConstrained, { + // Keep it inside the .course-content + constrain: '#'+CSS.PAGECONTENT + }); + del.dd.plug(Y.Plugin.DDWinScroll); + M.course.coursebase.register_module(this); M.course.dragres = this; } @@ -269,15 +294,15 @@ YUI.add('moodle-course-dragdrop', function(Y) { var resources = Y.Node.create('