1///////////////////////////////////////////////////////////////////////////////// 2// Start the Header Menu Adjustment (more, less) function 3var navItemWidths = []; 4 5function addjQValues($jq, getter) { 6 return Array.prototype.reduce.call( $jq, function (a, b) { 7 return a+ getter.call($(b)); 8 }, 0); 9} 10 11function adjustTopMenuLinks(target) { 12 13 //Create the target 14 var $target = target; 15 16 //check if more-menu exists and if in mobile-menu mode or desktop-menu mode 17 if ($($target + ' .more-menu-item').length > 0) { 18 19 if (window.innerWidth > 767) { 20 21 var $topnav = $($target + ' ul.navbar-nav'); 22 23 //if ($(window).width() <= lastWindowWidth) { 24 $($target).css('overflow','hidden'); 25 //check if nav has overflow of items (if width of items is greater than container width) 26 while(addjQValues($('> li:visible',$topnav),$.fn.width) > $($target).width()) { 27 28 //console.log("take items away") 29 30 //temporarily destroy menu 31 $($target + ' ul.navbar-nav').smartmenus('destroy'); 32 33 //make a copy of the deinitialized menu 34 var $topnav_copy = $($target + ' ul.navbar-nav').clone(); 35 36 //reinitialize menu 37 $.SmartMenus.Bootstrap.init(); 38 39 var $hideables = $('> li:not(.more-menu-ignore)', $topnav); 40 var $inserts = $('> li:not(.more-menu-ignore)', $topnav_copy); 41 42 //deinitialize last item, add it to more-menu, reinitialize smartmenu 43 $($target + ' .more-menu-item > .dropdown-menu').prepend($inserts.last()); 44 navItemWidths.unshift($hideables.last().width()); 45 $hideables.last().remove(); 46 $($target + ' ul.navbar-nav').smartmenus('destroy'); 47 $.SmartMenus.Bootstrap.init(); 48 $($target + ' .more-menu-item').css('display','block'); 49 } 50 //now that items fit menu, turn overflow to visible 51 $($target).css('overflow','visible'); 52 //} 53 //reverse process when increasing screen size 54 //else { 55 while($($target + ' .more-menu-item > .dropdown-menu > li').length > 0) { 56 57 58 59 //account for more-item-menu button width 60 var moreButtonWidth = 0; 61 if ($($target + ' .more-menu-item > .dropdown-menu > li').length === 1) { 62 moreButtonWidth = $($target + ' .more-menu-item').width(); 63 } 64 65 if ((addjQValues($('> li:visible', $topnav),$.fn.width) + navItemWidths[0] - moreButtonWidth) <= $($target).width()) { 66 //add item back to menu 67 //console.log("add items back") 68 69 //temporarily destroy menu 70 $($target + ' ul.navbar-nav').smartmenus('destroy'); 71 72 //make a copy of the deinitialized menu 73 var $topnav_deinit = $($target + ' ul.navbar-nav').clone(); 74 75 //reinitialize menu 76 $.SmartMenus.Bootstrap.init(); 77 78 var $removables = $('.more-menu-item > .dropdown-menu > li', $topnav); 79 var $putbacks = $('.more-menu-item > .dropdown-menu > li', $topnav_deinit); 80 81 //put first item back in top nav, remove from more menu, reinitialize smartmenu 82 if (moreButtonWidth > 0) { //putting back last one 83 $($target + ' .more-menu-item').css('display','none'); 84 } 85 $topnav.children('.more-menu-item').before($putbacks.first().clone()); 86 $putbacks.first().remove(); 87 navItemWidths.shift(); 88 $removables.first().remove(); 89 //reinitialize menu 90 $($target + ' ul.navbar-nav').smartmenus('destroy'); 91 $.SmartMenus.Bootstrap.init(); 92 } 93 else { 94 break; 95 } 96 } 97 //} 98 } 99 else { 100 if ($($target + ' .more-menu-item > .dropdown-menu > li').length > 0) { 101 $($target + ' ul.navbar-nav').smartmenus('destroy'); 102 103 $($target + ' .more-menu-item').before($($target + ' .more-menu-item > .dropdown-menu > li')); 104 $($target + ' .more-menu-item').css('display','none'); 105 $.SmartMenus.Bootstrap.init(); 106 } 107 } 108 } 109} 110 111// End the Header Menu Adjustment (more, less) function 112/////////////////////////////////////////////////////////////////////////////////
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.