Skip to content

Instantly share code, notes, and snippets.

@madcatgith
Created November 9, 2016 12:01
Show Gist options
  • Save madcatgith/0e9fe16100552ae021573edf56ffac6c to your computer and use it in GitHub Desktop.
Save madcatgith/0e9fe16100552ae021573edf56ffac6c to your computer and use it in GitHub Desktop.
function init_dropdown_menu(parent_class,submenu_class,menu_container) {
$('.'+parent_class).hover(function(){
$(this).find($('.'+submenu_class)).show();
$('.'+menu_container).mouseleave(function(){
$('.'+submenu_class).hide();
});
$('.'+menu_container+' a:not(.'+parent_class+')').mouseenter(function(){
if($(this).parents('.'+submenu_class).length==0) {
$('.'+submenu_class).hide();
}
});
},function(){
});
}
/*
<nav class="b-main-nav">
<ul class="b-main-nav__list inline-list">
<li>
<a href="index.html">
<svg class="svg-icon-home">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-home"></use>
</svg>
</a>
</li>
{foreach $menuArray as $menu}
<li {if ($menu.child|@count neq 0)}class="with_sub"{/if}><a href="{$menu.href}" title="{$menu.title|escape}">{$menu.title}</a>
{if ($menu.child|@count neq 0)}
<ul class="submenu">
{foreach $menu.child as $child}
<li {if Menu::isActive($child.id)}class="active"{/if}>
<a href="{$child.href}" title="{$child.title|escape}">{$child.title}</a>
</li>
{/foreach}
</ul>
{/if}
</li>
{/foreach}
</ul>
</nav>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment