Skip to content

Commit

Permalink
Fix active menu varnish cache
Browse files Browse the repository at this point in the history
  • Loading branch information
magiccart committed Jul 12, 2021
1 parent c89817c commit aa344b7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions view/frontend/web/js/magicmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,18 @@ require(['jquery', 'easing'], function($, easing){
},

active: function (menu) {
var homeUrl = menu.find('li.home a').attr('href').replace(/\/$/, "");
var currentUrl = window.location.href.replace(/\/$/, "");
menu.find('li a').each(function(){
var thisHref = ($(this).attr('href').split('?'))[0];
if(currentUrl.indexOf(thisHref) == 0) {
$(this).closest('li').addClass('active');
}
});
if(homeUrl == currentUrl){
menu.find('li.home').addClass('active');
} else {
menu.find("li:not('.home') a").each(function(){
var thisHref = ($(this).attr('href').split('?'))[0];
if(currentUrl.indexOf(thisHref) == 0) {
$(this).closest('li').addClass('active');
}
});
}
},

megamenu: function (menu) {
Expand Down

0 comments on commit aa344b7

Please sign in to comment.