Skip to content

Commit

Permalink
MDL-33890 Make course blocks less theme dependant
Browse files Browse the repository at this point in the history
This fix checks that the empty block region is actaually the standard one, so
it can be hidden. The blocks move operating area is not resticted to page
content any more.
  • Loading branch information
Ruslan Kabalin authored and danpoltawski committed Jul 9, 2012
1 parent f19cd42 commit d212244
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/yui/blocks/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ YUI.add('moodle-core-blocks', function(Y) {
EDITINGMOVE : 'editing_move',
HEADER : 'header',
LIGHTBOX : 'lightbox',
PAGECONTENT : 'page-content',
REGIONCONTENT : 'region-content',
SKIPBLOCK : 'skip-block',
SKIPBLOCKTO : 'skip-block-to'
Expand All @@ -28,7 +27,8 @@ YUI.add('moodle-core-blocks', function(Y) {
this.parentnodeclass = CSS.REGIONCONTENT;

// Initialise blocks dragging
var blockregionlist = Y.Node.all('#'+CSS.PAGECONTENT+' div.'+CSS.BLOCKREGION);
// Find all block regions on the page
var blockregionlist = Y.Node.all('div.'+CSS.BLOCKREGION);

if (blockregionlist.size() === 0) {
return false;
Expand Down Expand Up @@ -84,9 +84,6 @@ YUI.add('moodle-core-blocks', function(Y) {
}).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
}).plug(Y.Plugin.DDWinScroll);
}
}, this);
Expand Down Expand Up @@ -139,6 +136,10 @@ YUI.add('moodle-core-blocks', function(Y) {
return false;
}

// TODO: Hiding-displaying block region only works for base theme blocks
// (region-pre, region-post) at the moment. It should be improved
// to work with custom block regions as well.

// TODO: Fix this for the case when user drag block towards empty section,
// then the section appears, then user chnages his mind and moving back to
// original section. The opposite section remains opened and empty.
Expand All @@ -151,9 +152,9 @@ YUI.add('moodle-core-blocks', function(Y) {
}

// Moving from empty region-content towards the opposite one,
// hide empty one
// hide empty one (only for region-pre, region-post areas at the moment).
regionname = this.get_region_id(drop.ancestor('div.'+CSS.BLOCKREGION));
if (this.dragsourceregion.all('.'+CSS.BLOCK).size() == 0) {
if (this.dragsourceregion.all('.'+CSS.BLOCK).size() == 0 && this.dragsourceregion.get('id').match(/(region-pre|region-post)/i)) {
if (!documentbody.hasClass('side-'+regionname+'-only')) {
documentbody.addClass('side-'+regionname+'-only');
}
Expand Down

0 comments on commit d212244

Please sign in to comment.