From 01a7825107e3d0eafc931bd5bda8760782bd3a98 Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Thu, 28 Jul 2016 14:44:19 -0700 Subject: [PATCH] Refactor getBlockDescription() into a separate method in UtilsService. --- accessible/clipboard.service.js | 14 ++++++++------ accessible/toolbox-tree.component.js | 9 ++++++--- accessible/utils.service.js | 3 +++ accessible/workspace-tree.component.js | 13 ++++++++++--- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/accessible/clipboard.service.js b/accessible/clipboard.service.js index 246d9a2af..ed3ad9f6f 100644 --- a/accessible/clipboard.service.js +++ b/accessible/clipboard.service.js @@ -24,12 +24,13 @@ blocklyApp.ClipboardService = ng.core .Class({ - constructor: function() { + constructor: [blocklyApp.UtilsService, function(_utilsService) { this.clipboardBlockXml_ = null; this.clipboardBlockSuperiorConnection_ = null; this.clipboardBlockNextConnection_ = null; this.markedConnection_ = null; - }, + this.utilsService = _utilsService; + }], areConnectionsCompatible_: function(blockConnection, connection) { // Check that both connections exist, that it's the right kind of // connection, and that the types match. @@ -85,18 +86,19 @@ blocklyApp.ClipboardService = ng.core alert(Blockly.Msg.MARKED_SPOT_MSG); }, cut: function(block) { - var blockSummary = block.toString(); this.copy(block, false); block.dispose(true); - alert(Blockly.Msg.CUT_BLOCK_MSG + blockSummary); }, copy: function(block, announce) { this.clipboardBlockXml_ = Blockly.Xml.blockToDom(block); this.clipboardBlockSuperiorConnection_ = block.outputConnection || block.previousConnection; this.clipboardBlockNextConnection_ = block.nextConnection; + if (announce) { - alert(Blockly.Msg.COPIED_BLOCK_MSG + block.toString()); + alert( + Blockly.Msg.COPIED_BLOCK_MSG + + utilsService.getBlockDescription(block)); } }, pasteFromClipboard: function(connection) { @@ -114,7 +116,7 @@ blocklyApp.ClipboardService = ng.core } alert( Blockly.Msg.PASTED_BLOCK_FROM_CLIPBOARD_MSG + - reconstitutedBlock.toString()); + utilsService.getBlockDescription(reconstitutedBlock)); return reconstitutedBlock.id; }, pasteToMarkedConnection: function(block) { diff --git a/accessible/toolbox-tree.component.js b/accessible/toolbox-tree.component.js index 42449e4a9..b0278a3c7 100644 --- a/accessible/toolbox-tree.component.js +++ b/accessible/toolbox-tree.component.js @@ -32,7 +32,7 @@ blocklyApp.ToolboxTreeComponent = ng.core [ngClass]="{blocklyHasChildren: displayBlockMenu || block.inputList.length > 0, blocklyActiveDescendant: index == 0 && noCategories}" [attr.aria-labelledBy]="generateAriaLabelledByAttr('blockly-block-summary', idMap['blockSummaryLabel'])" [attr.aria-level]="level"> - +
  1. - +