From 919fc1f4f728d37abf31b0ef2e55442ab0f8bcdf Mon Sep 17 00:00:00 2001 From: Konstantinos Platis <konstantinos.platis@cern.ch> Date: Thu, 25 Apr 2019 07:12:31 +0000 Subject: [PATCH] Fixes issue with active trail in the 2nd level of menu --- patterns/molecules/menu/js/menu.component.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/patterns/molecules/menu/js/menu.component.js b/patterns/molecules/menu/js/menu.component.js index 4d44d688..dab2931c 100644 --- a/patterns/molecules/menu/js/menu.component.js +++ b/patterns/molecules/menu/js/menu.component.js @@ -103,17 +103,20 @@ if (("/"+currentlang) == previous_path) { break; } - matched_links = $('li.cern-dropdown').find('a[href^="'+ previous_path +'"]'); - if ((matched_links.length > 1 && current_search != '') || matched_links.length == 1) { + + matched_links = jQuery('li.cern-dropdown').find('a[href^="'+ previous_path +'"]'); + if ((matched_links.length > 1 && current_search != '') || matched_links.length == 1) { + jQuery('li.cern-dropdown').find('a[href^="'+ previous_path + current_search + '"]').closest('.cern-submenu').find('.cernmenu-level-0 a').addClass('active-trail'); + jQuery('li.cern-dropdown').find('a[href^="'+ previous_path + current_search + '"]').addClass('active-trail'); break; + } else { + if (i==0) { + matched_links.closest('.cern-submenu').find('.cernmenu-level-0 a').addClass('active-trail'); + } } - current_path.pop(); + current_path.pop(); } - - /*if (matched_links.length > 1 && current_search != '') { - var matched_links = $('li.cern-dropdown').find('a[href^="'+ previous_path + current_search +'"]'); - }*/ - + if (matched_links.length == 1) { // make a row children link active matched_links.eq(0).addClass('active-trail'); @@ -124,7 +127,6 @@ matched_links.eq(0).closest('.cern-dropdown').find('a.dropdown-toggle').eq(0).addClass('active-trail'); } } - /** END ACTIVE TRAIL */ })(jQuery, Drupal); -- GitLab