Skip to content

Commit

Permalink
MDL-43145 dock: Enable regions before the drag operation starts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Apr 11, 2014
1 parent 34df4e4 commit 58f70bb
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 20 deletions.
25 changes: 19 additions & 6 deletions lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js
Expand Up @@ -443,7 +443,6 @@ MANAGER.prototype = {
i = 0,
region,
regionname,
droptarget,
dragdelegation;

// Evil required by M.core.dragdrop.
Expand Down Expand Up @@ -472,7 +471,7 @@ MANAGER.prototype = {
// Setting blockregion as droptarget (the case when it is empty)
// The region-post (the right one)
// is very narrow, so add extra padding on the left to drop block on it.
droptarget = new Y.DD.Drop({
new Y.DD.Drop({
node: region.get_droptarget(),
groups: this.groups,
padding: '40 240 40 240'
Expand All @@ -492,9 +491,10 @@ MANAGER.prototype = {
moveOnEnd: false
});
dragdelegation.dd.plug(Y.Plugin.DDWinScroll);
// On the mouse down event we will enable all block regions so that they can be dragged to.
// This is VERY important as without it dnd won't work for empty block regions.
dragdelegation.on('drag:start', this.enable_all_regions, this);

// On the DD Manager start operation, we enable all block regions so that they can be drop targets. This
// must be done *before* drag:start but after dragging has been initialised.
Y.DD.DDM.on('ddm:start', this.enable_all_regions, this);

region.change_block_move_icons(this);
}
Expand Down Expand Up @@ -536,11 +536,24 @@ MANAGER.prototype = {

/**
* Enables all fo the regions so that they are all visible while dragging is occuring.
*
* @method enable_all_regions
*/
enable_all_regions : function() {
var i = 0;
var groups = Y.DD.DDM.activeDrag.get('groups');

// As we're called by Y.DD.DDM, we can't be certain that the call
// relates specifically to a block drag/drop operation. Test
// whether the relevant group applies here.
if (!groups || Y.Array.indexOf(groups, 'block') === -1) {
return;
}

var i;
for (i in this.regionobjects) {
if (!this.regionobjects.hasOwnProperty(i)) {
continue;
}
this.regionobjects[i].enable();
}
},
Expand Down

0 comments on commit 58f70bb

Please sign in to comment.