|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
goog.provide('Blockly.Block');
|
|
|
|
goog.require('Blockly.Blocks');
|
|
goog.require('Blockly.Colours');
|
|
goog.require('Blockly.Comment');
|
|
goog.require('Blockly.ScratchBlockComment');
|
|
goog.require('Blockly.Connection');
|
|
goog.require('Blockly.Events.BlockChange');
|
|
goog.require('Blockly.Events.BlockCreate');
|
|
goog.require('Blockly.Events.BlockDelete');
|
|
goog.require('Blockly.Events.BlockMove');
|
|
goog.require('Blockly.Extensions');
|
|
goog.require('Blockly.FieldLabelSerializable');
|
|
goog.require('Blockly.FieldVariableGetter');
|
|
goog.require('Blockly.Input');
|
|
goog.require('Blockly.Mutator');
|
|
goog.require('Blockly.Warning');
|
|
goog.require('Blockly.Workspace');
|
|
goog.require('Blockly.Xml');
|
|
goog.require('goog.array');
|
|
goog.require('goog.asserts');
|
|
goog.require('goog.math.Coordinate');
|
|
goog.require('goog.string');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block = function(workspace, prototypeName, opt_id) {
|
|
var flyoutWorkspace = workspace && workspace.getFlyout && workspace.getFlyout() ?
|
|
workspace.getFlyout().getWorkspace() : null;
|
|
|
|
this.id = (opt_id && !workspace.getBlockById(opt_id) &&
|
|
(!flyoutWorkspace || !flyoutWorkspace.getBlockById(opt_id))) ?
|
|
opt_id : Blockly.utils.genUid();
|
|
workspace.blockDB_[this.id] = this;
|
|
|
|
this.outputConnection = null;
|
|
|
|
this.nextConnection = null;
|
|
|
|
this.previousConnection = null;
|
|
|
|
this.inputList = [];
|
|
|
|
this.inputsInline = true;
|
|
|
|
this.disabled = false;
|
|
|
|
this.tooltip = '';
|
|
|
|
this.contextMenu = true;
|
|
|
|
|
|
|
|
|
|
|
|
this.parentBlock_ = null;
|
|
|
|
|
|
|
|
|
|
|
|
this.childBlocks_ = [];
|
|
|
|
|
|
|
|
|
|
|
|
this.deletable_ = true;
|
|
|
|
|
|
|
|
|
|
|
|
this.movable_ = true;
|
|
|
|
|
|
|
|
|
|
|
|
this.editable_ = true;
|
|
|
|
|
|
|
|
|
|
|
|
this.isShadow_ = false;
|
|
|
|
|
|
|
|
|
|
|
|
this.collapsed_ = false;
|
|
|
|
|
|
|
|
|
|
|
|
this.checkboxInFlyout_ = false;
|
|
|
|
|
|
|
|
|
|
|
|
this.canDragDuplicate_ = false;
|
|
|
|
|
|
this.comment = null;
|
|
|
|
|
|
|
|
|
|
|
|
this.outputShape_ = null;
|
|
|
|
|
|
|
|
|
|
|
|
this.category_ = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.xy_ = new goog.math.Coordinate(0, 0);
|
|
|
|
|
|
this.workspace = workspace;
|
|
|
|
this.isInFlyout = workspace.isFlyout;
|
|
|
|
this.isInMutator = workspace.isMutator;
|
|
|
|
|
|
this.RTL = workspace.RTL;
|
|
|
|
|
|
this.isInsertionMarker_ = false;
|
|
|
|
|
|
if (prototypeName) {
|
|
|
|
this.type = prototypeName;
|
|
var prototype = Blockly.Blocks[prototypeName];
|
|
goog.asserts.assertObject(prototype,
|
|
'Error: Unknown block type "%s".', prototypeName);
|
|
goog.mixin(this, prototype);
|
|
}
|
|
|
|
workspace.addTopBlock(this);
|
|
|
|
|
|
if (goog.isFunction(this.init)) {
|
|
this.init();
|
|
}
|
|
|
|
|
|
this.inputsInlineDefault = this.inputsInline;
|
|
|
|
|
|
if (Blockly.Events.isEnabled()) {
|
|
var existingGroup = Blockly.Events.getGroup();
|
|
if (!existingGroup) {
|
|
Blockly.Events.setGroup(true);
|
|
}
|
|
try {
|
|
Blockly.Events.fire(new Blockly.Events.BlockCreate(this));
|
|
} finally {
|
|
if (!existingGroup) {
|
|
Blockly.Events.setGroup(false);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (goog.isFunction(this.onchange)) {
|
|
this.setOnChange(this.onchange);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.data = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.colour_ = '#FF0000';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.colourSecondary_ = '#FF0000';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.colourTertiary_ = '#FF0000';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.shadowColour_ = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.dispose = function(healStack) {
|
|
if (!this.workspace) {
|
|
|
|
return;
|
|
}
|
|
|
|
if (this.onchangeWrapper_) {
|
|
this.workspace.removeChangeListener(this.onchangeWrapper_);
|
|
}
|
|
this.unplug(healStack);
|
|
if (Blockly.Events.isEnabled()) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockDelete(this));
|
|
}
|
|
Blockly.Events.disable();
|
|
|
|
try {
|
|
|
|
|
|
if (this.workspace) {
|
|
this.workspace.removeTopBlock(this);
|
|
|
|
delete this.workspace.blockDB_[this.id];
|
|
this.workspace = null;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Blockly.selected == this) {
|
|
Blockly.selected = null;
|
|
}
|
|
|
|
|
|
for (var i = this.childBlocks_.length - 1; i >= 0; i--) {
|
|
this.childBlocks_[i].dispose(false);
|
|
}
|
|
|
|
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
input.dispose();
|
|
}
|
|
this.inputList.length = 0;
|
|
|
|
var connections = this.getConnections_(true);
|
|
for (var i = 0; i < connections.length; i++) {
|
|
var connection = connections[i];
|
|
if (connection.isConnected()) {
|
|
connection.disconnect();
|
|
}
|
|
connections[i].dispose();
|
|
}
|
|
} finally {
|
|
Blockly.Events.enable();
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.initModel = function() {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field.initModel) {
|
|
field.initModel();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.unplug = function(opt_healStack) {
|
|
if (this.outputConnection) {
|
|
if (this.outputConnection.isConnected()) {
|
|
|
|
this.outputConnection.disconnect();
|
|
}
|
|
} else {
|
|
if (this.previousConnection) {
|
|
var previousTarget = null;
|
|
if (this.previousConnection.isConnected()) {
|
|
|
|
previousTarget = this.previousConnection.targetConnection;
|
|
|
|
this.previousConnection.disconnect();
|
|
}
|
|
}
|
|
var nextBlock = this.getNextBlock();
|
|
if (opt_healStack && nextBlock) {
|
|
|
|
var nextTarget = this.nextConnection.targetConnection;
|
|
nextTarget.disconnect();
|
|
if (previousTarget && previousTarget.checkType_(nextTarget)) {
|
|
|
|
previousTarget.connect(nextTarget);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getConnections_ = function() {
|
|
var myConnections = [];
|
|
if (this.outputConnection) {
|
|
myConnections.push(this.outputConnection);
|
|
}
|
|
if (this.previousConnection) {
|
|
myConnections.push(this.previousConnection);
|
|
}
|
|
if (this.nextConnection) {
|
|
myConnections.push(this.nextConnection);
|
|
}
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.connection) {
|
|
myConnections.push(input.connection);
|
|
}
|
|
}
|
|
return myConnections;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.lastConnectionInStack = function() {
|
|
var nextConnection = this.nextConnection;
|
|
while (nextConnection) {
|
|
var nextBlock = nextConnection.targetBlock();
|
|
if (!nextBlock) {
|
|
|
|
return nextConnection;
|
|
}
|
|
nextConnection = nextBlock.nextConnection;
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.bumpNeighbours_ = function() {
|
|
console.warn('Not expected to reach this bumpNeighbours_ function. The ' +
|
|
'BlockSvg function for bumpNeighbours_ was expected to be called instead.');
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getParent = function() {
|
|
|
|
return this.parentBlock_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getInputWithBlock = function(block) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.connection && input.connection.targetBlock() == block) {
|
|
return input;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getInputWithConnection = function(conn) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.connection == conn) {
|
|
return input;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getSurroundParent = function() {
|
|
var block = this;
|
|
do {
|
|
var prevBlock = block;
|
|
block = block.getParent();
|
|
if (!block) {
|
|
|
|
return null;
|
|
}
|
|
} while (block.getNextBlock() == prevBlock);
|
|
|
|
return block;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getNextBlock = function() {
|
|
return this.nextConnection && this.nextConnection.targetBlock();
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getPreviousBlock = function() {
|
|
return this.previousConnection && this.previousConnection.targetBlock();
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getFirstStatementConnection = function() {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.connection && input.connection.type == Blockly.NEXT_STATEMENT) {
|
|
return input.connection;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getRootBlock = function() {
|
|
var rootBlock;
|
|
var block = this;
|
|
do {
|
|
rootBlock = block;
|
|
block = rootBlock.parentBlock_;
|
|
} while (block);
|
|
return rootBlock;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getChildren = function(ordered) {
|
|
if (!ordered) {
|
|
return this.childBlocks_;
|
|
}
|
|
var blocks = [];
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.connection) {
|
|
var child = input.connection.targetBlock();
|
|
if (child) {
|
|
blocks.push(child);
|
|
}
|
|
}
|
|
}
|
|
var next = this.getNextBlock();
|
|
if (next) {
|
|
blocks.push(next);
|
|
}
|
|
return blocks;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setParent = function(newParent) {
|
|
if (newParent == this.parentBlock_) {
|
|
return;
|
|
}
|
|
if (this.parentBlock_) {
|
|
|
|
goog.array.remove(this.parentBlock_.childBlocks_, this);
|
|
|
|
|
|
if (this.previousConnection && this.previousConnection.isConnected()) {
|
|
throw 'Still connected to previous block.';
|
|
}
|
|
if (this.outputConnection && this.outputConnection.isConnected()) {
|
|
throw 'Still connected to parent block.';
|
|
}
|
|
this.parentBlock_ = null;
|
|
|
|
|
|
} else {
|
|
|
|
this.workspace.removeTopBlock(this);
|
|
}
|
|
|
|
this.parentBlock_ = newParent;
|
|
if (newParent) {
|
|
|
|
newParent.childBlocks_.push(this);
|
|
} else {
|
|
this.workspace.addTopBlock(this);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getDescendants = function(ordered, opt_ignoreShadows) {
|
|
var blocks = [this];
|
|
var childBlocks = this.getChildren(ordered);
|
|
for (var child, i = 0; child = childBlocks[i]; i++) {
|
|
if (!opt_ignoreShadows || !child.isShadow_) {
|
|
blocks.push.apply(
|
|
blocks, child.getDescendants(ordered, opt_ignoreShadows));
|
|
}
|
|
}
|
|
return blocks;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.isDeletable = function() {
|
|
return this.deletable_ && !this.isShadow_ &&
|
|
!(this.workspace && this.workspace.options.readOnly);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setDeletable = function(deletable) {
|
|
this.deletable_ = deletable;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.isMovable = function() {
|
|
return this.movable_ && !this.isShadow_ &&
|
|
!(this.workspace && this.workspace.options.readOnly);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setMovable = function(movable) {
|
|
this.movable_ = movable;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.isShadow = function() {
|
|
return this.isShadow_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setShadow = function(shadow) {
|
|
this.isShadow_ = shadow;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.isInsertionMarker = function() {
|
|
return this.isInsertionMarker_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setInsertionMarker = function(insertionMarker) {
|
|
if (this.isInsertionMarker_ == insertionMarker) {
|
|
return;
|
|
}
|
|
this.isInsertionMarker_ = insertionMarker;
|
|
|
|
if (this.isInsertionMarker_) {
|
|
this.setColour(Blockly.Colours.insertionMarker);
|
|
this.setOpacity(Blockly.Colours.insertionMarkerOpacity);
|
|
Blockly.utils.addClass( (this.svgGroup_),
|
|
'blocklyInsertionMarker');
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.isEditable = function() {
|
|
return this.editable_ && !(this.workspace && this.workspace.options.readOnly);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setEditable = function(editable) {
|
|
this.editable_ = editable;
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
field.updateEditable();
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setConnectionsHidden = function(hidden) {
|
|
if (!hidden && this.isCollapsed()) {
|
|
if (this.outputConnection) {
|
|
this.outputConnection.setHidden(hidden);
|
|
}
|
|
if (this.previousConnection) {
|
|
this.previousConnection.setHidden(hidden);
|
|
}
|
|
if (this.nextConnection) {
|
|
this.nextConnection.setHidden(hidden);
|
|
var child = this.nextConnection.targetBlock();
|
|
if (child) {
|
|
child.setConnectionsHidden(hidden);
|
|
}
|
|
}
|
|
} else {
|
|
var myConnections = this.getConnections_(true);
|
|
for (var i = 0, connection; connection = myConnections[i]; i++) {
|
|
connection.setHidden(hidden);
|
|
if (connection.isSuperior()) {
|
|
var child = connection.targetBlock();
|
|
if (child) {
|
|
child.setConnectionsHidden(hidden);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getMatchingConnection = function(otherBlock, conn) {
|
|
var connections = this.getConnections_(true);
|
|
var otherConnections = otherBlock.getConnections_(true);
|
|
if (connections.length != otherConnections.length) {
|
|
throw "Connection lists did not match in length.";
|
|
}
|
|
for (var i = 0; i < otherConnections.length; i++) {
|
|
if (otherConnections[i] == conn) {
|
|
return connections[i];
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setHelpUrl = function(url) {
|
|
this.helpUrl = url;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setTooltip = function(newTip) {
|
|
this.tooltip = newTip;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getColour = function() {
|
|
return this.colour_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getColourSecondary = function() {
|
|
return this.colourSecondary_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getColourTertiary = function() {
|
|
return this.colourTertiary_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getShadowColour = function() {
|
|
return this.shadowColour_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setShadowColour = function(colour) {
|
|
this.shadowColour_ = this.makeColour_(colour);
|
|
if (this.rendered) {
|
|
this.updateColour();
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.clearShadowColour = function() {
|
|
this.shadowColour_ = null;
|
|
if (this.rendered) {
|
|
this.updateColour();
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.makeColour_ = function(colour) {
|
|
var hue = Number(colour);
|
|
if (!isNaN(hue)) {
|
|
return Blockly.hueToRgb(hue);
|
|
} else if (goog.isString(colour) && colour.match(/^#[0-9a-fA-F]{6,8}$/)) {
|
|
return colour;
|
|
} else {
|
|
throw 'Invalid colour: ' + colour;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setColour = function(colour, colourSecondary, colourTertiary) {
|
|
this.colour_ = this.makeColour_(colour);
|
|
if (colourSecondary !== undefined) {
|
|
this.colourSecondary_ = this.makeColour_(colourSecondary);
|
|
} else {
|
|
this.colourSecondary_ = goog.color.rgbArrayToHex(
|
|
goog.color.darken(goog.color.hexToRgb(this.colour_), 0.1));
|
|
}
|
|
if (colourTertiary !== undefined) {
|
|
this.colourTertiary_ = this.makeColour_(colourTertiary);
|
|
} else {
|
|
this.colourTertiary_ = goog.color.rgbArrayToHex(
|
|
goog.color.darken(goog.color.hexToRgb(this.colour_), 0.2));
|
|
}
|
|
if (this.rendered) {
|
|
this.updateColour();
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setOnChange = function(onchangeFn) {
|
|
if (onchangeFn && !goog.isFunction(onchangeFn)) {
|
|
throw new Error("onchange must be a function.");
|
|
}
|
|
if (this.onchangeWrapper_) {
|
|
this.workspace.removeChangeListener(this.onchangeWrapper_);
|
|
}
|
|
this.onchange = onchangeFn;
|
|
if (this.onchange) {
|
|
this.onchangeWrapper_ = onchangeFn.bind(this);
|
|
this.workspace.addChangeListener(this.onchangeWrapper_);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getField = function(name) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field.name === name) {
|
|
return field;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getVars = function() {
|
|
var vars = [];
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field.referencesVariables()) {
|
|
vars.push(field.getValue());
|
|
}
|
|
}
|
|
}
|
|
return vars;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getVarModels = function() {
|
|
var vars = [];
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field.referencesVariables()) {
|
|
var model = this.workspace.getVariableById(field.getValue());
|
|
|
|
|
|
if (model) {
|
|
vars.push(model);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return vars;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.updateVarName = function(variable) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field.referencesVariables() &&
|
|
variable.getId() == field.getValue()) {
|
|
field.setText(variable.name);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.renameVarById = function(oldId, newId) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
|
if (field.referencesVariables() &&
|
|
oldId == field.getValue()) {
|
|
field.setValue(newId);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getFieldValue = function(name) {
|
|
var field = this.getField(name);
|
|
if (field) {
|
|
return field.getValue();
|
|
}
|
|
return null;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setFieldValue = function(newValue, name) {
|
|
var field = this.getField(name);
|
|
goog.asserts.assertObject(field, 'Field "%s" not found.', name);
|
|
field.setValue(newValue);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setPreviousStatement = function(newBoolean, opt_check) {
|
|
if (newBoolean) {
|
|
if (opt_check === undefined) {
|
|
opt_check = null;
|
|
}
|
|
if (!this.previousConnection) {
|
|
goog.asserts.assert(!this.outputConnection,
|
|
'Remove output connection prior to adding previous connection.');
|
|
this.previousConnection =
|
|
this.makeConnection_(Blockly.PREVIOUS_STATEMENT);
|
|
}
|
|
this.previousConnection.setCheck(opt_check);
|
|
} else {
|
|
if (this.previousConnection) {
|
|
goog.asserts.assert(!this.previousConnection.isConnected(),
|
|
'Must disconnect previous statement before removing connection.');
|
|
this.previousConnection.dispose();
|
|
this.previousConnection = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setNextStatement = function(newBoolean, opt_check) {
|
|
if (newBoolean) {
|
|
if (opt_check === undefined) {
|
|
opt_check = null;
|
|
}
|
|
if (!this.nextConnection) {
|
|
this.nextConnection = this.makeConnection_(Blockly.NEXT_STATEMENT);
|
|
}
|
|
this.nextConnection.setCheck(opt_check);
|
|
} else {
|
|
if (this.nextConnection) {
|
|
goog.asserts.assert(!this.nextConnection.isConnected(),
|
|
'Must disconnect next statement before removing connection.');
|
|
this.nextConnection.dispose();
|
|
this.nextConnection = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setOutput = function(newBoolean, opt_check) {
|
|
if (newBoolean) {
|
|
if (opt_check === undefined) {
|
|
opt_check = null;
|
|
}
|
|
if (!this.outputConnection) {
|
|
goog.asserts.assert(!this.previousConnection,
|
|
'Remove previous connection prior to adding output connection.');
|
|
this.outputConnection = this.makeConnection_(Blockly.OUTPUT_VALUE);
|
|
}
|
|
this.outputConnection.setCheck(opt_check);
|
|
} else {
|
|
if (this.outputConnection) {
|
|
goog.asserts.assert(!this.outputConnection.isConnected(),
|
|
'Must disconnect output value before removing connection.');
|
|
this.outputConnection.dispose();
|
|
this.outputConnection = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setInputsInline = function(newBoolean) {
|
|
if (this.inputsInline != newBoolean) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
|
this, 'inline', null, this.inputsInline, newBoolean));
|
|
this.inputsInline = newBoolean;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getInputsInline = function() {
|
|
if (this.inputsInline != undefined) {
|
|
|
|
return this.inputsInline;
|
|
}
|
|
|
|
for (var i = 1; i < this.inputList.length; i++) {
|
|
if (this.inputList[i - 1].type == Blockly.DUMMY_INPUT &&
|
|
this.inputList[i].type == Blockly.DUMMY_INPUT) {
|
|
|
|
return false;
|
|
}
|
|
}
|
|
for (var i = 1; i < this.inputList.length; i++) {
|
|
if (this.inputList[i - 1].type == Blockly.INPUT_VALUE &&
|
|
this.inputList[i].type == Blockly.DUMMY_INPUT) {
|
|
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setDisabled = function(disabled) {
|
|
if (this.disabled != disabled) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
|
this, 'disabled', null, this.disabled, disabled));
|
|
this.disabled = disabled;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getInheritedDisabled = function() {
|
|
var ancestor = this.getSurroundParent();
|
|
while (ancestor) {
|
|
if (ancestor.disabled) {
|
|
return true;
|
|
}
|
|
ancestor = ancestor.getSurroundParent();
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.isCollapsed = function() {
|
|
return this.collapsed_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setCollapsed = function(collapsed) {
|
|
if (this.collapsed_ != collapsed) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
|
this, 'collapsed', null, this.collapsed_, collapsed));
|
|
this.collapsed_ = collapsed;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.toString = function(opt_maxLength, opt_emptyToken) {
|
|
var text = [];
|
|
var emptyFieldPlaceholder = opt_emptyToken || '?';
|
|
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++) {
|
|
if (field instanceof Blockly.FieldDropdown && !field.getValue()) {
|
|
text.push(emptyFieldPlaceholder);
|
|
} else {
|
|
text.push(field.getText());
|
|
}
|
|
}
|
|
if (input.connection) {
|
|
var child = input.connection.targetBlock();
|
|
if (child) {
|
|
text.push(child.toString(undefined, opt_emptyToken));
|
|
} else {
|
|
text.push(emptyFieldPlaceholder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
text = goog.string.trim(text.join(' ')) || '???';
|
|
if (opt_maxLength) {
|
|
|
|
|
|
|
|
text = goog.string.truncate(text, opt_maxLength);
|
|
}
|
|
return text;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.appendValueInput = function(name) {
|
|
return this.appendInput_(Blockly.INPUT_VALUE, name);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.appendStatementInput = function(name) {
|
|
return this.appendInput_(Blockly.NEXT_STATEMENT, name);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.appendDummyInput = function(opt_name) {
|
|
return this.appendInput_(Blockly.DUMMY_INPUT, opt_name || '');
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.jsonInit = function(json) {
|
|
var warningPrefix = json['type'] ? 'Block "' + json['type'] + '": ' : '';
|
|
|
|
|
|
goog.asserts.assert(
|
|
json['output'] == undefined || json['previousStatement'] == undefined,
|
|
warningPrefix + 'Must not have both an output and a previousStatement.');
|
|
|
|
|
|
if (json['colour'] !== undefined) {
|
|
this.setColourFromJson_(json);
|
|
}
|
|
|
|
|
|
var i = 0;
|
|
while (json['message' + i] !== undefined) {
|
|
this.interpolate_(json['message' + i], json['args' + i] || [],
|
|
json['lastDummyAlign' + i]);
|
|
i++;
|
|
}
|
|
|
|
if (json['inputsInline'] !== undefined) {
|
|
this.setInputsInline(json['inputsInline']);
|
|
}
|
|
|
|
if (json['output'] !== undefined) {
|
|
this.setOutput(true, json['output']);
|
|
}
|
|
if (json['previousStatement'] !== undefined) {
|
|
this.setPreviousStatement(true, json['previousStatement']);
|
|
}
|
|
if (json['nextStatement'] !== undefined) {
|
|
this.setNextStatement(true, json['nextStatement']);
|
|
}
|
|
if (json['tooltip'] !== undefined) {
|
|
var rawValue = json['tooltip'];
|
|
var localizedText = Blockly.utils.replaceMessageReferences(rawValue);
|
|
this.setTooltip(localizedText);
|
|
}
|
|
if (json['enableContextMenu'] !== undefined) {
|
|
var rawValue = json['enableContextMenu'];
|
|
this.contextMenu = !!rawValue;
|
|
}
|
|
if (json['helpUrl'] !== undefined) {
|
|
var rawValue = json['helpUrl'];
|
|
var localizedValue = Blockly.utils.replaceMessageReferences(rawValue);
|
|
this.setHelpUrl(localizedValue);
|
|
}
|
|
if (goog.isString(json['extensions'])) {
|
|
console.warn('JSON attribute \'extensions\' should be an array of ' +
|
|
'strings. Found raw string in JSON for \'' + json['type'] + '\' block.');
|
|
json['extensions'] = [json['extensions']];
|
|
}
|
|
|
|
|
|
if (json['mutator'] !== undefined) {
|
|
Blockly.Extensions.apply(json['mutator'], this, true);
|
|
}
|
|
|
|
if (Array.isArray(json['extensions'])) {
|
|
var extensionNames = json['extensions'];
|
|
for (var i = 0; i < extensionNames.length; ++i) {
|
|
var extensionName = extensionNames[i];
|
|
Blockly.Extensions.apply(extensionName, this, false);
|
|
}
|
|
}
|
|
if (json['outputShape'] !== undefined) {
|
|
this.setOutputShape(json['outputShape']);
|
|
}
|
|
if (json['canDragDuplicate'] !== undefined) {
|
|
this.setDragDuplication(json['canDragDuplicate']);
|
|
}
|
|
if (json['checkboxInFlyout'] !== undefined) {
|
|
this.setCheckboxInFlyout(json['checkboxInFlyout']);
|
|
}
|
|
if (json['category'] !== undefined) {
|
|
this.setCategory(json['category']);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
|
|
if (goog.isDef(opt_disableCheck) && !goog.isBoolean(opt_disableCheck)) {
|
|
throw new Error("opt_disableCheck must be a boolean if provided");
|
|
}
|
|
if (!opt_disableCheck) {
|
|
var overwrites = [];
|
|
for (var key in mixinObj) {
|
|
if (this[key] !== undefined) {
|
|
overwrites.push(key);
|
|
}
|
|
}
|
|
if (overwrites.length) {
|
|
throw new Error('Mixin will overwrite block members: ' +
|
|
JSON.stringify(overwrites));
|
|
}
|
|
}
|
|
goog.mixin(this, mixinObj);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setColourFromRawValues_ = function(primary, secondary,
|
|
tertiary) {
|
|
primary = goog.isString(primary) ?
|
|
Blockly.utils.replaceMessageReferences(primary) : primary;
|
|
secondary = goog.isString(secondary) ?
|
|
Blockly.utils.replaceMessageReferences(secondary) : secondary;
|
|
tertiary = goog.isString(tertiary) ?
|
|
Blockly.utils.replaceMessageReferences(tertiary) : tertiary;
|
|
|
|
this.setColour(primary, secondary, tertiary);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setColourFromJson_ = function(json) {
|
|
this.setColourFromRawValues_(json['colour'], json['colourSecondary'],
|
|
json['colourTertiary']);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
|
|
var tokens = Blockly.utils.tokenizeInterpolation(message);
|
|
|
|
var indexDup = [];
|
|
var indexCount = 0;
|
|
var elements = [];
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
var token = tokens[i];
|
|
if (typeof token == 'number') {
|
|
if (token <= 0 || token > args.length) {
|
|
throw new Error('Block "' + this.type + '": ' +
|
|
'Message index %' + token + ' out of range.');
|
|
}
|
|
if (indexDup[token]) {
|
|
throw new Error('Block "' + this.type + '": ' +
|
|
'Message index %' + token + ' duplicated.');
|
|
}
|
|
indexDup[token] = true;
|
|
indexCount++;
|
|
elements.push(args[token - 1]);
|
|
} else {
|
|
token = token.trim();
|
|
if (token) {
|
|
elements.push(token);
|
|
}
|
|
}
|
|
}
|
|
if (indexCount != args.length) {
|
|
throw new Error('Block "' + this.type + '": ' +
|
|
'Message does not reference all ' + args.length + ' arg(s).');
|
|
}
|
|
|
|
if (elements.length && (typeof elements[elements.length - 1] == 'string' ||
|
|
goog.string.startsWith(
|
|
elements[elements.length - 1]['type'], 'field_'))) {
|
|
var dummyInput = {type: 'input_dummy'};
|
|
if (lastDummyAlign) {
|
|
dummyInput['align'] = lastDummyAlign;
|
|
}
|
|
elements.push(dummyInput);
|
|
}
|
|
|
|
var alignmentLookup = {
|
|
'LEFT': Blockly.ALIGN_LEFT,
|
|
'RIGHT': Blockly.ALIGN_RIGHT,
|
|
'CENTRE': Blockly.ALIGN_CENTRE
|
|
};
|
|
|
|
var fieldStack = [];
|
|
for (var i = 0; i < elements.length; i++) {
|
|
var element = elements[i];
|
|
if (typeof element == 'string') {
|
|
fieldStack.push([element, undefined]);
|
|
} else {
|
|
var field = null;
|
|
var input = null;
|
|
do {
|
|
var altRepeat = false;
|
|
if (typeof element == 'string') {
|
|
field = new Blockly.FieldLabel(element);
|
|
} else {
|
|
switch (element['type']) {
|
|
case 'input_value':
|
|
input = this.appendValueInput(element['name']);
|
|
break;
|
|
case 'input_statement':
|
|
input = this.appendStatementInput(element['name']);
|
|
break;
|
|
case 'input_dummy':
|
|
input = this.appendDummyInput(element['name']);
|
|
break;
|
|
default:
|
|
field = Blockly.Field.fromJson(element);
|
|
|
|
|
|
if (!field) {
|
|
if (element['alt']) {
|
|
element = element['alt'];
|
|
altRepeat = true;
|
|
} else {
|
|
console.warn('Blockly could not create a field of type ' +
|
|
element['type'] +
|
|
'. You may need to register your custom field. See ' +
|
|
'github.com/google/blockly/issues/1584');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} while (altRepeat);
|
|
if (field) {
|
|
fieldStack.push([field, element['name']]);
|
|
} else if (input) {
|
|
if (element['shape']) {
|
|
input.setShape(element['shape']);
|
|
}
|
|
if (element['check']) {
|
|
input.setCheck(element['check']);
|
|
}
|
|
if (element['align']) {
|
|
input.setAlign(alignmentLookup[element['align']]);
|
|
}
|
|
for (var j = 0; j < fieldStack.length; j++) {
|
|
input.appendField(fieldStack[j][0], fieldStack[j][1]);
|
|
}
|
|
fieldStack.length = 0;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.appendInput_ = function(type, name) {
|
|
var connection = null;
|
|
if (type == Blockly.INPUT_VALUE || type == Blockly.NEXT_STATEMENT) {
|
|
connection = this.makeConnection_(type);
|
|
}
|
|
var input = new Blockly.Input(type, name, this, connection);
|
|
|
|
this.inputList.push(input);
|
|
return input;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.moveInputBefore = function(name, refName) {
|
|
if (name == refName) {
|
|
return;
|
|
}
|
|
|
|
var inputIndex = -1;
|
|
var refIndex = refName ? -1 : this.inputList.length;
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.name == name) {
|
|
inputIndex = i;
|
|
if (refIndex != -1) {
|
|
break;
|
|
}
|
|
} else if (refName && input.name == refName) {
|
|
refIndex = i;
|
|
if (inputIndex != -1) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
goog.asserts.assert(inputIndex != -1, 'Named input "%s" not found.', name);
|
|
goog.asserts.assert(
|
|
refIndex != -1, 'Reference input "%s" not found.', refName);
|
|
this.moveNumberedInputBefore(inputIndex, refIndex);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.moveNumberedInputBefore = function(
|
|
inputIndex, refIndex) {
|
|
|
|
goog.asserts.assert(inputIndex != refIndex, 'Can\'t move input to itself.');
|
|
goog.asserts.assert(inputIndex < this.inputList.length,
|
|
'Input index ' + inputIndex + ' out of bounds.');
|
|
goog.asserts.assert(refIndex <= this.inputList.length,
|
|
'Reference input ' + refIndex + ' out of bounds.');
|
|
|
|
var input = this.inputList[inputIndex];
|
|
this.inputList.splice(inputIndex, 1);
|
|
if (inputIndex < refIndex) {
|
|
refIndex--;
|
|
}
|
|
|
|
this.inputList.splice(refIndex, 0, input);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.name == name) {
|
|
if (input.connection && input.connection.isConnected()) {
|
|
input.connection.setShadowDom(null);
|
|
var block = input.connection.targetBlock();
|
|
if (block.isShadow()) {
|
|
|
|
block.dispose();
|
|
} else {
|
|
|
|
block.unplug();
|
|
}
|
|
}
|
|
input.dispose();
|
|
this.inputList.splice(i, 1);
|
|
return;
|
|
}
|
|
}
|
|
if (!opt_quiet) {
|
|
goog.asserts.fail('Input "%s" not found.', name);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getInput = function(name) {
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (input.name == name) {
|
|
return input;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getInputTargetBlock = function(name) {
|
|
var input = this.getInput(name);
|
|
return input && input.connection && input.connection.targetBlock();
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getCommentText = function() {
|
|
return this.comment || '';
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setCommentText = function(text) {
|
|
if (this.comment != text) {
|
|
Blockly.Events.fire(new Blockly.Events.BlockChange(
|
|
this, 'comment', null, this.comment, text || ''));
|
|
this.comment = text;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setOutputShape = function(outputShape) {
|
|
this.outputShape_ = outputShape;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getOutputShape = function() {
|
|
return this.outputShape_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setCategory = function(category) {
|
|
this.category_ = category;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getCategory = function() {
|
|
return this.category_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setCheckboxInFlyout = function(hasCheckbox) {
|
|
this.checkboxInFlyout_ = hasCheckbox;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.hasCheckboxInFlyout = function() {
|
|
return this.checkboxInFlyout_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setDragDuplication = function(canDragDuplicate) {
|
|
this.canDragDuplicate_ = canDragDuplicate;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.canDragDuplicate = function() {
|
|
return this.canDragDuplicate_ && this.isShadow();
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setWarningText = function() {
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.setMutator = function() {
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.getRelativeToSurfaceXY = function() {
|
|
return this.xy_;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.moveBy = function(dx, dy) {
|
|
goog.asserts.assert(!this.parentBlock_, 'Block has parent.');
|
|
var event = new Blockly.Events.BlockMove(this);
|
|
this.xy_.translate(dx, dy);
|
|
event.recordNew();
|
|
Blockly.Events.fire(event);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.makeConnection_ = function(type) {
|
|
return new Blockly.Connection(this, type);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.allInputsFilled = function(opt_shadowBlocksAreFilled) {
|
|
|
|
if (opt_shadowBlocksAreFilled === undefined) {
|
|
opt_shadowBlocksAreFilled = true;
|
|
}
|
|
if (!opt_shadowBlocksAreFilled && this.isShadow()) {
|
|
return false;
|
|
}
|
|
|
|
|
|
for (var i = 0, input; input = this.inputList[i]; i++) {
|
|
if (!input.connection) {
|
|
continue;
|
|
}
|
|
var target = input.connection.targetBlock();
|
|
if (!target || !target.allInputsFilled(opt_shadowBlocksAreFilled)) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
var next = this.getNextBlock();
|
|
if (next) {
|
|
return next.allInputsFilled(opt_shadowBlocksAreFilled);
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Blockly.Block.prototype.toDevString = function() {
|
|
var msg = this.type ? '"' + this.type + '" block' : 'Block';
|
|
if (this.id) {
|
|
msg += ' (id="' + this.id + '")';
|
|
}
|
|
return msg;
|
|
};
|
|
|