From 45e5fb415715ce1270bdf2e5f72f2613f2189320 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Tue, 30 Jul 2019 16:33:50 -0700 Subject: [PATCH] More JSDoc and lint corrections --- core/block.js | 4 +- core/blockly.js | 4 +- core/dropdowndiv.js | 8 +- core/field.js | 10 +- core/field_angle.js | 8 +- core/field_checkbox.js | 8 +- core/field_colour.js | 8 +- core/field_date.js | 12 +- core/field_dropdown.js | 10 +- core/field_image.js | 8 +- core/field_label.js | 8 +- core/field_number.js | 8 +- core/field_textinput.js | 8 +- core/field_variable.js | 2 +- core/flyout_button.js | 4 +- core/flyout_horizontal.js | 4 +- core/flyout_vertical.js | 4 +- core/keyboard_nav/ast_node.js | 122 +++++++++--------- core/keyboard_nav/cursor.js | 1 + core/keyboard_nav/cursor_svg.js | 19 +-- core/keyboard_nav/navigation.js | 5 +- .../block_render_draw.js | 8 +- .../block_render_info.js | 3 +- .../block_rendering_constants.js | 7 +- 24 files changed, 142 insertions(+), 141 deletions(-) diff --git a/core/block.js b/core/block.js index 5bd8c78fe..44bef90e3 100644 --- a/core/block.js +++ b/core/block.js @@ -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. } diff --git a/core/blockly.js b/core/blockly.js index d44ecb1f5..2cf910226 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -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. diff --git a/core/dropdowndiv.js b/core/dropdowndiv.js index 501104d01..2066f1594 100644 --- a/core/dropdowndiv.js +++ b/core/dropdowndiv.js @@ -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 diff --git a/core/field.js b/core/field.js index c381f8d0a..f6591c8a7 100644 --- a/core/field.js +++ b/core/field.js @@ -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(). diff --git a/core/field_angle.js b/core/field_angle.js index 842eaf081..4f2da5ade 100644 --- a/core/field_angle.js +++ b/core/field_angle.js @@ -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; diff --git a/core/field_checkbox.js b/core/field_checkbox.js index d147794d5..0b1c204a7 100644 --- a/core/field_checkbox.js +++ b/core/field_checkbox.js @@ -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; diff --git a/core/field_colour.js b/core/field_colour.js index 489f816ae..9363fbb47 100644 --- a/core/field_colour.js +++ b/core/field_colour.js @@ -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); }; /** diff --git a/core/field_date.js b/core/field_date.js index 1586de38a..d742b30f4 100644 --- a/core/field_date.js +++ b/core/field_date.js @@ -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; }; /** diff --git a/core/field_dropdown.js b/core/field_dropdown.js index 28ac0c870..d6599e637 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -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; }; /** diff --git a/core/field_image.js b/core/field_image.js index 6af9aa774..b17f0e1f7 100644 --- a/core/field_image.js +++ b/core/field_image.js @@ -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; }; /** diff --git a/core/field_label.js b/core/field_label.js index a06c2720b..90d6d6431 100644 --- a/core/field_label.js +++ b/core/field_label.js @@ -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); }; /** diff --git a/core/field_number.js b/core/field_number.js index 807158077..5603b728c 100644 --- a/core/field_number.js +++ b/core/field_number.js @@ -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'); diff --git a/core/field_textinput.js b/core/field_textinput.js index fb31271ef..68180abb6 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -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); }; /** diff --git a/core/field_variable.js b/core/field_variable.js index e6f7e5f9e..74f57378e 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -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); diff --git a/core/flyout_button.js b/core/flyout_button.js index de37fe864..bf4ae27ec 100644 --- a/core/flyout_button.js +++ b/core/flyout_button.js @@ -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. diff --git a/core/flyout_horizontal.js b/core/flyout_horizontal.js index adb1f29b5..00a3f23e4 100644 --- a/core/flyout_horizontal.js +++ b/core/flyout_horizontal.js @@ -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); diff --git a/core/flyout_vertical.js b/core/flyout_vertical.js index fbf2720de..72f172b48 100644 --- a/core/flyout_vertical.js +++ b/core/flyout_vertical.js @@ -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); diff --git a/core/keyboard_nav/ast_node.js b/core/keyboard_nav/ast_node.js index 53d77c053..842a5d7d4 100644 --- a/core/keyboard_nav/ast_node.js +++ b/core/keyboard_nav/ast_node.js @@ -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() { diff --git a/core/keyboard_nav/cursor.js b/core/keyboard_nav/cursor.js index df494fb09..1d42529ee 100644 --- a/core/keyboard_nav/cursor.js +++ b/core/keyboard_nav/cursor.js @@ -26,6 +26,7 @@ goog.provide('Blockly.Cursor'); + /** * Class for a cursor. * @constructor diff --git a/core/keyboard_nav/cursor_svg.js b/core/keyboard_nav/cursor_svg.js index 21e6cae7d..e291269a9 100644 --- a/core/keyboard_nav/cursor_svg.js +++ b/core/keyboard_nav/cursor_svg.js @@ -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 */ diff --git a/core/keyboard_nav/navigation.js b/core/keyboard_nav/navigation.js index 8cf1bc631..a37fb004d 100644 --- a/core/keyboard_nav/navigation.js +++ b/core/keyboard_nav/navigation.js @@ -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 { diff --git a/core/renderers/block_rendering_rewrite/block_render_draw.js b/core/renderers/block_rendering_rewrite/block_render_draw.js index 61cc7d47c..d80646839 100644 --- a/core/renderers/block_rendering_rewrite/block_render_draw.js +++ b/core/renderers/block_rendering_rewrite/block_render_draw.js @@ -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; diff --git a/core/renderers/block_rendering_rewrite/block_render_info.js b/core/renderers/block_rendering_rewrite/block_render_info.js index 7bdbddc81..05bb494be 100644 --- a/core/renderers/block_rendering_rewrite/block_render_info.js +++ b/core/renderers/block_rendering_rewrite/block_render_info.js @@ -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; diff --git a/core/renderers/block_rendering_rewrite/block_rendering_constants.js b/core/renderers/block_rendering_rewrite/block_rendering_constants.js index b377607c8..1439d3fbf 100644 --- a/core/renderers/block_rendering_rewrite/block_rendering_constants.js +++ b/core/renderers/block_rendering_rewrite/block_rendering_constants.js @@ -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 }; })(); -