Mercurial > hg > isophonics-drupal-site
diff core/modules/toolbar/js/views/ToolbarAuralView.js @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 129ea1e6d783 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/toolbar/js/views/ToolbarAuralView.js Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,40 @@ +/** +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ + +(function (Backbone, Drupal) { + Drupal.toolbar.ToolbarAuralView = Backbone.View.extend({ + initialize: function initialize(options) { + this.strings = options.strings; + + this.listenTo(this.model, 'change:orientation', this.onOrientationChange); + this.listenTo(this.model, 'change:activeTray', this.onActiveTrayChange); + }, + onOrientationChange: function onOrientationChange(model, orientation) { + Drupal.announce(Drupal.t('Tray orientation changed to @orientation.', { + '@orientation': orientation + })); + }, + onActiveTrayChange: function onActiveTrayChange(model, tray) { + var relevantTray = tray === null ? model.previous('activeTray') : tray; + + if (!relevantTray) { + return; + } + var action = tray === null ? Drupal.t('closed') : Drupal.t('opened'); + var trayNameElement = relevantTray.querySelector('.toolbar-tray-name'); + var text = void 0; + 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); \ No newline at end of file