Skip to content

Commit

Permalink
Merge branch 'MDL-43145-master' of git://github.com/andrewnicols/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Apr 21, 2014
2 parents 2490169 + 58f70bb commit 65ffd68
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 30 deletions.
6 changes: 5 additions & 1 deletion lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,11 @@ public function region_completely_docked($region, $output) {

$this->check_is_loaded();
$this->ensure_content_created($region, $output);
foreach($this->visibleblockcontent[$region] as $instance) {
if (!$this->region_has_content($region, $output)) {
// If the region has no content then nothing is docked at all of course.
return false;
}
foreach ($this->visibleblockcontent[$region] as $instance) {
if (!empty($instance->content) && !get_user_preferences('docked_block_instance_'.$instance->blockinstanceid, 0)) {
return false;
}
Expand Down
27 changes: 20 additions & 7 deletions lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ M.core.blockdraganddrop.is_using_blocks_render_method = function() {
var goodregions = Y.all('.block-region[data-blockregion]').size();
var allregions = Y.all('.block-region').size();
this._isusingnewblocksmethod = (allregions === goodregions);
if (goodregions > 0 && allregions > 0) {
if (goodregions > 0 && allregions > 0 && goodregions !== allregions) {
Y.log('Both core_renderer::blocks and core_renderer::blocks_for_region have been used.', 'warn', 'moodle-core_blocks');
}
}
Expand Down 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:mouseDown', 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
4 changes: 2 additions & 2 deletions lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions lib/yui/build/moodle-core-blocks/moodle-core-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ M.core.blockdraganddrop.is_using_blocks_render_method = function() {
var goodregions = Y.all('.block-region[data-blockregion]').size();
var allregions = Y.all('.block-region').size();
this._isusingnewblocksmethod = (allregions === goodregions);
if (goodregions > 0 && allregions > 0) {
if (goodregions > 0 && allregions > 0 && goodregions !== allregions) {
}
}
return this._isusingnewblocksmethod;
Expand Down Expand Up @@ -439,7 +439,6 @@ MANAGER.prototype = {
i = 0,
region,
regionname,
droptarget,
dragdelegation;

// Evil required by M.core.dragdrop.
Expand Down Expand Up @@ -468,7 +467,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 @@ -488,9 +487,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:mouseDown', 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 @@ -531,11 +531,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
4 changes: 3 additions & 1 deletion lib/yui/build/moodle-core-dock/moodle-core-dock-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,9 @@ DOCK.prototype = {
BODY.addClass('used-region-'+regionname);
BODY.removeClass('empty-region-'+regionname);
BODY.removeClass('docked-region-'+regionname);
} else {
} else if (region.all('.block_dock_placeholder').size() > 0) {
// There are no blocks in the region but there are placeholders.
// All blocks in this region have been docked.
BODY.addClass('empty-region-'+regionname);
BODY.addClass('docked-region-'+regionname);
BODY.removeClass('used-region-'+regionname);
Expand Down
6 changes: 3 additions & 3 deletions lib/yui/build/moodle-core-dock/moodle-core-dock-min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/yui/build/moodle-core-dock/moodle-core-dock.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,9 @@ DOCK.prototype = {
BODY.addClass('used-region-'+regionname);
BODY.removeClass('empty-region-'+regionname);
BODY.removeClass('docked-region-'+regionname);
} else {
} else if (region.all('.block_dock_placeholder').size() > 0) {
// There are no blocks in the region but there are placeholders.
// All blocks in this region have been docked.
BODY.addClass('empty-region-'+regionname);
BODY.addClass('docked-region-'+regionname);
BODY.removeClass('used-region-'+regionname);
Expand Down
2 changes: 1 addition & 1 deletion lib/yui/src/blocks/js/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ M.core.blockdraganddrop.is_using_blocks_render_method = function() {
var goodregions = Y.all('.block-region[data-blockregion]').size();
var allregions = Y.all('.block-region').size();
this._isusingnewblocksmethod = (allregions === goodregions);
if (goodregions > 0 && allregions > 0) {
if (goodregions > 0 && allregions > 0 && goodregions !== allregions) {
Y.log('Both core_renderer::blocks and core_renderer::blocks_for_region have been used.', 'warn', 'moodle-core_blocks');
}
}
Expand Down
25 changes: 19 additions & 6 deletions lib/yui/src/blocks/js/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ MANAGER.prototype = {
i = 0,
region,
regionname,
droptarget,
dragdelegation;

// Evil required by M.core.dragdrop.
Expand Down Expand Up @@ -87,7 +86,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 @@ -107,9 +106,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:mouseDown', 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 @@ -151,11 +151,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
4 changes: 3 additions & 1 deletion lib/yui/src/dock/js/dock.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,9 @@ DOCK.prototype = {
BODY.addClass('used-region-'+regionname);
BODY.removeClass('empty-region-'+regionname);
BODY.removeClass('docked-region-'+regionname);
} else {
} else if (region.all('.block_dock_placeholder').size() > 0) {
// There are no blocks in the region but there are placeholders.
// All blocks in this region have been docked.
BODY.addClass('empty-region-'+regionname);
BODY.addClass('docked-region-'+regionname);
BODY.removeClass('used-region-'+regionname);
Expand Down

0 comments on commit 65ffd68

Please sign in to comment.