X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ftoolbar%2Fjs%2Fviews%2FToolbarAuralView.es6.js;fp=web%2Fcore%2Fmodules%2Ftoolbar%2Fjs%2Fviews%2FToolbarAuralView.es6.js;h=c7ae04d2bdbaec083232ecb22130a4888225a027;hp=c27b864f06dc8672c3b3a6f9c4b5e251dd684603;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/toolbar/js/views/ToolbarAuralView.es6.js b/web/core/modules/toolbar/js/views/ToolbarAuralView.es6.js index c27b864f0..c7ae04d2b 100644 --- a/web/core/modules/toolbar/js/views/ToolbarAuralView.es6.js +++ b/web/core/modules/toolbar/js/views/ToolbarAuralView.es6.js @@ -3,69 +3,79 @@ * A Backbone view for the aural feedback of the toolbar. */ -(function (Backbone, Drupal) { - Drupal.toolbar.ToolbarAuralView = Backbone.View.extend(/** @lends Drupal.toolbar.ToolbarAuralView# */{ +(function(Backbone, Drupal) { + 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 + * Options for the view. + * @param {object} options.strings + * Various strings to use in the view. + */ + initialize(options) { + this.strings = options.strings; - /** - * Backbone view for the aural feedback of the toolbar. - * - * @constructs - * - * @augments Backbone.View - * - * @param {object} options - * Options for the view. - * @param {object} options.strings - * Various strings to use in the view. - */ - initialize(options) { - this.strings = options.strings; + this.listenTo( + this.model, + 'change:orientation', + this.onOrientationChange, + ); + this.listenTo(this.model, 'change:activeTray', this.onActiveTrayChange); + }, - 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 - * The toolbar model in question. - * @param {string} orientation - * The new value of the orientation attribute in the model. - */ - onOrientationChange(model, orientation) { - Drupal.announce(Drupal.t('Tray orientation changed to @orientation.', { - '@orientation': orientation, - })); - }, + /** + * Announces an orientation change. + * + * @param {Drupal.toolbar.ToolbarModel} model + * The toolbar model in question. + * @param {string} orientation + * The new value of the orientation attribute in the model. + */ + onOrientationChange(model, orientation) { + Drupal.announce( + Drupal.t('Tray orientation changed to @orientation.', { + '@orientation': orientation, + }), + ); + }, - /** - * Announces a changed active tray. - * - * @param {Drupal.toolbar.ToolbarModel} model - * The toolbar model in question. - * @param {HTMLElement} tray - * The new value of the tray attribute in the model. - */ - onActiveTrayChange(model, tray) { - const relevantTray = (tray === null) ? model.previous('activeTray') : tray; - // Current activeTray and previous activeTray are empty, no state change - // to announce. - if (!relevantTray) { - return; - } - const action = (tray === null) ? Drupal.t('closed') : Drupal.t('opened'); - const trayNameElement = relevantTray.querySelector('.toolbar-tray-name'); - let 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); + /** + * Announces a changed active tray. + * + * @param {Drupal.toolbar.ToolbarModel} model + * The toolbar model in question. + * @param {HTMLElement} tray + * The new value of the tray attribute in the model. + */ + onActiveTrayChange(model, tray) { + const relevantTray = + tray === null ? model.previous('activeTray') : tray; + // Current activeTray and previous activeTray are empty, no state change + // to announce. + if (!relevantTray) { + return; + } + const action = tray === null ? Drupal.t('closed') : Drupal.t('opened'); + const trayNameElement = relevantTray.querySelector( + '.toolbar-tray-name', + ); + let 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)); + ); +})(Backbone, Drupal);