47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
/**
|
|
* DO NOT EDIT THIS FILE.
|
|
* See the following change record for more information,
|
|
* https://www.drupal.org/node/2815083
|
|
* @preserve
|
|
**/
|
|
|
|
(function (Drupal, drupalSettings) {
|
|
Drupal.behaviors.activeLinks = {
|
|
attach: function attach(context) {
|
|
var path = drupalSettings.path;
|
|
var queryString = JSON.stringify(path.currentQuery);
|
|
var querySelector = path.currentQuery ? "[data-drupal-link-query='".concat(queryString, "']") : ':not([data-drupal-link-query])';
|
|
var originalSelectors = ["[data-drupal-link-system-path=\"".concat(path.currentPath, "\"]")];
|
|
var selectors;
|
|
|
|
if (path.isFront) {
|
|
originalSelectors.push('[data-drupal-link-system-path="<front>"]');
|
|
}
|
|
|
|
selectors = [].concat(originalSelectors.map(function (selector) {
|
|
return "".concat(selector, ":not([hreflang])");
|
|
}), originalSelectors.map(function (selector) {
|
|
return "".concat(selector, "[hreflang=\"").concat(path.currentLanguage, "\"]");
|
|
}));
|
|
selectors = selectors.map(function (current) {
|
|
return current + querySelector;
|
|
});
|
|
var activeLinks = context.querySelectorAll(selectors.join(','));
|
|
var il = activeLinks.length;
|
|
|
|
for (var i = 0; i < il; i++) {
|
|
activeLinks[i].classList.add('is-active');
|
|
}
|
|
},
|
|
detach: function detach(context, settings, trigger) {
|
|
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');
|
|
}
|
|
}
|
|
}
|
|
};
|
|
})(Drupal, drupalSettings); |