From 04785a22229ee6cd46d7d15ab1045b09dd194161 Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Mon, 5 Dec 2016 17:39:03 -0800 Subject: [PATCH] Clean up the sidebar file and remove unneeded code. --- accessible/sidebar.component.js | 66 +++++++++++++------------------ accessible/tree.service.js | 11 ------ accessible/workspace.component.js | 21 +++++++--- 3 files changed, 43 insertions(+), 55 deletions(-) diff --git a/accessible/sidebar.component.js b/accessible/sidebar.component.js index d614c193e..23be536ae 100644 --- a/accessible/sidebar.component.js +++ b/accessible/sidebar.component.js @@ -28,33 +28,30 @@ blocklyApp.SidebarComponent = ng.core.Component({ selector: 'blockly-sidebar', template: `
-
- - - - - - -
+ + + +
`, pipes: [blocklyApp.TranslatePipe] @@ -75,7 +72,6 @@ blocklyApp.SidebarComponent = ng.core.Component({ this.customSidebarButtons = ACCESSIBLE_GLOBALS && ACCESSIBLE_GLOBALS.customSidebarButtons ? ACCESSIBLE_GLOBALS.customSidebarButtons : []; - this.workspace = blocklyApp.workspace; this.blockConnectionService = blockConnectionService; this.toolboxModalService = toolboxModalService; @@ -89,19 +85,13 @@ blocklyApp.SidebarComponent = ng.core.Component({ isAnyConnectionMarked: function() { return this.blockConnectionService.isAnyConnectionMarked(); }, - handleButtonClick: function(buttonConfig) { - buttonConfig.action(); - }, - clearWorkspace: function() { - this.workspace.clear(); - document.getElementById(this.ID_FOR_CREATE_NEW_GROUP_BUTTON).focus(); - }, - onSidebarKeypress: function(e) { - this.treeService.onSidebarKeypress(e, document.activeElement.id); - }, isWorkspaceEmpty: function() { return this.utilsService.isWorkspaceEmpty(); }, + clearWorkspace: function() { + blocklyApp.workspace.clear(); + document.getElementById(this.ID_FOR_CREATE_NEW_GROUP_BUTTON).focus(); + }, showToolboxModalForAttachToMarkedConnection: function() { this.toolboxModalService.showToolboxModalForAttachToMarkedConnection( this.ID_FOR_ATTACH_TO_LINK_BUTTON); diff --git a/accessible/tree.service.js b/accessible/tree.service.js index 4c2e24584..5589c3983 100644 --- a/accessible/tree.service.js +++ b/accessible/tree.service.js @@ -169,17 +169,6 @@ blocklyApp.TreeService = ng.core.Class({ that.setActiveDesc(blockId + 'blockRoot', domNode.id); }, 100); }, - onSidebarKeypress: function(e, treeId) { - if (e.keyCode == 9) { - // Tab key. - var destinationTreeId = - e.shiftKey ? this.getIdOfPreviousTree_(treeId) : - this.getIdOfNextTree_(treeId); - if (destinationTreeId) { - this.notifyUserAboutCurrentTree_(destinationTreeId); - } - } - }, getNextActiveDescWhenBlockIsDeleted: function(blockRootNode) { // Go up a level, if possible. var nextNode = blockRootNode.parentNode; diff --git a/accessible/workspace.component.js b/accessible/workspace.component.js index bbc84b9df..3fd35ac59 100644 --- a/accessible/workspace.component.js +++ b/accessible/workspace.component.js @@ -35,7 +35,8 @@ blocklyApp.WorkspaceComponent = ng.core.Component({ tabindex="0" role="tree" class="blocklyTree blocklyWorkspaceFocusTarget" [attr.aria-activedescendant]="getActiveDescId(tree.id)" [attr.aria-labelledby]="workspaceTitle.id" - (keydown)="onKeypress($event, tree)"> + (keydown)="onKeypress($event, tree)" + (focus)="speakLocation(i)"> @@ -58,12 +59,15 @@ blocklyApp.WorkspaceComponent = ng.core.Component({ }) .Class({ constructor: [ - blocklyApp.TreeService, blocklyApp.ToolboxModalService, - function(_treeService, _toolboxModalService) { - this.treeService = _treeService; - this.toolboxModalService = _toolboxModalService; - this.workspace = blocklyApp.workspace; + blocklyApp.NotificationsService, + blocklyApp.ToolboxModalService, + blocklyApp.TreeService, + function(notificationsService, toolboxModalService, treeService) { + this.notificationsService = notificationsService; + this.toolboxModalService = toolboxModalService; + this.treeService = treeService; + this.workspace = blocklyApp.workspace; this.ID_FOR_EMPTY_WORKSPACE_BTN = 'blocklyEmptyWorkspaceButton'; } ], @@ -76,5 +80,10 @@ blocklyApp.WorkspaceComponent = ng.core.Component({ showToolboxModalForCreateNewGroup: function() { this.toolboxModalService.showToolboxModalForCreateNewGroup( this.ID_FOR_EMPTY_WORKSPACE_BTN); + }, + speakLocation: function(index) { + this.notificationsService.speak( + 'Now in workspace group ' + (index + 1) + ' of ' + + this.workspace.topBlocks_.length); } });