More JSDoc and lint corrections

This commit is contained in:
Neil Fraser
2019-07-30 16:33:50 -07:00
committed by Neil Fraser
parent 6aedfab4d1
commit 45e5fb4157
24 changed files with 142 additions and 141 deletions

View File

@@ -413,8 +413,8 @@ Blockly.Block.prototype.getOnlyValueConnection_ = function() {
var connection = null;
for (var i = 0; i < this.inputList.length; i++) {
var thisConnection = this.inputList[i].connection;
if (thisConnection && thisConnection.type == Blockly.INPUT_VALUE
&& thisConnection.targetConnection) {
if (thisConnection && thisConnection.type == Blockly.INPUT_VALUE &&
thisConnection.targetConnection) {
if (connection) {
return null; // More than one value input found.
}

View File

@@ -265,8 +265,8 @@ Blockly.onKeyDown_ = function(e) {
Blockly.hideChaff();
workspace.undo(e.shiftKey);
}
} else if (Blockly.keyboardAccessibilityMode
&& Blockly.Navigation.navigate(e)) {
} else if (Blockly.keyboardAccessibilityMode &&
Blockly.Navigation.navigate(e)) {
return;
}
// Common code for delete and cut.

View File

@@ -386,8 +386,8 @@ Blockly.DropDownDiv.getPositionBelowMetrics = function(
var xCoords = Blockly.DropDownDiv.getPositionX(
primaryX, boundsInfo.left, boundsInfo.right, divSize.width);
var arrowY = -(Blockly.DropDownDiv.ARROW_SIZE / 2
+ Blockly.DropDownDiv.BORDER_SIZE);
var arrowY = -(Blockly.DropDownDiv.ARROW_SIZE / 2 +
Blockly.DropDownDiv.BORDER_SIZE);
var finalY = primaryY + Blockly.DropDownDiv.PADDING_Y;
return {
@@ -421,8 +421,8 @@ Blockly.DropDownDiv.getPositionAboveMetrics = function(
var xCoords = Blockly.DropDownDiv.getPositionX(
secondaryX, boundsInfo.left, boundsInfo.right, divSize.width);
var arrowY = divSize.height - (Blockly.DropDownDiv.BORDER_SIZE * 2)
- (Blockly.DropDownDiv.ARROW_SIZE / 2);
var arrowY = divSize.height - (Blockly.DropDownDiv.BORDER_SIZE * 2) -
(Blockly.DropDownDiv.ARROW_SIZE / 2);
var finalY = secondaryY - divSize.height - Blockly.DropDownDiv.PADDING_Y;
var initialY = secondaryY - divSize.height; // No padding on Y

View File

@@ -49,7 +49,7 @@ goog.require('goog.style');
Blockly.Field = function(value, opt_validator) {
this.size_ = new Blockly.utils.Size(0, Blockly.BlockSvg.MIN_BLOCK_Y);
this.setValue(value);
this.setValidator(opt_validator);
opt_validator && this.setValidator(opt_validator);
};
/**
@@ -459,10 +459,10 @@ Blockly.Field.prototype.setVisible = function(visible) {
*
* If the function does not return anything (or returns undefined) the new
* value is accepted as valid. This is to allow for fields using the
* validated founction as a field-level change event notification.
* validated function as a field-level change event notification.
*
* @param {Function=} handler The validator
* function or null to clear a previous validator.
* @param {Function} handler The validator function
* or null to clear a previous validator.
*/
Blockly.Field.prototype.setValidator = function(handler) {
this.validator_ = handler;
@@ -534,7 +534,7 @@ Blockly.Field.prototype.updateColour = function() {
};
/**
* Used by getSize() to move/resize any dom elements, and get the new size.
* Used by getSize() to move/resize any DOM elements, and get the new size.
*
* All rendering that has an effect on the size/shape of the block should be
* done here, and should be triggered by getSize().

View File

@@ -334,16 +334,16 @@ Blockly.FieldAngle.prototype.updateGraph_ = function() {
/**
* Ensure that the input value is a valid angle.
* @param {string|number=} newValue The input value.
* @param {string|number=} opt_newValue The input value.
* @return {?number} A valid angle, or null if invalid.
* @protected
* @override
*/
Blockly.FieldAngle.prototype.doClassValidation_ = function(newValue) {
if (isNaN(newValue)) {
Blockly.FieldAngle.prototype.doClassValidation_ = function(opt_newValue) {
if (isNaN(opt_newValue)) {
return null;
}
var n = parseFloat(newValue || 0);
var n = parseFloat(opt_newValue || 0);
n %= 360;
if (n < 0) {
n += 360;

View File

@@ -141,15 +141,15 @@ Blockly.FieldCheckbox.prototype.showEditor_ = function() {
/**
* Ensure that the input value is valid ('TRUE' or 'FALSE').
* @param {string|boolean=} newValue The input value.
* @param {string|boolean=} opt_newValue The input value.
* @return {?string} A valid value ('TRUE' or 'FALSE), or null if invalid.
* @protected
*/
Blockly.FieldCheckbox.prototype.doClassValidation_ = function(newValue) {
if (newValue === true || newValue === 'TRUE') {
Blockly.FieldCheckbox.prototype.doClassValidation_ = function(opt_newValue) {
if (opt_newValue === true || opt_newValue === 'TRUE') {
return 'TRUE';
}
if (newValue === false || newValue === 'FALSE') {
if (opt_newValue === false || opt_newValue === 'FALSE') {
return 'FALSE';
}
return null;

View File

@@ -162,15 +162,15 @@ Blockly.FieldColour.prototype.initView = function() {
/**
* Ensure that the input value is a valid colour.
* @param {string=} newValue The input value.
* @param {string=} opt_newValue The input value.
* @return {?string} A valid colour, or null if invalid.
* @protected
*/
Blockly.FieldColour.prototype.doClassValidation_ = function(newValue) {
if (typeof newValue != 'string') {
Blockly.FieldColour.prototype.doClassValidation_ = function(opt_newValue) {
if (typeof opt_newValue != 'string') {
return null;
}
return Blockly.utils.colour.parse(newValue);
return Blockly.utils.colour.parse(opt_newValue);
};
/**

View File

@@ -100,20 +100,20 @@ Blockly.FieldDate.prototype.DROPDOWN_BACKGROUND_COLOUR = 'white';
/**
* Ensure that the input value is a valid date.
* @param {string=} newValue The input value.
* @param {string=} opt_newValue The input value.
* @return {?string} A valid date, or null if invalid.
* @protected
*/
Blockly.FieldDate.prototype.doClassValidation_ = function(newValue) {
if (!newValue) {
Blockly.FieldDate.prototype.doClassValidation_ = function(opt_newValue) {
if (!opt_newValue) {
return null;
}
// Check if the new value is parsable or not.
var date = goog.date.Date.fromIsoString(newValue);
if (!date || date.toIsoString(true) != newValue) {
var date = goog.date.Date.fromIsoString(opt_newValue);
if (!date || date.toIsoString(true) != opt_newValue) {
return null;
}
return newValue;
return opt_newValue;
};
/**

View File

@@ -390,16 +390,16 @@ Blockly.FieldDropdown.prototype.getOptions = function() {
/**
* Ensure that the input value is a valid language-neutral option.
* @param {string=} newValue The input value.
* @param {string=} opt_newValue The input value.
* @return {?string} A valid language-neutral option, or null if invalid.
* @protected
*/
Blockly.FieldDropdown.prototype.doClassValidation_ = function(newValue) {
Blockly.FieldDropdown.prototype.doClassValidation_ = function(opt_newValue) {
var isValueValid = false;
var options = this.getOptions();
for (var i = 0, option; option = options[i]; i++) {
// Options are tuples of human-readable text and language-neutral values.
if (option[1] == newValue) {
if (option[1] == opt_newValue) {
isValueValid = true;
break;
}
@@ -408,11 +408,11 @@ Blockly.FieldDropdown.prototype.doClassValidation_ = function(newValue) {
if (this.sourceBlock_) {
console.warn('Cannot set the dropdown\'s value to an unavailable option.' +
' Block type: ' + this.sourceBlock_.type + ', Field name: ' + this.name +
', Value: ' + newValue);
', Value: ' + opt_newValue);
}
return null;
}
return newValue;
return opt_newValue;
};
/**

View File

@@ -133,15 +133,15 @@ Blockly.FieldImage.prototype.initView = function() {
/**
* Ensure that the input value (the source URL) is a string.
* @param {string=} newValue The input value
* @param {string=} opt_newValue The input value.
* @return {?string} A string, or null if invalid.
* @protected
*/
Blockly.FieldImage.prototype.doClassValidation_ = function(newValue) {
if (typeof newValue != 'string') {
Blockly.FieldImage.prototype.doClassValidation_ = function(opt_newValue) {
if (typeof opt_newValue != 'string') {
return null;
}
return newValue;
return opt_newValue;
};
/**

View File

@@ -88,15 +88,15 @@ Blockly.FieldLabel.prototype.initView = function() {
/**
* Ensure that the input value casts to a valid string.
* @param {string=} newValue The input value.
* @param {string=} opt_newValue The input value.
* @return {?string} A valid string, or null if invalid.
* @protected
*/
Blockly.FieldLabel.prototype.doClassValidation_ = function(newValue) {
if (newValue === null || newValue === undefined) {
Blockly.FieldLabel.prototype.doClassValidation_ = function(opt_newValue) {
if (opt_newValue === null || opt_newValue === undefined) {
return null;
}
return String(newValue);
return String(opt_newValue);
};
/**

View File

@@ -103,17 +103,17 @@ Blockly.FieldNumber.prototype.setConstraints = function(min, max, precision) {
/**
* Ensure that the input value is a valid number (must fulfill the
* constraints placed on the field).
* @param {string|number=} newValue The input value.
* @param {string|number=} opt_newValue The input value.
* @return {?number} A valid number, or null if invalid.
* @protected
* @override
*/
Blockly.FieldNumber.prototype.doClassValidation_ = function(newValue) {
if (newValue === null || newValue === undefined) {
Blockly.FieldNumber.prototype.doClassValidation_ = function(opt_newValue) {
if (opt_newValue === null || opt_newValue === undefined) {
return null;
}
// Clean up text.
newValue = String(newValue);
var newValue = String(opt_newValue);
// TODO: Handle cases like 'ten', '1.203,14', etc.
// 'O' is sometimes mistaken for '0' by inexperienced users.
newValue = newValue.replace(/O/ig, '0');

View File

@@ -101,15 +101,15 @@ Blockly.FieldTextInput.prototype.spellcheck_ = true;
/**
* Ensure that the input value casts to a valid string.
* @param {string=} newValue The input value.
* @param {string=} opt_newValue The input value.
* @return {?string} A valid string, or null if invalid.
* @protected
*/
Blockly.FieldTextInput.prototype.doClassValidation_ = function(newValue) {
if (newValue === null || newValue === undefined) {
Blockly.FieldTextInput.prototype.doClassValidation_ = function(opt_newValue) {
if (opt_newValue === null || opt_newValue === undefined) {
return null;
}
return String(newValue);
return String(opt_newValue);
};
/**

View File

@@ -58,7 +58,7 @@ Blockly.FieldVariable = function(varname, opt_validator, opt_variableTypes,
// spurious variable. Just do the relevant parts of the constructor.
this.menuGenerator_ = Blockly.FieldVariable.dropdownCreate;
this.size_ = new Blockly.utils.Size(0, Blockly.BlockSvg.MIN_BLOCK_Y);
this.setValidator(opt_validator);
opt_validator && this.setValidator(opt_validator);
this.defaultVariableName = (varname || '');
this.setTypes_(opt_variableTypes, opt_defaultType);

View File

@@ -79,9 +79,9 @@ Blockly.FlyoutButton = function(workspace, targetWorkspace, xml, isLabel) {
* @type {string}
* @private
*/
this.callbackKey_ = xml.getAttribute('callbackKey')
this.callbackKey_ = xml.getAttribute('callbackKey') ||
/* Check the lower case version too to satisfy IE */
|| xml.getAttribute('callbackkey');
xml.getAttribute('callbackkey');
/**
* If specified, a CSS class to add to this button.

View File

@@ -175,8 +175,8 @@ Blockly.HorizontalFlyout.prototype.position = function() {
// to align the bottom edge of the flyout with the bottom edge of the
// blocklyDiv, we calculate the full height of the div minus the height
// of the flyout.
var y = targetWorkspaceMetrics.viewHeight
+ targetWorkspaceMetrics.absoluteTop - this.height_;
var y = targetWorkspaceMetrics.viewHeight +
targetWorkspaceMetrics.absoluteTop - this.height_;
}
}
this.positionAt_(this.width_, this.height_, x, y);

View File

@@ -173,8 +173,8 @@ Blockly.VerticalFlyout.prototype.position = function() {
// to align the right edge of the flyout with the right edge of the
// blocklyDiv, we calculate the full width of the div minus the width
// of the flyout.
var x = targetWorkspaceMetrics.viewWidth
+ targetWorkspaceMetrics.absoluteLeft - this.width_;
var x = targetWorkspaceMetrics.viewWidth +
targetWorkspaceMetrics.absoluteLeft - this.width_;
}
}
this.positionAt_(this.width_, this.height_, x, y);

View File

@@ -19,25 +19,26 @@
*/
/**
* @fileoverview The class representing an ast node.
* Used to traverse the blockly ast.
* @fileoverview The class representing an AST node.
* Used to traverse the Blockly AST.
*/
'use strict';
goog.provide('Blockly.ASTNode');
/**
* Class for an ast node.
* Class for an AST node.
* It is recommended that you use one of the createNode methods instead of
* creating a node directly.
* @constructor
* @param {!string} type The type of the location.
* Must be in Bockly.ASTNode.types.
* @param {Blockly.Block|Blockly.Connection|Blockly.Field|Blockly.Workspace}
* location The position in the ast.
* @param {Object=} params Optional dictionary of options.
* location The position in the AST.
* @param {!Object=} opt_params Optional dictionary of options.
*/
Blockly.ASTNode = function(type, location, params) {
Blockly.ASTNode = function(type, location, opt_params) {
if (!location) {
throw Error('Cannot create a node without a location.');
}
@@ -58,18 +59,17 @@ Blockly.ASTNode = function(type, location, params) {
this.isConnection_ = Blockly.ASTNode.isConnectionType(type);
/**
* The location of the ast node.
* The location of the AST node.
* @type {!(Blockly.Block|Blockly.Connection|Blockly.Field|Blockly.Workspace)}
* @private
*/
this.location_ = location;
this.processParams_(params || null);
this.processParams_(opt_params || null);
};
/**
* Object holding different types for an ast node.
* Object holding different types for an AST node.
*/
Blockly.ASTNode.types = {
FIELD: 'field',
@@ -99,7 +99,7 @@ Blockly.ASTNode.wsMove_ = 10;
Blockly.ASTNode.DEFAULT_OFFSET_Y = -20;
/**
* Whether an ast node of the given type points to a connection.
* Whether an AST node of the given type points to a connection.
* @param {string} type The type to check. One of Blockly.ASTNode.types.
* @return {boolean} True if a node of the given type points to a connection.
* @package
@@ -116,20 +116,20 @@ Blockly.ASTNode.isConnectionType = function(type) {
};
/**
* Create an ast node pointing to a field.
* @param {Blockly.Field} field The location of the ast node.
* @return {Blockly.ASTNode} An ast node pointing to a field.
* Create an AST node pointing to a field.
* @param {Blockly.Field} field The location of the AST node.
* @return {Blockly.ASTNode} An AST node pointing to a field.
*/
Blockly.ASTNode.createFieldNode = function(field) {
return new Blockly.ASTNode(Blockly.ASTNode.types.FIELD, field);
};
/**
* Creates an ast node pointing to a connection. If the connection has a parent
* input then create an ast node of type input that will hold the connection.
* Creates an AST node pointing to a connection. If the connection has a parent
* input then create an AST node of type input that will hold the connection.
* @param {Blockly.Connection} connection This is the connection the node will
* point to.
* @return {Blockly.ASTNode} An ast node pointing to a connection.
* @return {Blockly.ASTNode} An AST node pointing to a connection.
*/
Blockly.ASTNode.createConnectionNode = function(connection) {
if (!connection){
@@ -137,8 +137,8 @@ Blockly.ASTNode.createConnectionNode = function(connection) {
}
if (connection.type === Blockly.INPUT_VALUE) {
return Blockly.ASTNode.createInputNode(connection.getParentInput());
} else if (connection.type === Blockly.NEXT_STATEMENT
&& connection.getParentInput()) {
} else if (connection.type === Blockly.NEXT_STATEMENT &&
connection.getParentInput()) {
return Blockly.ASTNode.createInputNode(connection.getParentInput());
} else if (connection.type === Blockly.NEXT_STATEMENT) {
return new Blockly.ASTNode(Blockly.ASTNode.types.NEXT, connection);
@@ -151,10 +151,10 @@ Blockly.ASTNode.createConnectionNode = function(connection) {
};
/**
* Creates an ast node pointing to an input. Stores the input connection as the
* Creates an AST node pointing to an input. Stores the input connection as the
* location.
* @param {Blockly.Input} input The input used to create an ast node.
* @return {Blockly.ASTNode} An ast node pointing to a input.
* @param {Blockly.Input} input The input used to create an AST node.
* @return {Blockly.ASTNode} An AST node pointing to a input.
*/
Blockly.ASTNode.createInputNode = function(input) {
if (!input) {
@@ -163,24 +163,25 @@ Blockly.ASTNode.createInputNode = function(input) {
var params = {
"input": input
};
return new Blockly.ASTNode(Blockly.ASTNode.types.INPUT, input.connection, params);
return new Blockly.ASTNode(Blockly.ASTNode.types.INPUT, input.connection,
params);
};
/**
* Creates an ast node pointing to a block.
* @param {Blockly.Block} block The block used to create an ast node.
* @return {Blockly.ASTNode} An ast node pointing to a block.
* Creates an AST node pointing to a block.
* @param {Blockly.Block} block The block used to create an AST node.
* @return {Blockly.ASTNode} An AST node pointing to a block.
*/
Blockly.ASTNode.createBlockNode = function(block) {
return new Blockly.ASTNode(Blockly.ASTNode.types.BLOCK, block);
};
/**
* Create an ast node of type stack. A stack, represented by its top block, is
* Create an AST node of type stack. A stack, represented by its top block, is
* the set of all blocks connected to a top block, including the top block.
* @param {Blockly.Block} topBlock A top block has no parent and can be found
* in the list returned by workspace.getTopBlocks().
* @return {Blockly.ASTNode} An ast node of type stack that points to the top
* @return {Blockly.ASTNode} An AST node of type stack that points to the top
* block on the stack.
*/
Blockly.ASTNode.createStackNode = function(topBlock) {
@@ -188,11 +189,11 @@ Blockly.ASTNode.createStackNode = function(topBlock) {
};
/**
* Creates an ast node pointing to a workpsace.
* Creates an AST node pointing to a workspace.
* @param {Blockly.Workspace} workspace The workspace that we are on.
* @param {Blockly.utils.Coordinate} wsCoordinate The position on the workspace for
* this node.
* @return {Blockly.ASTNode} An ast node pointing to a workspace and a position
* @param {Blockly.utils.Coordinate} wsCoordinate The position on the workspace
* for this node.
* @return {Blockly.ASTNode} An AST node pointing to a workspace and a position
* on the workspace.
*/
Blockly.ASTNode.createWorkspaceNode = function(workspace, wsCoordinate) {
@@ -275,7 +276,7 @@ Blockly.ASTNode.prototype.isConnection = function() {
* @param {!Blockly.Input} parentInput The parentInput of the field.
* @param {boolean=} opt_last If true find the last editable field otherwise get
* the previous field.
* @return {Blockly.ASTNode} The ast node holding the previous or last field or
* @return {Blockly.ASTNode} The AST node holding the previous or last field or
* null if no previous field exists.
* @private
*/
@@ -298,7 +299,7 @@ Blockly.ASTNode.prototype.findPreviousEditableField_ = function(location,
* Given an input find the next editable field or an input with a non null
* connection in the same block. The current location must be an input
* connection.
* @return {Blockly.ASTNode} The ast node holding the next field or connection
* @return {Blockly.ASTNode} The AST node holding the next field or connection
* or null if there is no editable field or input connection after the given
* input.
* @private
@@ -324,7 +325,7 @@ Blockly.ASTNode.prototype.findNextForInput_ = function() {
/**
* Given a field find the next editable field or an input with a non null
* connection in the same block. The current location must be a field.
* @return {Blockly.ASTNode} The ast node pointing to the next field or
* @return {Blockly.ASTNode} The AST node pointing to the next field or
* connection or null if there is no editable field or input connection
* after the given input.
* @private
@@ -355,11 +356,11 @@ Blockly.ASTNode.prototype.findNextForField_ = function() {
* Given an input find the previous editable field or an input with a non null
* connection in the same block. The current location must be an input
* connection.
* @return {Blockly.ASTNode} The ast node holding the previous field or
* @return {Blockly.ASTNode} The AST node holding the previous field or
* connection.
* @private
*/
Blockly.ASTNode.prototype.findPrevForInput_ = function(){
Blockly.ASTNode.prototype.findPrevForInput_ = function() {
var location = this.location_.getParentInput();
var block = location.getSourceBlock();
var curIdx = block.inputList.indexOf(location);
@@ -380,7 +381,7 @@ Blockly.ASTNode.prototype.findPrevForInput_ = function(){
/**
* Given a field find the previous editable field or an input with a non null
* connection in the same block. The current location must be a field.
* @return {Blockly.ASTNode} The ast node holding the previous input or field.
* @return {Blockly.ASTNode} The AST node holding the previous input or field.
* @private
*/
Blockly.ASTNode.prototype.findPrevForField_ = function() {
@@ -440,12 +441,12 @@ Blockly.ASTNode.prototype.navigateBetweenStacks_ = function(forward) {
};
/**
* Finds the top most ast node for a given block.
* Finds the top most AST node for a given block.
* This is either the previous connection, output connection or block depending
* on what kind of connections the block has.
* @param {Blockly.Block} block The block that we want to find the top
* @param {!Blockly.Block} block The block that we want to find the top
* connection on.
* @return {!Blockly.ASTNode} The ast node containing the top connection.
* @return {!Blockly.ASTNode} The AST node containing the top connection.
* @private
*/
Blockly.ASTNode.prototype.findTopASTNodeForBlock_ = function(block) {
@@ -458,26 +459,27 @@ Blockly.ASTNode.prototype.findTopASTNodeForBlock_ = function(block) {
};
/**
* Get the ast node pointing to the input that the block is nested under or if
* the block is not nested then get the stack ast node.
* @param {Blockly.Block} block The source block of the current location.
* @return {Blockly.ASTNode} The ast node pointing to the input connection or
* Get the AST node pointing to the input that the block is nested under or if
* the block is not nested then get the stack AST node.
* @param {!Blockly.Block} block The source block of the current location.
* @return {Blockly.ASTNode} The AST node pointing to the input connection or
* the top block of the stack this block is in.
* @private
*/
Blockly.ASTNode.prototype.getOutAstNodeForBlock_ = function(block) {
var topBlock = null;
//If the block doesn't have a previous connection then it is the top of the
//substack
// If the block doesn't have a previous connection then it is the top of the
// substack.
if (!block.previousConnection) {
topBlock = block;
} else {
topBlock = this.findTopOfSubStack_(block);
}
var topConnection = topBlock.previousConnection || topBlock.outputConnection;
//If the top connection has a parentInput, create an ast node pointing to that input
// If the top connection has a parentInput, create an AST node pointing to
// that input.
if (topConnection && topConnection.targetConnection &&
topConnection.targetConnection.getParentInput()) {
topConnection.targetConnection.getParentInput()) {
return Blockly.ASTNode.createInputNode(
topConnection.targetConnection.getParentInput());
} else {
@@ -489,7 +491,7 @@ Blockly.ASTNode.prototype.getOutAstNodeForBlock_ = function(block) {
/**
* Find the first editable field or input with a connection on a given block.
* @param {!Blockly.BlockSvg} block The source block of the current location.
* @return {Blockly.ASTNode} An ast node pointing to the first field or input.
* @return {Blockly.ASTNode} An AST node pointing to the first field or input.
* Null if there are no editable fields or inputs with connections on the block.
* @private
*/
@@ -520,18 +522,18 @@ Blockly.ASTNode.prototype.findFirstFieldOrInput_ = function(block) {
*/
Blockly.ASTNode.prototype.findTopOfSubStack_ = function(sourceBlock) {
var topBlock = sourceBlock;
while (topBlock && topBlock.previousConnection
&& topBlock.previousConnection.targetConnection
&& topBlock.previousConnection.targetBlock().nextConnection
== topBlock.previousConnection.targetConnection) {
while (topBlock && topBlock.previousConnection &&
topBlock.previousConnection.targetConnection &&
topBlock.previousConnection.targetBlock().nextConnection ==
topBlock.previousConnection.targetConnection) {
topBlock = topBlock.previousConnection.targetBlock();
}
return topBlock;
};
/**
* Find the element to the right of the current element in the ast.
* @return {Blockly.ASTNode} An ast node that wraps the next field, connection,
* Find the element to the right of the current element in the AST.
* @return {Blockly.ASTNode} An AST node that wraps the next field, connection,
* block, or workspace. Or null if there is no node to the right.
*/
Blockly.ASTNode.prototype.next = function() {
@@ -581,7 +583,7 @@ Blockly.ASTNode.prototype.next = function() {
/**
* Find the element one level below and all the way to the left of the current
* location.
* @return {Blockly.ASTNode} An ast node that wraps the next field, connection,
* @return {Blockly.ASTNode} An AST node that wraps the next field, connection,
* workspace, or block. Or null if there is nothing below this node.
*/
Blockly.ASTNode.prototype.in = function() {
@@ -612,8 +614,8 @@ Blockly.ASTNode.prototype.in = function() {
};
/**
* Find the element to the left of the current element in the ast.
* @return {Blockly.ASTNode} An ast node that wraps the previous field,
* Find the element to the left of the current element in the AST.
* @return {Blockly.ASTNode} An AST node that wraps the previous field,
* connection, workspace or block. Or null if no node exists to the left.
* null.
*/
@@ -663,7 +665,7 @@ Blockly.ASTNode.prototype.prev = function() {
/**
* Find the next element that is one position above and all the way to the left
* of the current location.
* @return {Blockly.ASTNode} An ast node that wraps the next field, connection,
* @return {Blockly.ASTNode} An AST node that wraps the next field, connection,
* workspace or block. Or null if we are at the workspace level.
*/
Blockly.ASTNode.prototype.out = function() {

View File

@@ -26,6 +26,7 @@
goog.provide('Blockly.Cursor');
/**
* Class for a cursor.
* @constructor

View File

@@ -25,7 +25,10 @@
'use strict';
goog.provide('Blockly.CursorSvg');
goog.require('Blockly.Cursor');
/**
* Class for a cursor.
* @param {!Blockly.Workspace} workspace The workspace to sit in.
@@ -90,14 +93,14 @@ Blockly.CursorSvg.CURSOR_COLOR = '#cc0a0a';
Blockly.CursorSvg.MARKER_COLOR = '#4286f4';
/**
* Parent svg element.
* This is generally a block's svg root, unless the cursor is on the workspace.
* Parent SVG element.
* This is generally a block's SVG root, unless the cursor is on the workspace.
* @type {Element}
*/
Blockly.CursorSvg.prototype.parent_ = null;
/**
* The current svg element for the cursor.
* The current SVG element for the cursor.
* @type {Element}
*/
Blockly.CursorSvg.prototype.currentCursorSvg = null;
@@ -111,7 +114,7 @@ Blockly.CursorSvg.prototype.getSvgRoot = function() {
};
/**
* Create the dom element for the cursor.
* Create the DOM element for the cursor.
* @return {!Element} The cursor controls SVG group.
*/
Blockly.CursorSvg.prototype.createDom = function() {
@@ -126,7 +129,7 @@ Blockly.CursorSvg.prototype.createDom = function() {
/**
* Set parent of the cursor. This is so that the cursor will be on the correct
* svg group.
* SVG group.
* @param {Element} newParent New parent of the cursor.
* @private
*/
@@ -347,8 +350,8 @@ Blockly.CursorSvg.prototype.update_ = function() {
this.showWithBlock_();
//This needs to be the location type because next connections can be input
//type but they need to draw like they are a next statement
} else if (curNode.getLocation().type === Blockly.INPUT_VALUE
|| curNode.getType() === Blockly.ASTNode.types.OUTPUT) {
} else if (curNode.getLocation().type === Blockly.INPUT_VALUE ||
curNode.getType() === Blockly.ASTNode.types.OUTPUT) {
this.showWithInputOutput_();
} else if (curNode.getLocation().type === Blockly.NEXT_STATEMENT) {
this.showWithNext_();
@@ -364,7 +367,7 @@ Blockly.CursorSvg.prototype.update_ = function() {
};
/**
* Create the cursor svg.
* Create the cursor SVG.
* @return {Element} The SVG node created.
* @private
*/

View File

@@ -22,6 +22,7 @@ goog.provide('Blockly.Navigation');
goog.require('Blockly.ASTNode');
/**
* The cursor for keyboard navigation.
* @type {Blockly.Cursor}
@@ -478,8 +479,8 @@ Blockly.Navigation.modify = function() {
Blockly.Navigation.connect = function(movingConnection, targetConnection) {
if (movingConnection) {
var movingBlock = movingConnection.getSourceBlock();
if (targetConnection.type == Blockly.PREVIOUS_STATEMENT
|| targetConnection.type == Blockly.OUTPUT_VALUE) {
if (targetConnection.type == Blockly.PREVIOUS_STATEMENT ||
targetConnection.type == Blockly.OUTPUT_VALUE) {
movingBlock.positionNearConnection(movingConnection, targetConnection);
}
try {

View File

@@ -281,10 +281,10 @@ Blockly.blockRendering.Drawer.prototype.drawInternals_ = function() {
* @private
*/
Blockly.blockRendering.Drawer.prototype.dealWithOffsetFields_ = function(field) {
if (field instanceof Blockly.FieldDropdown
|| field instanceof Blockly.FieldTextInput
|| field instanceof Blockly.FieldColour
|| field instanceof Blockly.FieldCheckbox) {
if (field instanceof Blockly.FieldDropdown ||
field instanceof Blockly.FieldTextInput ||
field instanceof Blockly.FieldColour ||
field instanceof Blockly.FieldCheckbox) {
return 5;
}
return 0;

View File

@@ -587,8 +587,7 @@ Blockly.blockRendering.RenderInfo.prototype.makeSpacerRow_ = function(prev, next
Blockly.blockRendering.RenderInfo.prototype.getSpacerRowWidth_ = function(prev, next) {
// The width of the spacer before the bottom row should be the same as the
// bottom row.
if (next.type === 'bottom row'
&& next.hasFixedWidth) {
if (next.type === 'bottom row' && next.hasFixedWidth) {
return next.width;
}
return this.width;

View File

@@ -109,7 +109,7 @@ Blockly.blockRendering.constants.SPACER_DEFAULT_HEIGHT = 15;
Blockly.blockRendering.constants.MIN_BLOCK_HEIGHT = 24;
Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_WIDTH =
Blockly.blockRendering.constants.TAB_WIDTH + 14.5;
Blockly.blockRendering.constants.TAB_WIDTH + 14.5;
Blockly.blockRendering.constants.EMPTY_INLINE_INPUT_HEIGHT =
Blockly.blockRendering.constants.TAB_HEIGHT + 11;
@@ -211,7 +211,6 @@ Blockly.blockRendering.constants.PUZZLE_TAB = (function() {
};
})();
Blockly.blockRendering.constants.NOTCH = (function() {
var width = Blockly.blockRendering.constants.NOTCH_WIDTH;
var height = Blockly.blockRendering.constants.NOTCH_HEIGHT;
@@ -237,7 +236,6 @@ Blockly.blockRendering.constants.NOTCH = (function() {
};
})();
Blockly.blockRendering.constants.INSIDE_CORNERS = (function() {
var radius = Blockly.blockRendering.constants.CORNER_RADIUS;
@@ -254,8 +252,6 @@ Blockly.blockRendering.constants.INSIDE_CORNERS = (function() {
};
})();
Blockly.blockRendering.constants.OUTSIDE_CORNERS = (function() {
var radius = Blockly.blockRendering.constants.CORNER_RADIUS;
/**
@@ -273,4 +269,3 @@ Blockly.blockRendering.constants.OUTSIDE_CORNERS = (function() {
bottomLeft: bottomLeft
};
})();