1jQuery(document).ready(function($){ 2 3 $(window).resize(function(){ 4 resetNav(); 5 updateNav(); 6 setNavWidth(); 7 }).resize(); 8 9 $('.hidden-count-wrap').on('click', function(e){ 10 e.preventDefault(); 11 return false; 12 }); 13 14 function resetNav(){ 15 // put all hidden links back in visible 16 $('.hidden-links > li').each(function(){ 17 $(this).insertBefore('.hidden-links-wrap'); 18 }); 19 } 20 21 function updateNav(){ 22 23 // reset link width 24 var linkwidth = 0; 25 $('.greedy-nav .visible-links > li').each(function(){ 26 linkwidth += $(this).width(); 27 }); 28 linkwidth += 10; 29 30 // The visible list is overflowing the nav 31 if(linkwidth > $('.greedy-nav').width()){ 32 33 // Move item to the hidden list 34 if($('.greedy-nav .visible-links > li').not('.hidden-links-wrap').length){ 35 $('.greedy-nav .visible-links > li').not('.hidden-links-wrap').last().prependTo($('.greedy-nav .hidden-links')); 36 } 37 38 // Show the dropdown btn 39 if($('.greedy-nav .hidden-links-wrap').hasClass('hidden')) { 40 $('.greedy-nav .hidden-links-wrap').removeClass('hidden'); 41 } 42 43 // The visible list is not overflowing 44 } else { 45 46 // Hide the dropdown btn if hidden list is empty 47 if($('.greedy-nav .hidden-links li').length < 1) { 48 $('.greedy-nav .hidden-links-wrap').addClass('hidden'); 49 } 50 } 51 52 // Keep counter updated 53 $('.greedy-nav .hidden-count').html($('.greedy-nav .hidden-links > li').length); 54 55 // Recur if the visible list is still overflowing the nav 56 if(linkwidth > $('.greedy-nav').width() && $('.greedy-nav .visible-links > li').not('.hidden-links-wrap').length){ 57 updateNav(); 58 } 59 } 60 61 function setNavWidth(){ 62 $('.main-nav .sub-menu').removeAttr('style'); 63 $('.main-nav > ul > li > .sub-menu').width($('.header-container').width()); 64 $('.main-nav .hidden-links > li > .sub-menu').width($('.header-container').width()); 65 } 66});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.