This commit is contained in:
Rachel Fenichel
2016-05-04 15:05:45 -07:00
parent f468b6a6cb
commit 640b38f38e
23 changed files with 191 additions and 128 deletions

View File

@@ -72,25 +72,54 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
/** @type {boolean} */
this.contextMenu = true;
/** @type {Blockly.Block} */
/**
* @type {Blockly.Block}
* @private
*/
this.parentBlock_ = null;
/** @type {!Array.<!Blockly.Block>} */
/**
* @type {!Array.<!Blockly.Block>}
* @private
*/
this.childBlocks_ = [];
/** @type {boolean} */
/** @type {boolean}
* @private
*/
this.deletable_ = true;
/** @type {boolean} */
/**
* @type {boolean}
* @private
*/
this.movable_ = true;
/** @type {boolean} */
/**
* @type {boolean}
* @private
*/
this.editable_ = true;
/** @type {boolean} */
/**
* @type {boolean}
* @private
*/
this.isShadow_ = false;
/** @type {boolean} */
/**
* @type {boolean}
* @private
*/
this.collapsed_ = false;
/** @type {string|Blockly.Comment} */
this.comment = null;
/** @type {!goog.math.Coordinate} */
/**
* @type {!goog.math.Coordinate}
* @private
*/
this.xy_ = new goog.math.Coordinate(0, 0);
/** @type {!Blockly.Workspace} */
@@ -193,13 +222,13 @@ Blockly.Block.prototype.dispose = function(healStack) {
}
// Then dispose of myself.
// Dispose of all inputs and their fields.
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, input; input = this.inputList[j]; j++) {
input.dispose();
}
this.inputList.length = 0;
// Dispose of any remaining connections (next/previous/output).
var connections = this.getConnections_(true);
for (var i = 0; i < connections.length; i++) {
for (i = 0; i < connections.length; i++) {
var connection = connections[i];
if (connection.isConnected()) {
connection.disconnect();
@@ -557,7 +586,7 @@ Blockly.Block.prototype.setConnectionsHidden = function(hidden) {
for (var i = 0, connection; connection = myConnections[i]; i++) {
connection.setHidden(hidden);
if (connection.isSuperior()) {
var child = connection.targetBlock();
child = connection.targetBlock();
if (child) {
child.setConnectionsHidden(hidden);
}
@@ -814,7 +843,7 @@ Blockly.Block.prototype.getInputsInline = function() {
return false;
}
}
for (var i = 1; i < this.inputList.length; i++) {
for (i = 1; i < this.inputList.length; i++) {
if (this.inputList[i - 1].type == Blockly.INPUT_VALUE &&
this.inputList[i].type == Blockly.DUMMY_INPUT) {
// Dummy input after a value input. Inline them.
@@ -1020,11 +1049,11 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
// Add last dummy input if needed.
if (elements.length && (typeof elements[elements.length - 1] == 'string' ||
elements[elements.length - 1]['type'].indexOf('field_') == 0)) {
var input = {type: 'input_dummy'};
var dummyInput = {type: 'input_dummy'};
if (lastDummyAlign) {
input['align'] = lastDummyAlign;
dummyInput['align'] = lastDummyAlign;
}
elements.push(input);
elements.push(dummyInput);
}
// Lookup of alignment constants.
var alignmentLookup = {
@@ -1034,7 +1063,7 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
};
// Populate block with inputs and fields.
var fieldStack = [];
for (var i = 0; i < elements.length; i++) {
for (i = 0; i < elements.length; i++) {
var element = elements[i];
if (typeof element == 'string') {
fieldStack.push([element, undefined]);