diff --git a/blocks/lists.js b/blocks/lists.js index d22bbc490..eea532a7a 100644 --- a/blocks/lists.js +++ b/blocks/lists.js @@ -195,7 +195,7 @@ Blockly.Blocks['lists_create_with_container'] = { Blockly.Blocks['lists_create_with_item'] = { /** - * Mutator bolck for adding items. + * Mutator block for adding items. * @this Blockly.Block */ init: function() { diff --git a/blocks/logic.js b/blocks/logic.js index 3a74e2872..35cf49f74 100644 --- a/blocks/logic.js +++ b/blocks/logic.js @@ -236,7 +236,7 @@ Blockly.Blocks['controls_if_if'] = { Blockly.Blocks['controls_if_elseif'] = { /** - * Mutator bolck for else-if condition. + * Mutator block for else-if condition. * @this Blockly.Block */ init: function() { @@ -268,6 +268,7 @@ Blockly.Blocks['controls_if_else'] = { Blockly.Blocks['controls_ifelse'] = { /** * If/else block that does not use a mutator. + * @this Blockly.Block */ init: function() { this.jsonInit({ @@ -303,7 +304,7 @@ Blockly.Blocks['controls_ifelse'] = { "colour": Blockly.Blocks.logic.HUE, "tooltip": Blockly.Msg.CONTROLS_IF_TOOLTIP_2, "helpUrl": Blockly.Msg.CONTROLS_IF_HELPURL - }); + }); } }; diff --git a/core/utils.js b/core/utils.js index ca2c9c641..f3b65b7c2 100644 --- a/core/utils.js +++ b/core/utils.js @@ -78,6 +78,7 @@ Blockly.utils.removeClass = function(element, className) { } else { element.removeAttribute('class'); } + return true; }; /** diff --git a/core/workspace.js b/core/workspace.js index 6d6a71307..46661f532 100644 --- a/core/workspace.js +++ b/core/workspace.js @@ -301,45 +301,46 @@ Blockly.Workspace.prototype.getVariableUses = function(name) { * @param {string} name Name of variable to delete. */ Blockly.Workspace.prototype.deleteVariable = function(name) { - var workspace = this; var variableIndex = this.variableIndexOf(name); - if (variableIndex != -1) { - // Check whether this variable is a function parameter before deleting. - var uses = this.getVariableUses(name); - for (var i = 0, block; block = uses[i]; i++) { - if (block.type == 'procedures_defnoreturn' || - block.type == 'procedures_defreturn') { - var procedureName = block.getFieldValue('NAME'); - Blockly.alert( - Blockly.Msg.CANNOT_DELETE_VARIABLE_PROCEDURE. - replace('%1', name). - replace('%2', procedureName)); - return; - } + if (variableIndex == -1) { + return; + } + // Check whether this variable is a function parameter before deleting. + var uses = this.getVariableUses(name); + for (var i = 0, block; block = uses[i]; i++) { + if (block.type == 'procedures_defnoreturn' || + block.type == 'procedures_defreturn') { + var procedureName = block.getFieldValue('NAME'); + Blockly.alert( + Blockly.Msg.CANNOT_DELETE_VARIABLE_PROCEDURE. + replace('%1', name). + replace('%2', procedureName)); + return; } - - function doDeletion() { - Blockly.Events.setGroup(true); - for (var i = 0; i < uses.length; i++) { - uses[i].dispose(true, false); - } - Blockly.Events.setGroup(false); - workspace.variableList.splice(variableIndex, 1); - } - if (uses.length > 1) { - // Confirm before deleting multiple blocks. - Blockly.confirm( - Blockly.Msg.DELETE_VARIABLE_CONFIRMATION.replace('%1', uses.length). - replace('%2', name), - function(ok) { - if (ok) { - doDeletion(); - } - }); - } else { - // No confirmation necessary for a single block. - doDeletion(); + } + + var workspace = this; + function doDeletion() { + Blockly.Events.setGroup(true); + for (var i = 0; i < uses.length; i++) { + uses[i].dispose(true, false); } + Blockly.Events.setGroup(false); + workspace.variableList.splice(variableIndex, 1); + } + if (uses.length > 1) { + // Confirm before deleting multiple blocks. + Blockly.confirm( + Blockly.Msg.DELETE_VARIABLE_CONFIRMATION.replace('%1', uses.length). + replace('%2', name), + function(ok) { + if (ok) { + doDeletion(); + } + }); + } else { + // No confirmation necessary for a single block. + doDeletion(); } };