mirror of
https://github.com/google/blockly.git
synced 2026-01-10 10:27:08 +01:00
Remove goog.array
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.<!Blockly.Events.Abstract>} 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();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user