Guide_Wii/assets/js/plugins/jquery.greedy-navigation.js
2018-10-01 13:20:23 +00:00

1 line
1.3 KiB
JavaScript

$(document).ready(function(){var e,n,s,d,i,o=$("nav.greedy-nav button.navsel"),a=$("nav.greedy-nav button.langsel"),l=$("nav.greedy-nav .visible-links"),t=$("nav.greedy-nav .hidden-links.links-menu"),c=$("nav.greedy-nav .hidden-links.lang-menu"),r=0,u=0,v=[];function h(){e=l.width()-10,n=l.children().length,s=v[n-1],e<s?(l.children().last().prependTo(t),n-=1,h()):e>v[n]&&(t.children().first().appendTo(l),n+=1,h()),o.attr("count",r-n),n===r?o.addClass("hidden"):o.removeClass("hidden")}l.children().outerWidth(function(e,n){u+=n,r+=1,v.push(u)}),$(window).resize(function(){h()}),o.on("click",function(){t.is(":visible")?(t.addClass("hidden"),$(this).removeClass("close")):(t.removeClass("hidden"),$(this).addClass("close"),c.addClass("hidden"),a.removeClass("close"),clearTimeout(i))}),t.on("mouseleave",function(){d=setTimeout(function(){t.addClass("hidden"),o.removeClass("close")},1e3)}).on("mouseenter",function(){clearTimeout(d)}),a.on("click",function(){c.is(":visible")?(c.addClass("hidden"),$(this).removeClass("close")):(c.removeClass("hidden"),$(this).addClass("close"),t.addClass("hidden"),o.removeClass("close"),clearTimeout(d))}),c.on("mouseleave",function(){i=setTimeout(function(){c.addClass("hidden"),a.removeClass("close")},1e3)}).on("mouseenter",function(){clearTimeout(i)}),h()});