Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
66
core/modules/toolbar/js/views/ToolbarAuralView.js
Normal file
66
core/modules/toolbar/js/views/ToolbarAuralView.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* @file
|
||||
* A Backbone view for the aural feedback of the toolbar.
|
||||
*/
|
||||
|
||||
(function (Backbone, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
Drupal.toolbar.ToolbarAuralView = Backbone.View.extend(/** @lends Drupal.toolbar.ToolbarAuralView# */{
|
||||
|
||||
/**
|
||||
* Backbone view for the aural feedback of the toolbar.
|
||||
*
|
||||
* @constructs
|
||||
*
|
||||
* @augments Backbone.View
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {object} options.strings
|
||||
*/
|
||||
initialize: function (options) {
|
||||
this.strings = options.strings;
|
||||
|
||||
this.listenTo(this.model, 'change:orientation', this.onOrientationChange);
|
||||
this.listenTo(this.model, 'change:activeTray', this.onActiveTrayChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* Announces an orientation change.
|
||||
*
|
||||
* @param {Drupal.toolbar.ToolbarModel} model
|
||||
* @param {string} orientation
|
||||
* The new value of the orientation attribute in the model.
|
||||
*/
|
||||
onOrientationChange: function (model, orientation) {
|
||||
Drupal.announce(Drupal.t('Tray orientation changed to @orientation.', {
|
||||
'@orientation': orientation
|
||||
}));
|
||||
},
|
||||
|
||||
/**
|
||||
* Announces a changed active tray.
|
||||
*
|
||||
* @param {Drupal.toolbar.ToolbarModel} model
|
||||
* @param {HTMLElement} tray
|
||||
* The new value of the tray attribute in the model.
|
||||
*/
|
||||
onActiveTrayChange: function (model, tray) {
|
||||
var relevantTray = (tray === null) ? model.previous('activeTray') : tray;
|
||||
var action = (tray === null) ? Drupal.t('closed') : Drupal.t('opened');
|
||||
var trayNameElement = relevantTray.querySelector('.toolbar-tray-name');
|
||||
var text;
|
||||
if (trayNameElement !== null) {
|
||||
text = Drupal.t('Tray "@tray" @action.', {
|
||||
'@tray': trayNameElement.textContent, '@action': action
|
||||
});
|
||||
}
|
||||
else {
|
||||
text = Drupal.t('Tray @action.', {'@action': action});
|
||||
}
|
||||
Drupal.announce(text);
|
||||
}
|
||||
});
|
||||
|
||||
}(Backbone, Drupal));
|
Reference in a new issue