2015-08-17 17:00:26 -07:00
/ * *
2018-11-23 12:29:20 +00:00
* DO NOT EDIT THIS FILE .
* See the following change record for more information ,
* https : //www.drupal.org/node/2815083
* @ preserve
* * /
2015-08-17 17:00:26 -07:00
( function ( Drupal , debounce ) {
2018-11-23 12:29:20 +00:00
var liveElement = void 0 ;
2015-08-17 17:00:26 -07:00
var announcements = [ ] ;
Drupal . behaviors . drupalAnnounce = {
2018-11-23 12:29:20 +00:00
attach : function attach ( context ) {
2015-08-17 17:00:26 -07:00
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' ;
2018-11-23 12:29:20 +00:00
var announcement = void 0 ;
2015-08-17 17:00:26 -07:00
var il = announcements . length ;
for ( var i = 0 ; i < il ; i ++ ) {
announcement = announcements . pop ( ) ;
text . unshift ( announcement . text ) ;
2018-11-23 12:29:20 +00:00
2015-08-17 17:00:26 -07:00
if ( announcement . priority === 'assertive' ) {
priority = 'assertive' ;
}
}
if ( text . length ) {
liveElement . innerHTML = '' ;
2018-11-23 12:29:20 +00:00
2015-08-17 17:00:26 -07:00
liveElement . setAttribute ( 'aria-busy' , 'true' ) ;
2018-11-23 12:29:20 +00:00
2015-08-17 17:00:26 -07:00
liveElement . setAttribute ( 'aria-live' , priority ) ;
2018-11-23 12:29:20 +00:00
2015-08-17 17:00:26 -07:00
liveElement . innerHTML = text . join ( '\n' ) ;
2018-11-23 12:29:20 +00:00
2015-08-17 17:00:26 -07:00
liveElement . setAttribute ( 'aria-busy' , 'false' ) ;
}
}
Drupal . announce = function ( text , priority ) {
announcements . push ( {
text : text ,
priority : priority
} ) ;
2018-11-23 12:29:20 +00:00
return debounce ( announce , 200 ) ( ) ;
2015-08-17 17:00:26 -07:00
} ;
2018-11-23 12:29:20 +00:00
} ) ( Drupal , Drupal . debounce ) ;