db backup prior to drupal security update
[yaffs-website] / web / core / modules / toolbar / js / views / ToolbarAuralView.js
1 /**
2  * @file
3  * A Backbone view for the aural feedback of the toolbar.
4  */
5
6 (function (Backbone, Drupal) {
7
8   'use strict';
9
10   Drupal.toolbar.ToolbarAuralView = Backbone.View.extend(/** @lends Drupal.toolbar.ToolbarAuralView# */{
11
12     /**
13      * Backbone view for the aural feedback of the toolbar.
14      *
15      * @constructs
16      *
17      * @augments Backbone.View
18      *
19      * @param {object} options
20      *   Options for the view.
21      * @param {object} options.strings
22      *   Various strings to use in the view.
23      */
24     initialize: function (options) {
25       this.strings = options.strings;
26
27       this.listenTo(this.model, 'change:orientation', this.onOrientationChange);
28       this.listenTo(this.model, 'change:activeTray', this.onActiveTrayChange);
29     },
30
31     /**
32      * Announces an orientation change.
33      *
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.
38      */
39     onOrientationChange: function (model, orientation) {
40       Drupal.announce(Drupal.t('Tray orientation changed to @orientation.', {
41         '@orientation': orientation
42       }));
43     },
44
45     /**
46      * Announces a changed active tray.
47      *
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.
52      */
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');
57       var text;
58       if (trayNameElement !== null) {
59         text = Drupal.t('Tray "@tray" @action.', {
60           '@tray': trayNameElement.textContent, '@action': action
61         });
62       }
63       else {
64         text = Drupal.t('Tray @action.', {'@action': action});
65       }
66       Drupal.announce(text);
67     }
68   });
69
70 }(Backbone, Drupal));