diff --git a/core/block.js b/core/block.js index 36fb5ac28..38709e781 100644 --- a/core/block.js +++ b/core/block.js @@ -36,10 +36,11 @@ goog.require('Blockly.Events.BlockMove'); goog.require('Blockly.Extensions'); goog.require('Blockly.Input'); goog.require('Blockly.Mutator'); +goog.require('Blockly.utils'); goog.require('Blockly.Warning'); goog.require('Blockly.Workspace'); goog.require('Blockly.Xml'); -goog.require('goog.array'); + goog.require('goog.math.Coordinate'); @@ -496,7 +497,7 @@ Blockly.Block.prototype.setParent = function(newParent) { } if (this.parentBlock_) { // Remove this block from the old parent's child list. - goog.array.remove(this.parentBlock_.childBlocks_, this); + Blockly.utils.arrayRemove(this.parentBlock_.childBlocks_, this); // Disconnect from superior blocks. if (this.previousConnection && this.previousConnection.isConnected()) { @@ -1444,7 +1445,7 @@ Blockly.Block.prototype.removeInput = function(name, opt_quiet) { } } if (!opt_quiet) { - throw ReferenceErrer('Input not found: ' + name); + throw ReferenceError('Input not found: ' + name); } }; diff --git a/core/block_events.js b/core/block_events.js index 2bc6d6b23..b3a25be6f 100644 --- a/core/block_events.js +++ b/core/block_events.js @@ -37,7 +37,6 @@ goog.provide('Blockly.Events.Move'); // Deprecated. goog.require('Blockly.Events'); goog.require('Blockly.Events.Abstract'); -goog.require('goog.array'); goog.require('goog.math.Coordinate'); diff --git a/core/block_svg.js b/core/block_svg.js index b26396945..fbf9ea947 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -37,6 +37,7 @@ goog.require('Blockly.Tooltip'); goog.require('Blockly.Touch'); goog.require('Blockly.utils'); +goog.require('goog.color'); goog.require('goog.dom'); goog.require('goog.math.Coordinate'); diff --git a/core/connection.js b/core/connection.js index 23dbdb6cb..d6988c55e 100644 --- a/core/connection.js +++ b/core/connection.js @@ -654,9 +654,13 @@ Blockly.Connection.prototype.toString = function() { } else if (block.nextConnection == this) { msg = 'Next Connection of '; } else { - var parentInput = goog.array.find(block.inputList, function(input) { - return input.connection == this; - }, this); + var parentInput = null; + for (var i = 0, input; input = block.inputList[i]; i++) { + if (input.connection == this) { + parentInput = input; + break; + } + } if (parentInput) { msg = 'Input "' + parentInput.name + '" connection on '; } else { diff --git a/core/events.js b/core/events.js index b57d8c0e5..da4cbd3c7 100644 --- a/core/events.js +++ b/core/events.js @@ -30,7 +30,6 @@ */ goog.provide('Blockly.Events'); -goog.require('goog.array'); goog.require('goog.math.Coordinate'); @@ -193,7 +192,7 @@ Blockly.Events.fireNow_ = function() { * @return {!Array.} Array of filtered events. */ Blockly.Events.filter = function(queueIn, forward) { - var queue = goog.array.clone(queueIn); + var queue = queueIn.slice(); // Shallow copy of queue. if (!forward) { // Undo is merged in reverse order. queue.reverse(); diff --git a/core/events_abstract.js b/core/events_abstract.js index 17eea76d1..156353137 100644 --- a/core/events_abstract.js +++ b/core/events_abstract.js @@ -28,8 +28,6 @@ goog.provide('Blockly.Events.Abstract'); goog.require('Blockly.Events'); -goog.require('goog.array'); -goog.require('goog.math.Coordinate'); /** * Abstract class for an event. diff --git a/core/ui_events.js b/core/ui_events.js index 2430ac928..d3ec6d6da 100644 --- a/core/ui_events.js +++ b/core/ui_events.js @@ -29,8 +29,6 @@ goog.provide('Blockly.Events.Ui'); goog.require('Blockly.Events'); goog.require('Blockly.Events.Abstract'); -goog.require('goog.array'); -goog.require('goog.math.Coordinate'); /** * Class for a UI event. diff --git a/core/utils.js b/core/utils.js index 478c07228..9fc42a912 100644 --- a/core/utils.js +++ b/core/utils.js @@ -912,3 +912,19 @@ Blockly.utils.getViewportBBox = function() { Blockly.utils.startsWith = function(str, prefix) { return str.lastIndexOf(prefix, 0) == 0; }; + +/** + * Removes the first occurrence of a particular value from an array. + * @param {!Array} arr Array from which to remove + * value. + * @param {*} obj Object to remove. + * @return {boolean} True if an element was removed. + */ +Blockly.utils.arrayRemove = function(arr, obj) { + var i = arr.indexOf(obj); + if (i == -1) { + return false; + } + arr.splice(i, 1); + return true; +}; diff --git a/core/variable_events.js b/core/variable_events.js index 8691dbb0f..b9b40c84c 100644 --- a/core/variable_events.js +++ b/core/variable_events.js @@ -32,9 +32,6 @@ goog.provide('Blockly.Events.VarRename'); goog.require('Blockly.Events'); goog.require('Blockly.Events.Abstract'); -goog.require('goog.array'); -goog.require('goog.math.Coordinate'); - /** * Abstract class for a variable event. diff --git a/core/workspace.js b/core/workspace.js index 04952a189..90a3cd3d5 100644 --- a/core/workspace.js +++ b/core/workspace.js @@ -26,9 +26,10 @@ goog.provide('Blockly.Workspace'); +goog.require('Blockly.utils'); goog.require('Blockly.VariableMap'); goog.require('Blockly.WorkspaceComment'); -goog.require('goog.array'); + goog.require('goog.math'); @@ -160,7 +161,7 @@ Blockly.Workspace.prototype.addTopBlock = function(block) { * @param {!Blockly.Block} block Block to remove. */ Blockly.Workspace.prototype.removeTopBlock = function(block) { - if (!goog.array.remove(this.topBlocks_, block)) { + if (!Blockly.utils.arrayRemove(this.topBlocks_, block)) { throw Error('Block not present in workspace\'s list of top-most blocks.'); } }; @@ -211,7 +212,7 @@ Blockly.Workspace.prototype.addTopComment = function(comment) { * @package */ Blockly.Workspace.prototype.removeTopComment = function(comment) { - if (!goog.array.remove(this.topComments_, comment)) { + if (!Blockly.utils.arrayRemove(this.topComments_, comment)) { throw Error('Comment not present in workspace\'s list of top-most ' + 'comments.'); } @@ -511,7 +512,7 @@ Blockly.Workspace.prototype.addChangeListener = function(func) { * @param {Function} func Function to stop calling. */ Blockly.Workspace.prototype.removeChangeListener = function(func) { - goog.array.remove(this.listeners_, func); + Blockly.utils.arrayRemove(this.listeners_, func); }; /** diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 56e1516ac..ac1d00707 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -38,6 +38,7 @@ goog.require('Blockly.ScrollbarPair'); goog.require('Blockly.Touch'); goog.require('Blockly.TouchGesture'); goog.require('Blockly.Trashcan'); +goog.require('Blockly.utils'); goog.require('Blockly.VariablesDynamic'); goog.require('Blockly.Workspace'); goog.require('Blockly.WorkspaceAudio'); @@ -48,7 +49,6 @@ goog.require('Blockly.WorkspaceDragSurfaceSvg'); goog.require('Blockly.Xml'); goog.require('Blockly.ZoomControls'); -goog.require('goog.array'); goog.require('goog.dom'); goog.require('goog.math.Coordinate'); @@ -926,7 +926,7 @@ Blockly.WorkspaceSvg.prototype.highlightBlock = function(id, opt_state) { var state = (opt_state === undefined) || opt_state; // Using Set here would be great, but at the cost of IE10 support. if (!state) { - goog.array.remove(this.highlightedBlocks_, block); + Blockly.utils.arrayRemove(this.highlightedBlocks_, block); } else if (this.highlightedBlocks_.indexOf(block) == -1) { this.highlightedBlocks_.push(block); }