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 , drupalSettings ) {
Drupal . behaviors . activeLinks = {
2018-11-23 12:29:20 +00:00
attach : function attach ( context ) {
2015-08-17 17:00:26 -07:00
var path = drupalSettings . path ;
var queryString = JSON . stringify ( path . currentQuery ) ;
2018-11-23 12:29:20 +00:00
var querySelector = path . currentQuery ? '[data-drupal-link-query=\'' + queryString + '\']' : ':not([data-drupal-link-query])' ;
2015-08-17 17:00:26 -07:00
var originalSelectors = [ '[data-drupal-link-system-path="' + path . currentPath + '"]' ] ;
2018-11-23 12:29:20 +00:00
var selectors = void 0 ;
2015-08-17 17:00:26 -07:00
if ( path . isFront ) {
originalSelectors . push ( '[data-drupal-link-system-path="<front>"]' ) ;
}
2018-11-23 12:29:20 +00:00
selectors = [ ] . concat ( originalSelectors . map ( function ( selector ) {
return selector + ':not([hreflang])' ;
} ) , originalSelectors . map ( function ( selector ) {
return selector + '[hreflang="' + path . currentLanguage + '"]' ;
} ) ) ;
2015-08-17 17:00:26 -07:00
2018-11-23 12:29:20 +00:00
selectors = selectors . map ( function ( current ) {
return current + querySelector ;
} ) ;
2015-08-17 17:00:26 -07:00
var activeLinks = context . querySelectorAll ( selectors . join ( ',' ) ) ;
var il = activeLinks . length ;
for ( var i = 0 ; i < il ; i ++ ) {
activeLinks [ i ] . classList . add ( 'is-active' ) ;
}
} ,
2018-11-23 12:29:20 +00:00
detach : function detach ( context , settings , trigger ) {
2015-08-17 17:00:26 -07:00
if ( trigger === 'unload' ) {
var activeLinks = context . querySelectorAll ( '[data-drupal-link-system-path].is-active' ) ;
var il = activeLinks . length ;
for ( var i = 0 ; i < il ; i ++ ) {
activeLinks [ i ] . classList . remove ( 'is-active' ) ;
}
}
}
} ;
2018-11-23 12:29:20 +00:00
} ) ( Drupal , drupalSettings ) ;