1(function(document, window, undefined) { 2 "use strict"; 3 4 // Buttons 5 var buttons = document.querySelectorAll(".js-button"); 6 7 var links = document.querySelectorAll(".show-hide-link"); 8 9 10 11 var displayContent = function(button, content) { 12 if (content.classList.contains("active")) { 13 // Hide content 14 content.classList.remove("active"); 15 button.setAttribute("aria-expanded", "false"); 16 content.setAttribute("aria-hidden", "true"); 17 } else { 18 // Show content 19 content.classList.add("active"); 20 button.setAttribute("aria-expanded", "true"); 21 content.setAttribute("aria-hidden", "false"); 22 } 23 }; 24 25 [].forEach.call(buttons, function(button, index) { 26 // Content var 27 var content = button.nextElementSibling; 28 29 // Set button attributes 30 button.setAttribute("id", "button-" + index); 31 button.setAttribute("aria-expanded", "false"); 32 button.setAttribute("aria-controls", "content-" + index); 33 34 // Set content attributes 35 content.setAttribute("id", "content-" + index); 36 content.setAttribute("aria-hidden", "true"); 37 content.setAttribute("aria-labelledby", "button-" + index); 38 39 function hideit(){ 40 content.classList.remove("active"); 41 button.setAttribute("aria-expanded", "false"); 42 content.setAttribute("aria-hidden", "true"); 43 } 44 45 // SHOW THE MENU 46 button.addEventListener( 47 "click", 48 function() { 49 displayContent(this, content); 50 return false; 51 52 }, 53 false 54 ); 55 56 for (var i = 0 ; i < links.length; i++) { 57 links[i].addEventListener('click' , hideit, false ) ; 58 } 59 60 // links.addEventListener( 61 // "click", 62 // function() { 63 // content.classList.remove("active"); 64 // button.setAttribute("aria-expanded", "false"); 65 // content.setAttribute("aria-hidden", "true"); 66 // return false; 67 // 68 // }, 69 // false 70 // ); 71 72 // also close on link click 73 74// $( ".link-menu-content.active a" ).click(function() { 75// function() { 76// alert('hey'); 77// } 78// }); 79 80 81 button.addEventListener( 82 "keydown", 83 function(event) { 84 // Handle 'space' key 85 if (event.which === 32) { 86 event.preventDefault(); 87 displayContent(this, content); 88 } 89 }, 90 false 91 ); 92 }); 93})(document, window);
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.