ToolbarAuralView.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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, '@action': action
  30. });
  31. } else {
  32. text = Drupal.t('Tray @action.', { '@action': action });
  33. }
  34. Drupal.announce(text);
  35. }
  36. });
  37. })(Backbone, Drupal);