Skip to content

Commit

Permalink
MDL-43281 Blocks: Retrieve a newly created block after creating it
Browse files Browse the repository at this point in the history
Although we were previously creating the DOM markup for a block region if
it did not exist, we were not making use of it.

This change ensures that we make use of that block region as part of the
blocks code.
  • Loading branch information
andrewnicols committed Dec 31, 2013
1 parent e71a533 commit 5aee250
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/yui/build/moodle-core-blocks/moodle-core-blocks-debug.js
Expand Up @@ -802,7 +802,7 @@ BLOCKREGION.prototype = {
Y.log('Block region `'+this.get('region')+'` initialising', 'info');
if (!node) {
Y.log('block region known about but no HTML structure found for it. Guessing structure.', 'warn');
this.create_and_add_node();
node = this.create_and_add_node();
}
var body = Y.one('body'),
hasblocks = node.all('.'+CSS.BLOCK).size() > 0,
Expand All @@ -818,6 +818,7 @@ BLOCKREGION.prototype = {
* Creates a generic block region node and adds it to the DOM at the best guess location.
* Any calling of this method is an unfortunate circumstance.
* @method create_and_add_node
* @return Node The newly created Node
*/
create_and_add_node : function() {
var c = Y.Node.create,
Expand Down Expand Up @@ -860,6 +861,8 @@ BLOCKREGION.prototype = {
Y.one('body').append(node);
}
this.set('node', node);

return node;
},

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/yui/build/moodle-core-blocks/moodle-core-blocks-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/yui/build/moodle-core-blocks/moodle-core-blocks.js
Expand Up @@ -798,7 +798,7 @@ BLOCKREGION.prototype = {
initializer : function() {
var node = this.get('node');
if (!node) {
this.create_and_add_node();
node = this.create_and_add_node();
}
var body = Y.one('body'),
hasblocks = node.all('.'+CSS.BLOCK).size() > 0,
Expand All @@ -814,6 +814,7 @@ BLOCKREGION.prototype = {
* Creates a generic block region node and adds it to the DOM at the best guess location.
* Any calling of this method is an unfortunate circumstance.
* @method create_and_add_node
* @return Node The newly created Node
*/
create_and_add_node : function() {
var c = Y.Node.create,
Expand Down Expand Up @@ -856,6 +857,8 @@ BLOCKREGION.prototype = {
Y.one('body').append(node);
}
this.set('node', node);

return node;
},

/**
Expand Down
5 changes: 4 additions & 1 deletion lib/yui/src/blocks/js/blockregion.js
Expand Up @@ -27,7 +27,7 @@ BLOCKREGION.prototype = {
Y.log('Block region `'+this.get('region')+'` initialising', 'info');
if (!node) {
Y.log('block region known about but no HTML structure found for it. Guessing structure.', 'warn');
this.create_and_add_node();
node = this.create_and_add_node();
}
var body = Y.one('body'),
hasblocks = node.all('.'+CSS.BLOCK).size() > 0,
Expand All @@ -43,6 +43,7 @@ BLOCKREGION.prototype = {
* Creates a generic block region node and adds it to the DOM at the best guess location.
* Any calling of this method is an unfortunate circumstance.
* @method create_and_add_node
* @return Node The newly created Node
*/
create_and_add_node : function() {
var c = Y.Node.create,
Expand Down Expand Up @@ -85,6 +86,8 @@ BLOCKREGION.prototype = {
Y.one('body').append(node);
}
this.set('node', node);

return node;
},

/**
Expand Down

0 comments on commit 5aee250

Please sign in to comment.