From 2d724607e1081fb0b8c34240ff4291c341df7020 Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Fri, 22 Jun 2012 15:50:49 +0100 Subject: [PATCH] MDL-33890 Make course blocks less theme dependant 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. --- lib/yui/blocks/blocks.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/yui/blocks/blocks.js b/lib/yui/blocks/blocks.js index 21cc5f1a7dc..cec719f859b 100644 --- a/lib/yui/blocks/blocks.js +++ b/lib/yui/blocks/blocks.js @@ -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' @@ -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; @@ -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); @@ -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. @@ -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'); }