3 * A Backbone view for the aural feedback of the toolbar.
6 (function(Backbone, Drupal) {
7 Drupal.toolbar.ToolbarAuralView = Backbone.View.extend(
8 /** @lends Drupal.toolbar.ToolbarAuralView# */ {
10 * Backbone view for the aural feedback of the toolbar.
14 * @augments Backbone.View
16 * @param {object} options
17 * Options for the view.
18 * @param {object} options.strings
19 * Various strings to use in the view.
22 this.strings = options.strings;
27 this.onOrientationChange,
29 this.listenTo(this.model, 'change:activeTray', this.onActiveTrayChange);
33 * Announces an orientation change.
35 * @param {Drupal.toolbar.ToolbarModel} model
36 * The toolbar model in question.
37 * @param {string} orientation
38 * The new value of the orientation attribute in the model.
40 onOrientationChange(model, orientation) {
42 Drupal.t('Tray orientation changed to @orientation.', {
43 '@orientation': orientation,
49 * Announces a changed active tray.
51 * @param {Drupal.toolbar.ToolbarModel} model
52 * The toolbar model in question.
53 * @param {HTMLElement} tray
54 * The new value of the tray attribute in the model.
56 onActiveTrayChange(model, tray) {
58 tray === null ? model.previous('activeTray') : tray;
59 // Current activeTray and previous activeTray are empty, no state change
64 const action = tray === null ? Drupal.t('closed') : Drupal.t('opened');
65 const trayNameElement = relevantTray.querySelector(
69 if (trayNameElement !== null) {
70 text = Drupal.t('Tray "@tray" @action.', {
71 '@tray': trayNameElement.textContent,
75 text = Drupal.t('Tray @action.', { '@action': action });
77 Drupal.announce(text);