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