app.component.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * AccessibleBlockly
  3. *
  4. * Copyright 2016 Google Inc.
  5. * https://developers.google.com/blockly/
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the 'License');
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an 'AS IS' BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. /**
  20. * @fileoverview Angular2 Component that details how the AccessibleBlockly
  21. * app is rendered on the page.
  22. * @author madeeha@google.com (Madeeha Ghori)
  23. */
  24. blocklyApp.workspace = new Blockly.Workspace();
  25. blocklyApp.AppView = ng.core
  26. .Component({
  27. selector: 'blockly-app',
  28. template: `
  29. <div *ngIf="getStatusMessage()" aria-hidden="true" class="blocklyAriaLiveStatus">
  30. <span aria-live="polite" role="status">{{getStatusMessage()}}</span>
  31. </div>
  32. <div>
  33. <blockly-toolbox></blockly-toolbox>
  34. <blockly-workspace></blockly-workspace>
  35. </div>
  36. <label aria-hidden="true" hidden id="blockly-button">{{'BUTTON'|translate}}</label>
  37. <label aria-hidden="true" hidden id="blockly-more-options">{{'MORE_OPTIONS'|translate}}</label>
  38. <label aria-hidden="true" hidden id="blockly-toolbox-block">{{'TOOLBOX_BLOCK'|translate}}</label>
  39. <label aria-hidden="true" hidden id="blockly-workspace-block">{{'WORKSPACE_BLOCK'|translate}}</label>
  40. `,
  41. directives: [blocklyApp.ToolboxComponent, blocklyApp.WorkspaceComponent],
  42. pipes: [blocklyApp.TranslatePipe],
  43. // All services are declared here, so that all components in the
  44. // application use the same instance of the service.
  45. // https://www.sitepoint.com/angular-2-components-providers-classes-factories-values/
  46. providers: [
  47. blocklyApp.ClipboardService, blocklyApp.NotificationsService,
  48. blocklyApp.TreeService, blocklyApp.UtilsService,
  49. blocklyApp.AudioService]
  50. })
  51. .Class({
  52. constructor: [blocklyApp.NotificationsService, function(_notificationsService) {
  53. this.notificationsService = _notificationsService;
  54. }],
  55. getStatusMessage: function() {
  56. return this.notificationsService.getStatusMessage();
  57. }
  58. });