fix collapse bug

This commit is contained in:
carloslfu
2015-03-02 12:45:20 -05:00
parent b91471abdb
commit e0313dd6f1
2 changed files with 15 additions and 11 deletions

View File

@@ -807,16 +807,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

@@ -293,7 +293,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++) {
@@ -311,6 +310,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.