ToolbarAuralView.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/2815083
  5. * @preserve
  6. **/
  7. (function (Backbone, Drupal) {
  8. Drupal.toolbar.ToolbarAuralView = Backbone.View.extend({
  9. initialize: function initialize(options) {
  10. this.strings = options.strings;
  11. this.listenTo(this.model, 'change:orientation', this.onOrientationChange);
  12. this.listenTo(this.model, 'change:activeTray', this.onActiveTrayChange);
  13. },
  14. onOrientationChange: function onOrientationChange(model, orientation) {
  15. Drupal.announce(Drupal.t('Tray orientation changed to @orientation.', {
  16. '@orientation': orientation
  17. }));
  18. },
  19. onActiveTrayChange: function onActiveTrayChange(model, tray) {
  20. var relevantTray = tray === null ? model.previous('activeTray') : tray;
  21. if (!relevantTray) {
  22. return;
  23. }
  24. var action = tray === null ? Drupal.t('closed') : Drupal.t('opened');
  25. var trayNameElement = relevantTray.querySelector('.toolbar-tray-name');
  26. var text = void 0;
  27. if (trayNameElement !== null) {
  28. text = Drupal.t('Tray "@tray" @action.', {
  29. '@tray': trayNameElement.textContent,
  30. '@action': action
  31. });
  32. } else {
  33. text = Drupal.t('Tray @action.', { '@action': action });
  34. }
  35. Drupal.announce(text);
  36. }
  37. });
  38. })(Backbone, Drupal);