From f623004b3a675d6eb7afd67610ef74117f71a283 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 16 May 2018 12:52:12 -0700 Subject: [PATCH] Small changes --- core/block.js | 7 +++++-- core/block_svg.js | 14 ++++++++++---- core/dragged_connection_manager.js | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/core/block.js b/core/block.js index 5386b4372..3c9988c7c 100644 --- a/core/block.js +++ b/core/block.js @@ -259,6 +259,10 @@ Blockly.Block.prototype.dispose = function(healStack) { // well as corruption of the connection database. Therefore we must // methodically step through the blocks and carefully disassemble them. + if (Blockly.selected == this) { + Blockly.selected = null; + } + // First, dispose of all my children. for (var i = this.childBlocks_.length - 1; i >= 0; i--) { this.childBlocks_[i].dispose(false); @@ -365,7 +369,7 @@ Blockly.Block.prototype.getConnections_ = function(_all) { * @return {Blockly.Connection} The last next connection on the stack, or null. * @package */ -Blockly.Block.prototype.lastConnectionInStack_ = function() { +Blockly.Block.prototype.lastConnectionInStack = function() { var nextConnection = this.nextConnection; while (nextConnection) { var nextBlock = nextConnection.targetBlock(); @@ -1282,7 +1286,6 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) { case 'input_dummy': input = this.appendDummyInput(element['name']); break; - default: field = Blockly.Field.fromJson(element); diff --git a/core/block_svg.js b/core/block_svg.js index e1fda02f6..313103794 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -36,6 +36,7 @@ goog.require('Blockly.RenderedConnection'); goog.require('Blockly.Tooltip'); goog.require('Blockly.Touch'); goog.require('Blockly.utils'); + goog.require('goog.Timer'); goog.require('goog.asserts'); goog.require('goog.dom'); @@ -320,13 +321,18 @@ Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() { */ Blockly.BlockSvg.prototype.moveBy = function(dx, dy) { goog.asserts.assert(!this.parentBlock_, 'Block has parent.'); - var event = new Blockly.Events.BlockMove(this); + var eventsEnabled = Blockly.Events.isEnabled(); + if (eventsEnabled) { + var event = new Blockly.Events.BlockMove(this); + } var xy = this.getRelativeToSurfaceXY(); this.translate(xy.x + dx, xy.y + dy); this.moveConnections_(dx, dy); - event.recordNew(); + if (eventsEnabled) { + event.recordNew(); + Blockly.Events.fire(event); + } this.workspace.resizeContents(); - Blockly.Events.fire(event); }; /** @@ -570,7 +576,7 @@ Blockly.BlockSvg.prototype.createTabList_ = function() { * @private */ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) { - var gesture = this.workspace.getGesture(e); + var gesture = this.workspace && this.workspace.getGesture(e); if (gesture) { gesture.handleBlockStart(e, this); } diff --git a/core/dragged_connection_manager.js b/core/dragged_connection_manager.js index 5763a9a9d..fc5525fd5 100644 --- a/core/dragged_connection_manager.js +++ b/core/dragged_connection_manager.js @@ -215,7 +215,7 @@ Blockly.DraggedConnectionManager.prototype.addHighlighting_ = function() { Blockly.DraggedConnectionManager.prototype.initAvailableConnections_ = function() { var available = this.topBlock_.getConnections_(false); // Also check the last connection on this stack - var lastOnStack = this.topBlock_.lastConnectionInStack_(); + var lastOnStack = this.topBlock_.lastConnectionInStack(); if (lastOnStack && lastOnStack != this.topBlock_.nextConnection) { available.push(lastOnStack); }