6096d4170fdb67c3ec515670111de9b6cf393f28
[yaffs-website] / web / core / modules / toolbar / js / views / ToolbarAuralView.js
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
8 (function (Backbone, Drupal) {
9   Drupal.toolbar.ToolbarAuralView = Backbone.View.extend({
10     initialize: function initialize(options) {
11       this.strings = options.strings;
12
13       this.listenTo(this.model, 'change:orientation', this.onOrientationChange);
14       this.listenTo(this.model, 'change:activeTray', this.onActiveTrayChange);
15     },
16     onOrientationChange: function onOrientationChange(model, orientation) {
17       Drupal.announce(Drupal.t('Tray orientation changed to @orientation.', {
18         '@orientation': orientation
19       }));
20     },
21     onActiveTrayChange: function onActiveTrayChange(model, tray) {
22       var relevantTray = tray === null ? model.previous('activeTray') : tray;
23
24       if (!relevantTray) {
25         return;
26       }
27       var action = tray === null ? Drupal.t('closed') : Drupal.t('opened');
28       var trayNameElement = relevantTray.querySelector('.toolbar-tray-name');
29       var text = void 0;
30       if (trayNameElement !== null) {
31         text = Drupal.t('Tray "@tray" @action.', {
32           '@tray': trayNameElement.textContent,
33           '@action': action
34         });
35       } else {
36         text = Drupal.t('Tray @action.', { '@action': action });
37       }
38       Drupal.announce(text);
39     }
40   });
41 })(Backbone, Drupal);