2014-01-23 18:04:41 +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
|
|
|
|
**/
|
2014-01-23 18:04:41 +00:00
|
|
|
|
|
|
|
(function (Drupal, drupalSettings) {
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.activeLinks = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context) {
|
|
|
|
const path = drupalSettings.path;
|
|
|
|
const queryString = JSON.stringify(path.currentQuery);
|
|
|
|
const querySelector = path.currentQuery ? `[data-drupal-link-query='${queryString}']` : ':not([data-drupal-link-query])';
|
|
|
|
const originalSelectors = [`[data-drupal-link-system-path="${path.currentPath}"]`];
|
|
|
|
let selectors;
|
2014-01-27 21:41:32 +00:00
|
|
|
|
|
|
|
if (path.isFront) {
|
|
|
|
originalSelectors.push('[data-drupal-link-system-path="<front>"]');
|
|
|
|
}
|
2014-01-23 18:04:41 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
selectors = [].concat(originalSelectors.map(selector => `${selector}:not([hreflang])`), originalSelectors.map(selector => `${selector}[hreflang="${path.currentLanguage}"]`));
|
|
|
|
selectors = selectors.map(current => current + querySelector);
|
|
|
|
const activeLinks = context.querySelectorAll(selectors.join(','));
|
|
|
|
const il = activeLinks.length;
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
for (let i = 0; i < il; i++) {
|
Issue #2031641 by aburrows, lauriii, nlisgo, Pol, redsquid, tuutti, LewisNyman, akalata, agviu, kallehauge, _nolocation, rpayanm, saki007ster, mdrummond, RavindraSingh, brahmjeet789: Change active class to is-active
2015-04-16 14:25:55 +00:00
|
|
|
activeLinks[i].classList.add('is-active');
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
|
|
|
},
|
2021-12-18 06:12:16 +00:00
|
|
|
|
|
|
|
detach(context, settings, trigger) {
|
2014-01-27 21:41:32 +00:00
|
|
|
if (trigger === 'unload') {
|
2021-12-18 06:12:16 +00:00
|
|
|
const activeLinks = context.querySelectorAll('[data-drupal-link-system-path].is-active');
|
|
|
|
const il = activeLinks.length;
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
for (let i = 0; i < il; i++) {
|
Issue #2031641 by aburrows, lauriii, nlisgo, Pol, redsquid, tuutti, LewisNyman, akalata, agviu, kallehauge, _nolocation, rpayanm, saki007ster, mdrummond, RavindraSingh, brahmjeet789: Change active class to is-active
2015-04-16 14:25:55 +00:00
|
|
|
activeLinks[i].classList.remove('is-active');
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2014-01-23 18:04:41 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(Drupal, drupalSettings);
|