mirror of
https://github.com/google/blockly.git
synced 2026-01-23 16:50:10 +01:00
Change the TreeService to a singleton.
This commit is contained in:
@@ -37,27 +37,24 @@ blocklyApp.WorkspaceComponent = ng.core
|
||||
{{buttonConfig.text}}
|
||||
</button>
|
||||
</span>
|
||||
<button id="clear-workspace" (click)="workspace.clear()"
|
||||
<button id="clear-workspace" (click)="clearWorkspace()"
|
||||
[disabled]="isWorkspaceEmpty()" class="blocklyTree">
|
||||
{{'CLEAR_WORKSPACE'|translate}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div *ngIf="workspace">
|
||||
<ol #tree id="blockly-workspace-tree{{i}}" *ngFor="#block of workspace.topBlocks_; #i = index"
|
||||
tabIndex="0" role="group" class="blocklyTree" [attr.aria-labelledby]="workspaceTitle.id"
|
||||
[attr.aria-activedescendant]="tree.getAttribute('aria-activedescendant') || tree.id + '-node0' "
|
||||
<ol #tree *ngFor="#block of workspace.topBlocks_; #i = index"
|
||||
tabIndex="0" role="group" class="blocklyTree"
|
||||
[attr.aria-labelledby]="workspaceTitle.id"
|
||||
(keydown)="onKeypress($event, tree)">
|
||||
<blockly-workspace-tree [level]=1 [block]="block" [isTopBlock]="true"
|
||||
[topBlockIndex]="i" [parentId]="tree.id"
|
||||
[tree]="tree">
|
||||
<blockly-workspace-tree [level]=1 [block]="block" [tree]="tree">
|
||||
</blockly-workspace-tree>
|
||||
</ol>
|
||||
</div>
|
||||
`,
|
||||
directives: [blocklyApp.WorkspaceTreeComponent],
|
||||
pipes: [blocklyApp.TranslatePipe],
|
||||
providers: [blocklyApp.TreeService]
|
||||
pipes: [blocklyApp.TranslatePipe]
|
||||
})
|
||||
.Class({
|
||||
constructor: [blocklyApp.TreeService, function(_treeService) {
|
||||
@@ -72,14 +69,18 @@ blocklyApp.WorkspaceComponent = ng.core
|
||||
this.workspace = blocklyApp.workspace;
|
||||
this.treeService = _treeService;
|
||||
}],
|
||||
clearWorkspace: function() {
|
||||
this.workspace.clear();
|
||||
this.treeService.initTreeRegistry();
|
||||
},
|
||||
onWorkspaceToolbarKeypress: function(event) {
|
||||
var activeElementId = document.activeElement.id;
|
||||
this.treeService.onWorkspaceToolbarKeypress(event, activeElementId);
|
||||
this.treeService.onWorkspaceToolbarKeypress(
|
||||
event, document.activeElement.id);
|
||||
},
|
||||
onKeypress: function(event, tree){
|
||||
this.treeService.onKeypress(event, tree);
|
||||
},
|
||||
isWorkspaceEmpty: function() {
|
||||
return !blocklyApp.workspace.topBlocks_.length;
|
||||
return !this.workspace.topBlocks_.length;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user