Security update for Core, with self-updated composer
[yaffs-website] / web / core / misc / announce.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, debounce) {
9   var liveElement = void 0;
10   var announcements = [];
11
12   Drupal.behaviors.drupalAnnounce = {
13     attach: function attach(context) {
14       if (!liveElement) {
15         liveElement = document.createElement('div');
16         liveElement.id = 'drupal-live-announce';
17         liveElement.className = 'visually-hidden';
18         liveElement.setAttribute('aria-live', 'polite');
19         liveElement.setAttribute('aria-busy', 'false');
20         document.body.appendChild(liveElement);
21       }
22     }
23   };
24
25   function announce() {
26     var text = [];
27     var priority = 'polite';
28     var announcement = void 0;
29
30     var il = announcements.length;
31     for (var i = 0; i < il; i++) {
32       announcement = announcements.pop();
33       text.unshift(announcement.text);
34
35       if (announcement.priority === 'assertive') {
36         priority = 'assertive';
37       }
38     }
39
40     if (text.length) {
41       liveElement.innerHTML = '';
42
43       liveElement.setAttribute('aria-busy', 'true');
44
45       liveElement.setAttribute('aria-live', priority);
46
47       liveElement.innerHTML = text.join('\n');
48
49       liveElement.setAttribute('aria-busy', 'false');
50     }
51   }
52
53   Drupal.announce = function (text, priority) {
54     announcements.push({
55       text: text,
56       priority: priority
57     });
58
59     return debounce(announce, 200)();
60   };
61 })(Drupal, Drupal.debounce);