Merge pull request #78 from carloslfu/fix_collapse_bug

fix collapse bug
This commit is contained in:
Neil Fraser
2015-03-08 18:51:05 -07:00
2 changed files with 15 additions and 11 deletions

View File

@@ -808,16 +808,20 @@ Blockly.Block.prototype.setCollapsed = function(collapsed) {
*/
Blockly.Block.prototype.toString = function(opt_maxLength) {
var text = [];
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
text.push(field.getText());
}
if (input.connection) {
var child = input.connection.targetBlock();
if (child) {
text.push(child.toString());
} else {
text.push('?');
if(this.collapsed_) {
text.push(this.getInput('_TEMP_COLLAPSED_INPUT').fieldRow[0].text_);
} else {
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
text.push(field.getText());
}
if (input.connection) {
var child = input.connection.targetBlock();
if (child) {
text.push(child.toString());
} else {
text.push('?');
}
}
}
}

View File

@@ -325,7 +325,6 @@ Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) {
if (this.collapsed_ == collapsed) {
return;
}
Blockly.BlockSvg.superClass_.setCollapsed.call(this, collapsed);
var renderList = [];
// Show/hide the inputs.
for (var x = 0, input; input = this.inputList[x]; x++) {
@@ -343,6 +342,7 @@ Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) {
} else {
this.removeInput(COLLAPSED_INPUT_NAME);
}
Blockly.BlockSvg.superClass_.setCollapsed.call(this, collapsed);
if (!renderList.length) {
// No child blocks, just render this block.