X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmisc%2Factive-link.js;fp=web%2Fcore%2Fmisc%2Factive-link.js;h=69651211fb50acd3cefd88109196f322d7adc20b;hp=9cf55b43444fdb90e45eca6a8868863e742adef1;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/misc/active-link.js b/web/core/misc/active-link.js index 9cf55b434..69651211f 100644 --- a/web/core/misc/active-link.js +++ b/web/core/misc/active-link.js @@ -1,60 +1,40 @@ /** - * @file - * Attaches behaviors for Drupal's active link marking. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (function (Drupal, drupalSettings) { - - 'use strict'; - - /** - * Append is-active class. - * - * The link is only active if its path corresponds to the current path, the - * language of the linked path is equal to the current language, and if the - * query parameters of the link equal those of the current request, since the - * same request with different query parameters may yield a different page - * (e.g. pagers, exposed View filters). - * - * Does not discriminate based on element type, so allows you to set the - * is-active class on any element: a, li… - * - * @type {Drupal~behavior} - */ Drupal.behaviors.activeLinks = { - attach: function (context) { - // Start by finding all potentially active links. + attach: function attach(context) { var path = drupalSettings.path; var queryString = JSON.stringify(path.currentQuery); - var querySelector = path.currentQuery ? "[data-drupal-link-query='" + queryString + "']" : ':not([data-drupal-link-query])'; + var querySelector = path.currentQuery ? '[data-drupal-link-query=\'' + queryString + '\']' : ':not([data-drupal-link-query])'; var originalSelectors = ['[data-drupal-link-system-path="' + path.currentPath + '"]']; - var selectors; + var selectors = void 0; - // If this is the front page, we have to check for the path as - // well. if (path.isFront) { originalSelectors.push('[data-drupal-link-system-path=""]'); } - // Add language filtering. - selectors = [].concat( - // Links without any hreflang attributes (most of them). - originalSelectors.map(function (selector) { return selector + ':not([hreflang])'; }), - // Links with hreflang equals to the current language. - originalSelectors.map(function (selector) { return selector + '[hreflang="' + path.currentLanguage + '"]'; }) - ); + selectors = [].concat(originalSelectors.map(function (selector) { + return selector + ':not([hreflang])'; + }), originalSelectors.map(function (selector) { + return selector + '[hreflang="' + path.currentLanguage + '"]'; + })); - // Add query string selector for pagers, exposed filters. - selectors = selectors.map(function (current) { return current + querySelector; }); + selectors = selectors.map(function (current) { + return current + querySelector; + }); - // Query the DOM. 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 (context, settings, trigger) { + detach: function detach(context, settings, trigger) { if (trigger === 'unload') { var activeLinks = context.querySelectorAll('[data-drupal-link-system-path].is-active'); var il = activeLinks.length; @@ -64,5 +44,4 @@ } } }; - -})(Drupal, drupalSettings); +})(Drupal, drupalSettings); \ No newline at end of file