Created
May 12, 2016 14:38
-
-
Save johnny5th/e2e2ad61f58a32bbf6ab17a330d1e265 to your computer and use it in GitHub Desktop.
Drupal subnav dropdown click code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.menu-button').click(function() { | |
$('.nav-bar .menu-block-wrapper').toggleClass('open'); | |
}); | |
var deep_links = $('.nav-bar .menu-block-wrapper li.is-expanded'); | |
$('> a', deep_links).click(function() { | |
// Hide other open menus on desktop | |
if(isScreen("desktop")) { | |
$(this).parent().siblings().find('> a, ul').removeClass('activemenu'); | |
} | |
$(this).siblings('ul').toggleClass('activemenu'); | |
$(this).toggleClass('activemenu'); | |
return false; | |
}); | |
// Screen Helper | |
// Requires matchMedia | |
function isScreen(test_screen) { | |
var real_screen; | |
if(matchMedia('(max-width: 62.4375em)').matches) { | |
real_screen = "mobile"; | |
} else { | |
real_screen = "desktop"; | |
} | |
if(real_screen == test_screen) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment