Move all files to 2017/
This commit is contained in:
parent
ac7370f67f
commit
2875863330
15717 changed files with 0 additions and 0 deletions
61
2017/web/core/misc/announce.js
Normal file
61
2017/web/core/misc/announce.js
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function (Drupal, debounce) {
|
||||
var liveElement = void 0;
|
||||
var announcements = [];
|
||||
|
||||
Drupal.behaviors.drupalAnnounce = {
|
||||
attach: function attach(context) {
|
||||
if (!liveElement) {
|
||||
liveElement = document.createElement('div');
|
||||
liveElement.id = 'drupal-live-announce';
|
||||
liveElement.className = 'visually-hidden';
|
||||
liveElement.setAttribute('aria-live', 'polite');
|
||||
liveElement.setAttribute('aria-busy', 'false');
|
||||
document.body.appendChild(liveElement);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function announce() {
|
||||
var text = [];
|
||||
var priority = 'polite';
|
||||
var announcement = void 0;
|
||||
|
||||
var il = announcements.length;
|
||||
for (var i = 0; i < il; i++) {
|
||||
announcement = announcements.pop();
|
||||
text.unshift(announcement.text);
|
||||
|
||||
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
|
||||
});
|
||||
|
||||
return debounce(announce, 200)();
|
||||
};
|
||||
})(Drupal, Drupal.debounce);
|
Reference in a new issue