1jQuery(document).ready(function() { 2 if ( jQuery("#menu") != undefined) { 3 var api = jQuery("#menu").data( "mmenu" ); 4 5 // Open / close mmenu by clicking button 6 jQuery('.mmenu-toggler').each(function(){ 7 var link = jQuery(this); 8 9 link.click(function(){ 10 var el = jQuery(this); 11 12 if (el.attr('aria-expanded') === "false") { 13 if (jQuery("#mmenu-button-close").length === 0) { 14 jQuery('<button class="sr-only" id="mmenu-button-close">'+'Sulje\x20valikko'+'</button>').insertBefore('.mm-tabend') 15 } 16 17 if(link.hasClass("mobile-search-focus")){ 18 setTimeout(function(){ 19 jQuery('#mobile-search-field').focus(); 20 }, 500); 21 } else { 22 setTimeout(function(){ 23 jQuery("#top-of-menu").focus(); 24 }, 500); 25 } 26 api.open(); 27 28 api.bind("open:start", function() { 29 jQuery('.mmenu-title-toggler').text('Sulje\x20valikko') 30 el.attr('aria-expanded', 'true'); 31 }) 32 33 api.bind("open:finish", function(){ 34 jQuery("#mmenu-button-close").click(function(){ 35 api.close(); 36 el.attr('aria-expanded', 'false'); 37 el.focus(); 38 jQuery('.mmenu-title-toggler').text('Avaa\x20valikko') 39 }); 40 }) 41 } else { 42 api.close(); 43 jQuery('.mmenu-toggler').each(function(){ 44 jQuery(this).attr('aria-expanded', 'false') 45 }) 46 } 47 }); 48 }); 49 50 51 // Move focus to start of panel when opened 52 api.bind("panelOpened",function() { 53 jQuery("#top-of-menu").focus(); 54 }); 55 56 // Close by clicking MMenu default close button 57 jQuery('.close-mm-menu').click(function(){ 58 api.close(); 59 }) 60 61 jQuery("#menu").attr("role", "menu"); 62 // Close by clicking close menu button on panel 63 jQuery("#menu").on('click', '#menu-button-close', function() { 64 api.close(); 65 jQuery('.mmenu-toggler').each(function(){ 66 jQuery(this).attr('aria-expanded', 'false') 67 }) 68 jQuery('.mmenu-title-toggler').text('Avaa\x20valikko') 69 }); 70 71 api.bind( "close:finish", function( $panel ) { 72 jQuery(".menu-icon").get(0).focus(); 73 jQuery('.mmenu-title-toggler').text('Avaa\x20valikko') 74 jQuery('.mmenu-toggler').each(function(){ 75 jQuery(this).attr('aria-expanded', 'false') 76 }) 77 }); 78 79 jQuery('.mobile-search-focus').on('click', function(){ 80 api.bind( 'closeAllPanels', function() {}); 81 api.closeAllPanels(); 82 }); 83 84 jQuery("a.mm-listitem__text").attr("role", "menuitem"); 85 jQuery("a.mm-btn.mm-btn_prev.mm-navbar__btn").attr("role", "menuitem"); 86 jQuery("a.mm-btn.mm-btn_next.mm-listitem__btn").attr("role", "menuitem"); 87 jQuery('.mm-listitem.selected > a:not(".mm-listitem__btn")').attr('aria-current', 'page'); 88 89 // Append name of menu being opened or closed to each mobile arrow element 90 mobileArrowElements = jQuery('.mm-menu a.mm-btn'); 91 mobileArrowElements.each(function() { 92 if (jQuery(this).hasClass('mm-btn_next')) { 93 listItemText = jQuery(this).siblings('a.mm-listitem__text').text(); 94 currentSpan = jQuery(this).find('.mm-sronly'); 95 currentSpan.text(currentSpan.text() + ' ' + listItemText); 96 } else if (jQuery(this).hasClass('mm-btn_prev')) { 97 var href = $(this).attr('href'); 98 listItemText = jQuery(this.parentNode.parentNode).siblings(href).find('a.mm-navbar__title').text(); 99 currentSpan = jQuery(this).find('.mm-sronly'); 100 currentSpan.text('Takaisin' + ' ' + listItemText + ' ' + (listItemText ? 'valikkoon' : 'päävalikkoon')); 101 } 102 }); 103 104 /* Set class based on what mobile-menu-opening-button is clicked */ 105 jQuery('.mobile-search-focus.mmenu-toggler').on('click', function(){ 106 jQuery('#mobile-search-field').addClass('mobile-search-activation'); 107 }); 108 jQuery('.menu-icon.mmenu-toggler').on('click', function(){ 109 jQuery('#menu').addClass('mobile-menu-activation'); 110 }); 111 112 /* Use class information to focus wanted element */ 113 api.bind("open:finish", function(){ 114 if (jQuery('#mobile-search-field').hasClass('mobile-search-activation')) { 115 jQuery('#mobile-search-field').focus(); 116 } 117 if (jQuery('#menu').hasClass('mobile-menu-activation')) { 118 jQuery("#menu").find('.mm-panels > .mm-panel:first-child > .mm-listview > li:first-child > a').focus(); 119 } 120 121 /* Remove classes after use */ 122 jQuery('#mobile-search-field').removeClass('mobile-search-activation'); 123 jQuery('#menu').removeClass('mobile-menu-activation'); 124 }) 125 126 /* Focus current page -element when opening new panel */ 127 api.bind('openPanel:finish', function( panel ){ 128 jQuery(panel).find('.mm-navbar__title').focus(); 129 }); 130 } 131});
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.