From caccf3fcf7cbc01ec9081022a94e5af2148694b1 Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Tue, 2 Aug 2016 15:57:12 -0700 Subject: [PATCH] Use the correct closure when executing block actions. --- accessible/workspace-tree.component.js | 29 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/accessible/workspace-tree.component.js b/accessible/workspace-tree.component.js index 5999dd2ea..dc1ff1089 100644 --- a/accessible/workspace-tree.component.js +++ b/accessible/workspace-tree.component.js @@ -210,6 +210,21 @@ blocklyApp.WorkspaceTreeComponent = ng.core alert('Block moved to marked spot: ' + blockDescription); }); }, + copyBlock_: function() { + this.clipboardService.copy(this.block, true); + }, + markSpotBelow_: function() { + this.clipboardService.markConnection(this.block.nextConnection); + }, + markSpotAbove_: function() { + this.clipboardService.markConnection(this.block.previousConnection); + }, + pasteToNextConnection_: function() { + this.pasteToConnection_(this.block.nextConnection); + }, + pasteToPreviousConnection_: function() { + this.pasteToConnection_(this.block.previousConnection); + }, ngOnInit: function() { var that = this; @@ -224,15 +239,14 @@ blocklyApp.WorkspaceTreeComponent = ng.core }, { baseIdKey: 'copy', translationIdForText: 'COPY_BLOCK', - action: that.clipboardService.copy.bind( - that.clipboardService, that.block, true), + action: that.copyBlock_.bind(that), isDisabled: function() { return false; } }, { baseIdKey: 'pasteBelow', translationIdForText: 'PASTE_BELOW', - action: that.pasteToConnection_.bind(that, that.block.nextConnection), + action: that.pasteToNextConnection_.bind(that), isDisabled: function() { return Boolean( !that.block.nextConnection || @@ -241,8 +255,7 @@ blocklyApp.WorkspaceTreeComponent = ng.core }, { baseIdKey: 'pasteAbove', translationIdForText: 'PASTE_ABOVE', - action: that.pasteToConnection_.bind( - that, that.block.previousConnection), + action: that.pasteToPreviousConnection_.bind(that), isDisabled: function() { return Boolean( !that.block.previousConnection || @@ -251,16 +264,14 @@ blocklyApp.WorkspaceTreeComponent = ng.core }, { baseIdKey: 'markBelow', translationIdForText: 'MARK_SPOT_BELOW', - action: that.clipboardService.markConnection.bind( - that.clipboardService, that.block.nextConnection), + action: that.markSpotBelow_.bind(that), isDisabled: function() { return !that.block.nextConnection; } }, { baseIdKey: 'markAbove', translationIdForText: 'MARK_SPOT_ABOVE', - action: that.clipboardService.markConnection.bind( - that.clipboardService, that.block.previousConnection), + action: that.markSpotAbove_.bind(that), isDisabled: function() { return !that.block.previousConnection; }