Skip to content

Commit

Permalink
Make comments more consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilFraser committed Jun 9, 2021
1 parent 6a6c630 commit cff7b35
Show file tree
Hide file tree
Showing 22 changed files with 75 additions and 76 deletions.
10 changes: 5 additions & 5 deletions core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ Blockly.Block.prototype.getOnlyValueConnection_ = function() {
thisConnection.type == Blockly.connectionTypes.INPUT_VALUE &&
thisConnection.targetConnection) {
if (connection) {
return null; // More than one value input found.
return null; // More than one value input found.
}
connection = thisConnection;
}
Expand Down Expand Up @@ -1700,7 +1700,7 @@ Blockly.Block.prototype.validateTokens_ = function(tokens, argsCount) {
};

/**
* Inserts args in place of numerical tokens. String args are converted to json
* Inserts args in place of numerical tokens. String args are converted to JSON
* that defines a label field. If necessary an extra dummy input is added to
* the end of the elements.
* @param {!Array<!string|number>} tokens The tokens to interpolate
Expand Down Expand Up @@ -1742,9 +1742,9 @@ Blockly.Block.prototype.interpolateArguments_ =
};

/**
* Creates a field from the json definition of a field. If a field with the
* Creates a field from the JSON definition of a field. If a field with the
* given type cannot be found, this attempts to create a different field using
* the 'alt' property of the json definition (if it exists).
* the 'alt' property of the JSON definition (if it exists).
* @param {{alt:(string|undefined)}} element The element to try to turn into a
* field.
* @return {?Blockly.Field} The field defined by the JSON, or null if one
Expand All @@ -1764,7 +1764,7 @@ Blockly.Block.prototype.fieldFromJson_ = function(element) {
};

/**
* Creates an input from the json definition of an input. Sets the input's check
* Creates an input from the JSON definition of an input. Sets the input's check
* and alignment if they are provided.
* @param {!Object} element The JSON to turn into an input.
* @param {string} warningPrefix The prefix to add to warnings to help the
Expand Down
17 changes: 8 additions & 9 deletions core/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ Blockly.Connection.prototype.respawnShadow_ = function() {
var parentBlock = this.getSourceBlock();
var shadow = this.getShadowDom();
if (parentBlock.workspace && shadow) {
var blockShadow =
Blockly.Xml.domToBlock(shadow, parentBlock.workspace);
var blockShadow = Blockly.Xml.domToBlock(shadow, parentBlock.workspace);
if (blockShadow.outputConnection) {
this.connect(blockShadow.outputConnection);
} else if (blockShadow.previousConnection) {
Expand Down Expand Up @@ -646,11 +645,10 @@ Blockly.Connection.prototype.neighbours = function(_maxLimit) {
*/
Blockly.Connection.prototype.getParentInput = function() {
var parentInput = null;
var block = this.sourceBlock_;
var inputs = block.inputList;
for (var idx = 0; idx < block.inputList.length; idx++) {
if (inputs[idx].connection === this) {
parentInput = inputs[idx];
var inputs = this.sourceBlock_.inputList;
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].connection === this) {
parentInput = inputs[i];
break;
}
}
Expand All @@ -663,11 +661,12 @@ Blockly.Connection.prototype.getParentInput = function() {
* @return {string} The description.
*/
Blockly.Connection.prototype.toString = function() {
var msg;
var block = this.sourceBlock_;
if (!block) {
return 'Orphan Connection';
} else if (block.outputConnection == this) {
}
var msg;
if (block.outputConnection == this) {
msg = 'Output Connection of ';
} else if (block.previousConnection == this) {
msg = 'Previous Connection of ';
Expand Down
18 changes: 9 additions & 9 deletions core/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ Blockly.Css.CONTENT = [
'.blocklyWidgetDiv {',
'display: none;',
'position: absolute;',
'z-index: 99999;', /* big value for bootstrap3 compatibility */
'z-index: 99999;', /* big value for bootstrap3 compatibility */
'}',

'.injectionDiv {',
'height: 100%;',
'position: relative;',
'overflow: hidden;', /* So blocks in drag surface disappear at edges */
'overflow: hidden;', /* So blocks in drag surface disappear at edges */
'touch-action: none;',
'}',

Expand Down Expand Up @@ -125,7 +125,7 @@ Blockly.Css.CONTENT = [
'right: 0;',
'bottom: 0;',
'overflow: visible !important;',
'z-index: 50;', /* Display below toolbox, but above everything else. */
'z-index: 50;', /* Display below toolbox, but above everything else. */
'}',

'.blocklyBlockCanvas.blocklyCanvasTransitioning,',
Expand All @@ -143,7 +143,7 @@ Blockly.Css.CONTENT = [
'opacity: .9;',
'padding: 2px;',
'position: absolute;',
'z-index: 100000;', /* big value for bootstrap3 compatibility */
'z-index: 100000;', /* big value for bootstrap3 compatibility */
'}',

'.blocklyDropDownDiv {',
Expand All @@ -165,7 +165,7 @@ Blockly.Css.CONTENT = [
'}',

'.blocklyDropDownContent {',
'max-height: 300px;', // @todo: spec for maximum height.
'max-height: 300px;', // @todo: spec for maximum height.
'overflow: auto;',
'overflow-x: hidden;',
'position: relative;',
Expand Down Expand Up @@ -498,11 +498,11 @@ Blockly.Css.CONTENT = [
'}',

'.blocklyDropDownDiv .blocklyMenu {',
'background: inherit;', /* Compatibility with gapi, reset from goog-menu */
'border: inherit;', /* Compatibility with gapi, reset from goog-menu */
'background: inherit;', /* Compatibility with gapi, reset from goog-menu */
'border: inherit;', /* Compatibility with gapi, reset from goog-menu */
'font: normal 13px "Helvetica Neue", Helvetica, sans-serif;',
'outline: none;',
'position: relative;', /* Compatibility with gapi, reset from goog-menu */
'position: relative;', /* Compatibility with gapi, reset from goog-menu */
'z-index: 20000;', /* Arbitrary, but some apps depend on it... */
'}',

Expand Down Expand Up @@ -541,7 +541,7 @@ Blockly.Css.CONTENT = [
'background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px;',
'float: left;',
'margin-left: -24px;',
'position: static;', /* Scroll with the menu. */
'position: static;', /* Scroll with the menu. */
'}',

'.blocklyMenuItemRtl .blocklyMenuItemCheckbox {',
Expand Down
10 changes: 5 additions & 5 deletions core/dropdowndiv.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ Blockly.DropDownDiv.getPositionBelowMetrics_ = function(
return {
initialX: xCoords.divX,
initialY : primaryY,
finalX: xCoords.divX, // X position remains constant during animation.
finalX: xCoords.divX, // X position remains constant during animation.
finalY: finalY,
arrowX: xCoords.arrowX,
arrowY: arrowY,
Expand Down Expand Up @@ -525,12 +525,12 @@ Blockly.DropDownDiv.getPositionAboveMetrics_ = function(
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
var initialY = secondaryY - divSize.height; // No padding on Y.

return {
initialX: xCoords.divX,
initialY : initialY,
finalX: xCoords.divX, // X position remains constant during animation.
finalX: xCoords.divX, // X position remains constant during animation.
finalY: finalY,
arrowX: xCoords.arrowX,
arrowY: arrowY,
Expand Down Expand Up @@ -560,8 +560,8 @@ Blockly.DropDownDiv.getPositionTopOfPageMetrics_ = function(
return {
initialX: xCoords.divX,
initialY : 0,
finalX: xCoords.divX, // X position remains constant during animation.
finalY: 0, // Y position remains constant during animation.
finalX: xCoords.divX, // X position remains constant during animation.
finalY: 0, // Y position remains constant during animation.
arrowAtTop: null,
arrowX: null,
arrowY: null,
Expand Down
2 changes: 1 addition & 1 deletion core/events/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Blockly.Events.filter = function(queueIn, forward) {
// Merge duplicates.
for (var i = 0, event; (event = queue[i]); i++) {
if (!event.isNull()) {
// Treat all ui events as the same type in hash table.
// Treat all UI events as the same type in hash table.
var eventType = event.isUiEvent ? Blockly.Events.UI : event.type;
var key = [eventType, event.blockId, event.workspaceId].join(' ');

Expand Down
4 changes: 2 additions & 2 deletions core/field_dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ Blockly.FieldDropdown.prototype.dropdownCreate_ = function() {
var options = this.getOptions(false);
this.selectedMenuItem_ = null;
for (var i = 0; i < options.length; i++) {
var content = options[i][0]; // Human-readable text or image.
var value = options[i][1]; // Language-neutral value.
var content = options[i][0]; // Human-readable text or image.
var value = options[i][1]; // Language-neutral value.
if (typeof content == 'object') {
// An image, not text.
var image = new Image(content['width'], content['height']);
Expand Down
4 changes: 2 additions & 2 deletions core/field_multilineinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ Blockly.FieldMultilineInput.fromJson = function(options) {
* @package
*/
Blockly.FieldMultilineInput.prototype.toXml = function(fieldElement) {
// Replace '\n' characters with html-escaped equivalent '&#10'. This is
// needed so the plain-text representation of the xml produced by
// Replace '\n' characters with HTML-escaped equivalent '&#10'. This is
// needed so the plain-text representation of the XML produced by
// `Blockly.Xml.domToText` will appear on a single line (this is a limitation
// of the plain-text format).
fieldElement.textContent = this.getValue().replace(/\n/g, '&#10;');
Expand Down
2 changes: 1 addition & 1 deletion core/field_textinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ Blockly.FieldTextInput.prototype.isTabNavigable = function() {
*/
Blockly.FieldTextInput.prototype.getText_ = function() {
if (this.isBeingEdited_ && this.htmlInput_) {
// We are currently editing, return the html input value instead.
// We are currently editing, return the HTML input value instead.
return this.htmlInput_.value;
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions core/field_variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Blockly.FieldVariable.prototype.configure_ = function(config) {
*/
Blockly.FieldVariable.prototype.initModel = function() {
if (this.variable_) {
return; // Initialization already happened.
return; // Initialization already happened.
}
var variable = Blockly.Variables.getOrCreateVariablePackage(
this.sourceBlock_.workspace, null,
Expand Down Expand Up @@ -300,7 +300,7 @@ Blockly.FieldVariable.prototype.doValueUpdate_ = function(newId) {
Blockly.FieldVariable.prototype.typeIsAllowed_ = function(type) {
var typeList = this.getVariableTypes_();
if (!typeList) {
return true; // If it's null, all types are valid.
return true; // If it's null, all types are valid.
}
for (var i = 0; i < typeList.length; i++) {
if (type == typeList[i]) {
Expand Down
2 changes: 1 addition & 1 deletion core/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface,
mainWorkspace.getTheme().getClassName());

if (!wsOptions.hasCategories && wsOptions.languageTree) {
// Add flyout as an <svg> that is a sibling of the workspace svg.
// Add flyout as an <svg> that is a sibling of the workspace SVG.
var flyout = mainWorkspace.addFlyout(Blockly.utils.Svg.SVG);
Blockly.utils.dom.insertAfter(flyout, svg);
}
Expand Down
2 changes: 1 addition & 1 deletion core/insertion_marker_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ Blockly.InsertionMarkerManager.prototype.shouldUpdatePreviews_ = function(
} else {
console.error('Only one of localConnection_ and closestConnection_ was set.');
}
} else { // No connection found.
} else { // No connection found.
// Only need to update if we were showing a preview before.
return !!(this.localConnection_ && this.closestConnection_);
}
Expand Down
4 changes: 2 additions & 2 deletions core/mutator.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ Blockly.Mutator.prototype.createEditor_ = function() {
this.workspace_.addChangeListener(Blockly.Events.disableOrphans);

// Mutator flyouts go inside the mutator workspace's <g> rather than in
// a top level svg. Instead of handling scale themselves, mutators
// a top level SVG. Instead of handling scale themselves, mutators
// inherit scale from the parent workspace.
// To fix this, scale needs to be applied at a different level in the dom.
// To fix this, scale needs to be applied at a different level in the DOM.
var flyoutSvg = hasFlyout ?
this.workspace_.addFlyout(Blockly.utils.Svg.G) : null;
var background = this.workspace_.createDom('blocklyMutatorBackground');
Expand Down
6 changes: 3 additions & 3 deletions core/renderers/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ Blockly.blockRendering.ConstantProvider = function() {
* to be the height of the text based on the font used.
* @type {number}
*/
this.FIELD_TEXT_HEIGHT = -1; // Dynamically set
this.FIELD_TEXT_HEIGHT = -1; // Dynamically set.

/**
* Text baseline. This constant is dynamically set in ``setFontConstants_``
* to be the baseline of the text based on the font used.
* @type {number}
*/
this.FIELD_TEXT_BASELINE = -1; // Dynamically set
this.FIELD_TEXT_BASELINE = -1; // Dynamically set.

/**
* A field's border rect corner radius.
Expand Down Expand Up @@ -855,7 +855,7 @@ Blockly.blockRendering.ConstantProvider.prototype.makePuzzleTab = function() {
var halfHeight = height / 2;
var control1Y = halfHeight + overlap;
var control2Y = halfHeight + 0.5;
var control3Y = overlap; // 2.5
var control3Y = overlap; // 2.5

var endPoint1 = Blockly.utils.svgPaths.point(-width, forward * halfHeight);
var endPoint2 = Blockly.utils.svgPaths.point(width, forward * halfHeight);
Expand Down
4 changes: 2 additions & 2 deletions core/renderers/common/drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Blockly.blockRendering.Drawer.prototype.drawRightSideRow_ = function(row) {

/**
* Add steps for the bottom edge of a block, possibly including a notch
* for the next connection
* for the next connection.
* @protected
*/
Blockly.blockRendering.Drawer.prototype.drawBottom_ = function() {
Expand Down Expand Up @@ -449,7 +449,7 @@ Blockly.blockRendering.Drawer.prototype.positionNextConnection_ = function() {

if (bottomRow.connection) {
var connInfo = bottomRow.connection;
var x = connInfo.xPos; // Already contains info about startX
var x = connInfo.xPos; // Already contains info about startX.
var connX = (this.info_.RTL ? -x : x);
connInfo.connectionModel.setOffsetInBlock(connX, bottomRow.baseline);
}
Expand Down
2 changes: 1 addition & 1 deletion core/renderers/geras/drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Blockly.geras.Drawer.prototype.positionNextConnection_ = function() {

if (bottomRow.connection) {
var connInfo = bottomRow.connection;
var x = connInfo.xPos; // Already contains info about startX
var x = connInfo.xPos; // Already contains info about startX.
var connX = (this.info_.RTL ? -x : x) +
(this.constants_.DARK_PATH_OFFSET / 2);
connInfo.connectionModel.setOffsetInBlock(
Expand Down
30 changes: 15 additions & 15 deletions core/renderers/zelos/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,23 +214,23 @@ Blockly.zelos.ConstantProvider = function() {
* @package
*/
this.SHAPE_IN_SHAPE_PADDING = {
1: { // Outer shape: hexagon.
0: 5 * this.GRID_UNIT, // Field in hexagon.
1: 2 * this.GRID_UNIT, // Hexagon in hexagon.
2: 5 * this.GRID_UNIT, // Round in hexagon.
3: 5 * this.GRID_UNIT // Square in hexagon.
1: { // Outer shape: hexagon.
0: 5 * this.GRID_UNIT, // Field in hexagon.
1: 2 * this.GRID_UNIT, // Hexagon in hexagon.
2: 5 * this.GRID_UNIT, // Round in hexagon.
3: 5 * this.GRID_UNIT // Square in hexagon.
},
2: { // Outer shape: round.
0: 3 * this.GRID_UNIT, // Field in round.
1: 3 * this.GRID_UNIT, // Hexagon in round.
2: 1 * this.GRID_UNIT, // Round in round.
3: 2 * this.GRID_UNIT // Square in round.
2: { // Outer shape: round.
0: 3 * this.GRID_UNIT, // Field in round.
1: 3 * this.GRID_UNIT, // Hexagon in round.
2: 1 * this.GRID_UNIT, // Round in round.
3: 2 * this.GRID_UNIT // Square in round.
},
3: { // Outer shape: square.
0: 2 * this.GRID_UNIT, // Field in square.
1: 2 * this.GRID_UNIT, // Hexagon in square.
2: 2 * this.GRID_UNIT, // Round in square.
3: 2 * this.GRID_UNIT // Square in square.
3: { // Outer shape: square.
0: 2 * this.GRID_UNIT, // Field in square.
1: 2 * this.GRID_UNIT, // Hexagon in square.
2: 2 * this.GRID_UNIT, // Round in square.
3: 2 * this.GRID_UNIT // Square in square.
}
};

Expand Down
4 changes: 2 additions & 2 deletions core/theme/highcontrast.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Blockly.Themes.HighContrast.setComponentStyle('selectedGlowSize', 1);
Blockly.Themes.HighContrast.setComponentStyle('replacementGlowColour', '#000000');

Blockly.Themes.HighContrast.setFontStyle({
'family': null, // Use default font-family
'weight': null, // Use default font-weight
'family': null, // Use default font-family.
'weight': null, // Use default font-weight.
'size': 16
});
6 changes: 3 additions & 3 deletions core/toolbox/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ Blockly.Toolbox.prototype.render = function(toolboxDef) {
*/
Blockly.Toolbox.prototype.renderContents_ = function(toolboxDef) {
// This is for performance reasons. By using document fragment we only have to
// add to the dom once.
// add to the DOM once.
var fragment = document.createDocumentFragment();
for (var i = 0, toolboxItemDef; (toolboxItemDef = toolboxDef[i]); i++) {
this.createToolboxItem_(toolboxItemDef, fragment);
Expand All @@ -426,7 +426,7 @@ Blockly.Toolbox.prototype.createToolboxItem_ = function(toolboxItemDef, fragment
var registryName = toolboxItemDef['kind'];

// Categories that are collapsible are created using a class registered under
// a diffferent name.
// a different name.
if (registryName.toUpperCase() == 'CATEGORY' &&
Blockly.utils.toolbox.isCategoryCollapsible(
/** @type {!Blockly.utils.toolbox.CategoryInfo} */(toolboxItemDef))) {
Expand All @@ -443,7 +443,7 @@ Blockly.Toolbox.prototype.createToolboxItem_ = function(toolboxItemDef, fragment
if (toolboxItemDom) {
fragment.appendChild(toolboxItemDom);
}
// Adds the id to the html element that can receive a click.
// Adds the ID to the HTML element that can receive a click.
// This is used in onClick_ to find the toolboxItem that was clicked.
if (toolboxItem.getClickTarget) {
toolboxItem.getClickTarget().setAttribute('id', toolboxItem.getId());
Expand Down
Loading

0 comments on commit cff7b35

Please sign in to comment.