Merge branch 'MDL-43145-25' of git://github.com/andrewnicols/moodle into MOODLE_25_STABLE

This commit is contained in:
Sam Hemelryk
2014-04-22 10:39:17 +12:00
6 changed files with 72 additions and 27 deletions
+5 -1
View File
@@ -515,7 +515,11 @@ class block_manager {
$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;
}
@@ -359,7 +359,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');
}
}
@@ -451,7 +451,6 @@ MANAGER.prototype = {
i = 0,
region,
regionname,
droptarget,
dragdelegation;
// Evil required by M.core.dragdrop.
@@ -480,7 +479,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'
@@ -500,9 +499,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.remove_block_move_icons();
}
@@ -544,12 +544,25 @@ MANAGER.prototype = {
/**
* Enables all fo the regions so that they are all visible while dragging is occuring.
*
* @method enable_all_regions
* @returns {undefined}
*/
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();
}
},
@@ -783,7 +796,8 @@ Y.extend(MANAGER, M.core.dragdrop, MANAGER.prototype, {
value : []
}
}
});/**
});
/**
* This file contains the Block Region class used by the drag and drop manager.
*
* Provides drag and drop functionality for blocks.
File diff suppressed because one or more lines are too long
+22 -8
View File
@@ -359,7 +359,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;
@@ -447,7 +447,6 @@ MANAGER.prototype = {
i = 0,
region,
regionname,
droptarget,
dragdelegation;
// Evil required by M.core.dragdrop.
@@ -476,7 +475,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'
@@ -496,9 +495,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.remove_block_move_icons();
}
@@ -539,12 +539,25 @@ MANAGER.prototype = {
/**
* Enables all fo the regions so that they are all visible while dragging is occuring.
*
* @method enable_all_regions
* @returns {undefined}
*/
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();
}
},
@@ -778,7 +791,8 @@ Y.extend(MANAGER, M.core.dragdrop, MANAGER.prototype, {
value : []
}
}
});/**
});
/**
* This file contains the Block Region class used by the drag and drop manager.
*
* Provides drag and drop functionality for blocks.
+1 -1
View File
@@ -357,7 +357,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');
}
}
+20 -7
View File
@@ -58,7 +58,6 @@ MANAGER.prototype = {
i = 0,
region,
regionname,
droptarget,
dragdelegation;
// Evil required by M.core.dragdrop.
@@ -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'
@@ -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.remove_block_move_icons();
}
@@ -151,12 +151,25 @@ MANAGER.prototype = {
/**
* Enables all fo the regions so that they are all visible while dragging is occuring.
*
* @method enable_all_regions
* @returns {undefined}
*/
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();
}
},
@@ -390,4 +403,4 @@ Y.extend(MANAGER, M.core.dragdrop, MANAGER.prototype, {
value : []
}
}
});
});