1jQuery( document ).ready(function( $ ) { 2 3 // The styling for this mobile menu is located in sass/components/mobile-menu/_mobile-menu.scss. 4 // Create mobile menu container, create mobile bar, and clone the main menu. 5 var $mobileNav = $('<nav class="mobile-nav" role="navigation"></nav>'), 6 $mobileBar = $('<div class="mobile-nav__bar"><a class="mobile-nav__button mobile-nav__button--home" href="/" rel="home"><span class="mobile-nav__icon mobile-nav__icon--home">Home</span></a><button class="mobile-nav__button js-mobile-menu-button mobile-nav__button--menu"><span class="mobile-nav__icon mobile-nav__icon--menu">Menu</span></button></div>'), 7 $mobileLinks = $('<div class="mobile-nav__links element-hidden"></div>'), 8 $mobileArrow = $('<span class="mobile-arrow"></span>'), 9 $mainMenu = $('.nav--primary ul').first().clone(), 10 $isSuperfish = ($mainMenu.hasClass('sf-menu')) ? true : false; 11 12 // Remove menu id, add class, and format subnav menus. 13 $('.nav--secondary > ul > li').each(function() { 14 $(this).clone().appendTo($mainMenu); 15 }); 16 17 $mainMenu.removeAttr('id').attr('class', 'nav nav--mobile').find('ul').each(function () { 18 var $parentLink = $(this).prev('a'); 19 20 // Copy parent link to subnav list. 21 $parentLink.clone().prependTo(this).wrap('<li class="nav__item"></li>'); 22 23 // Change parent link into a button and add classes. 24 $parentLink.replaceWith(function () { 25 return $('<button class="nav__link nav__link--parent js-mobile-menu-parent" />').append($(this).contents()); 26 }); 27 28 // Remove inline styles from Superfish. 29 if ($isSuperfish) { 30 $(this).removeAttr('style').addClass('nav--subnav').find('ul, li, a').removeAttr('style'); 31 } 32 }); 33 34 // set classes on superfish items 35 if ($isSuperfish) { 36 $mainMenu.find('li').each(function(){ 37 $(this).attr("class","nav__item").find('a').attr("class","nav__link"); 38 }); 39 } 40 41 // Remove third level menu items. 42 $mainMenu.find('ul ul').remove(); 43 44 // Insert the cloned menus into the mobile menu container. 45 $mainMenu.appendTo($mobileLinks); 46 47 // Insert the top bar into mobile menu container. 48 $mobileBar.prependTo($mobileNav); 49 50 // Insert the mobile links into mobile menu container. 51 $mobileLinks.appendTo($mobileNav); 52 53 // Add mobile menu to the page. 54 $('.skiplinks').after($mobileNav); 55 56 var $mobileMenuWrapper = $('.mobile-nav__links'), 57 $mobileMenuLinks = $mobileMenuWrapper.find('a'); 58 59 // Initially take mobile menu links out of tab flow. 60 $mobileMenuLinks.attr('tabindex', -1); 61 62 // Open/close mobile menu when menu button is clicked. 63 $('.js-mobile-menu-button').click(function (e) { 64 $(this).toggleClass('is-active'); 65 $mobileMenuWrapper.toggleClass('element-hidden'); 66 67 // Remove focus for mouse clicks after closing the menu. 68 $(this).not('.is-active').mouseleave(function () { 69 $(this).blur() 70 }); 71 72 // Take mobile menu links out of tab flow if hidden. 73 if ($mobileMenuWrapper.hasClass('element-hidden')) { 74 $mobileMenuLinks.attr('tabindex', -1); 75 } 76 else { 77 $mobileMenuLinks.removeAttr('tabindex'); 78 } 79 80 e.preventDefault(); 81 }); 82 83 // Open/close submenus. 84 $('.js-mobile-menu-parent').click(function (e) { 85 $(this).toggleClass('is-active').next('ul').slideToggle(); 86 87 // Remove focus for mouse clicks after closing the subnav. 88 $(this).not('.is-active').mouseleave(function () { 89 $(this).blur(); 90 }); 91 92 e.preventDefault(); 93 }); 94 95 // Set the height of the menu. 96 $mobileMenuWrapper.height($(document).height()); 97 98 99});
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.