1(function($){ 2 $(function () { 3 //select all collapsibles 4 const collapsibles = $('.imt-collapsible'); 5 6 //for each collapsible ensure it's defaulted to collapsed and that aria labels are initialized 7 collapsibles.each(function(){ 8 let collapsible = $(this); 9 let button = collapsible.children(":button"); 10 let expandable = button.next(); 11 let container = collapsible.parents('.imt-collapsible-container'); 12 let animationSpeed = container.attr('data-animation-speed'); 13 14 button.attr("aria-expanded", false); 15 expandable.attr("aria-hidden", true); 16 17 //double toggle the animation, this sets it to the correct state so that we can use toggle on click 18 expandable.animate({ 19 height: "toggle" 20 },0); 21 expandable.animate({ 22 height: "toggle" 23 },0); 24 25 //initialize the click function for the collapsible 26 button.click(function(){ 27 //check the current state of the collapsible 28 let expanded = button.attr("aria-expanded") === 'false' ? false : true; 29 30 let buttonId = $(this).attr('data-expandable'); 31 32 //if the container is set to have an accordion toggle off all other collapsibles 33 if(container.hasClass('imt-accordion')){ 34 let children = container.find('.imt-collapsible'); 35 children.each(function(){ 36 let child = $(this); 37 let childButton = child.children(":button"); 38 let childExpandable = childButton.next(); 39 let collapsibleId = childExpandable.attr("id"); 40 41 // close all, but if the clicked item was open, don't toggle twice 42 if (childExpandable.attr("aria-hidden") === "false" && (buttonId !== collapsibleId)) { 43 childExpandable.animate({ 44 height: "toggle" 45 },Number(animationSpeed)); 46 childExpandable.attr("aria-hidden", true); 47 } 48 49 childButton.attr("aria-expanded", false); 50 51 }); 52 } 53 54 let tabindex = !expanded ? 0 : -1; 55 56 //change the state of the collapsible clicked & toggle the height 57 button.attr("aria-expanded", !expanded); 58 expandable.attr("aria-hidden", expanded); 59 expandable.attr("tabindex", tabindex); 60 expandable.animate({ 61 height: "toggle" 62 },Number(animationSpeed)); 63 64 }); 65 }); 66 }); 67})(jQuery);
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.