2013-04-20 03:43:48 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-08 14:04:39 +00:00
|
|
|
|
2013-04-20 03:43:48 +00:00
|
|
|
(function (Drupal, debounce) {
|
2020-01-30 09:08:38 +00:00
|
|
|
var liveElement;
|
2013-04-20 03:43:48 +00:00
|
|
|
var announcements = [];
|
|
|
|
Drupal.behaviors.drupalAnnounce = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
2013-04-20 03:43:48 +00:00
|
|
|
if (!liveElement) {
|
|
|
|
liveElement = document.createElement('div');
|
|
|
|
liveElement.id = 'drupal-live-announce';
|
2013-06-17 19:58:27 +00:00
|
|
|
liveElement.className = 'visually-hidden';
|
2013-04-20 03:43:48 +00:00
|
|
|
liveElement.setAttribute('aria-live', 'polite');
|
|
|
|
liveElement.setAttribute('aria-busy', 'false');
|
|
|
|
document.body.appendChild(liveElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
function announce() {
|
2013-04-20 03:43:48 +00:00
|
|
|
var text = [];
|
|
|
|
var priority = 'polite';
|
2020-01-30 09:08:38 +00:00
|
|
|
var announcement;
|
2020-01-28 13:12:54 +00:00
|
|
|
var il = announcements.length;
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2015-04-19 15:30:43 +00:00
|
|
|
for (var i = 0; i < il; i++) {
|
2013-04-20 03:43:48 +00:00
|
|
|
announcement = announcements.pop();
|
|
|
|
text.unshift(announcement.text);
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2013-04-20 03:43:48 +00:00
|
|
|
if (announcement.priority === 'assertive') {
|
|
|
|
priority = 'assertive';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (text.length) {
|
|
|
|
liveElement.innerHTML = '';
|
|
|
|
liveElement.setAttribute('aria-busy', 'true');
|
|
|
|
liveElement.setAttribute('aria-live', priority);
|
|
|
|
liveElement.innerHTML = text.join('\n');
|
|
|
|
liveElement.setAttribute('aria-busy', 'false');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Drupal.announce = function (text, priority) {
|
|
|
|
announcements.push({
|
|
|
|
text: text,
|
|
|
|
priority: priority
|
|
|
|
});
|
2017-05-19 22:12:53 +00:00
|
|
|
return debounce(announce, 200)();
|
2013-04-20 03:43:48 +00:00
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(Drupal, Drupal.debounce);
|