3 * A Backbone view for the aural feedback of the toolbar.
6 (function (Backbone, Drupal) {
10 Drupal.toolbar.ToolbarAuralView = Backbone.View.extend(/** @lends Drupal.toolbar.ToolbarAuralView# */{
13 * Backbone view for the aural feedback of the toolbar.
17 * @augments Backbone.View
19 * @param {object} options
20 * Options for the view.
21 * @param {object} options.strings
22 * Various strings to use in the view.
24 initialize: function (options) {
25 this.strings = options.strings;
27 this.listenTo(this.model, 'change:orientation', this.onOrientationChange);
28 this.listenTo(this.model, 'change:activeTray', this.onActiveTrayChange);
32 * Announces an orientation change.
34 * @param {Drupal.toolbar.ToolbarModel} model
35 * The toolbar model in question.
36 * @param {string} orientation
37 * The new value of the orientation attribute in the model.
39 onOrientationChange: function (model, orientation) {
40 Drupal.announce(Drupal.t('Tray orientation changed to @orientation.', {
41 '@orientation': orientation
46 * Announces a changed active tray.
48 * @param {Drupal.toolbar.ToolbarModel} model
49 * The toolbar model in question.
50 * @param {HTMLElement} tray
51 * The new value of the tray attribute in the model.
53 onActiveTrayChange: function (model, tray) {
54 var relevantTray = (tray === null) ? model.previous('activeTray') : tray;
55 var action = (tray === null) ? Drupal.t('closed') : Drupal.t('opened');
56 var trayNameElement = relevantTray.querySelector('.toolbar-tray-name');
58 if (trayNameElement !== null) {
59 text = Drupal.t('Tray "@tray" @action.', {
60 '@tray': trayNameElement.textContent, '@action': action
64 text = Drupal.t('Tray @action.', {'@action': action});
66 Drupal.announce(text);