Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / contextual / js / toolbar / views / AuralView.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, Drupal, Backbone, _) {
9   Drupal.contextualToolbar.AuralView = Backbone.View.extend({
10     announcedOnce: false,
11
12     initialize: function initialize(options) {
13       this.options = options;
14
15       this.listenTo(this.model, 'change', this.render);
16       this.listenTo(this.model, 'change:isViewing', this.manageTabbing);
17
18       $(document).on('keyup', _.bind(this.onKeypress, this));
19     },
20     render: function render() {
21       this.$el.find('button').attr('aria-pressed', !this.model.get('isViewing'));
22
23       return this;
24     },
25     manageTabbing: function manageTabbing() {
26       var tabbingContext = this.model.get('tabbingContext');
27
28       if (tabbingContext) {
29         if (tabbingContext.active) {
30           Drupal.announce(this.options.strings.tabbingReleased);
31         }
32         tabbingContext.release();
33       }
34
35       if (!this.model.get('isViewing')) {
36         tabbingContext = Drupal.tabbingManager.constrain($('.contextual-toolbar-tab, .contextual'));
37         this.model.set('tabbingContext', tabbingContext);
38         this.announceTabbingConstraint();
39         this.announcedOnce = true;
40       }
41     },
42     announceTabbingConstraint: function announceTabbingConstraint() {
43       var strings = this.options.strings;
44       Drupal.announce(Drupal.formatString(strings.tabbingConstrained, {
45         '@contextualsCount': Drupal.formatPlural(Drupal.contextual.collection.length, '@count contextual link', '@count contextual links')
46       }));
47       Drupal.announce(strings.pressEsc);
48     },
49     onKeypress: function onKeypress(event) {
50       if (!this.announcedOnce && event.keyCode === 9 && !this.model.get('isViewing')) {
51         this.announceTabbingConstraint();
52
53         this.announcedOnce = true;
54       }
55
56       if (event.keyCode === 27) {
57         this.model.set('isViewing', true);
58       }
59     }
60   });
61 })(jQuery, Drupal, Backbone, _);