1function slideUp( target, duration ) { 2 target.style.transitionProperty = 'height, margin, padding'; 3 target.style.transitionDuration = duration + 'ms'; 4 target.style.boxSizing = 'border-box'; 5 target.style.height = target.offsetHeight + 'px'; 6 target.offsetHeight; // eslint-disable-line no-unused-expressions 7 target.style.overflow = 'hidden'; 8 target.style.height = 0; 9 target.style.paddingTop = 0; 10 target.style.paddingBottom = 0; 11 target.style.marginTop = 0; 12 target.style.marginBottom = 0; 13 window.setTimeout( function () { 14 target.style.display = 'none'; 15 target.style.removeProperty( 'height' ); 16 target.style.removeProperty( 'padding-top' ); 17 target.style.removeProperty( 'padding-bottom' ); 18 target.style.removeProperty( 'margin-top' ); 19 target.style.removeProperty( 'margin-bottom' ); 20 target.style.removeProperty( 'overflow' ); 21 target.style.removeProperty( 'transition-duration' ); 22 target.style.removeProperty( 'transition-property' ); 23 }, duration ); 24} 25 26function slideDown( target, duration ) { 27 target.style.removeProperty( 'display' ); 28 let display = window.getComputedStyle( target ).display; 29 30 if ( display === 'none' ) display = 'block'; 31 32 target.style.display = display; 33 const height = target.offsetHeight; 34 target.style.overflow = 'hidden'; 35 target.style.height = 0; 36 target.style.paddingTop = 0; 37 target.style.paddingBottom = 0; 38 target.style.marginTop = 0; 39 target.style.marginBottom = 0; 40 target.offsetHeight; // eslint-disable-line no-unused-expressions 41 target.style.boxSizing = 'border-box'; 42 target.style.transitionProperty = 'height, margin, padding'; 43 target.style.transitionDuration = duration + 'ms'; 44 target.style.height = height + 'px'; 45 target.style.removeProperty( 'padding-top' ); 46 target.style.removeProperty( 'padding-bottom' ); 47 target.style.removeProperty( 'margin-top' ); 48 target.style.removeProperty( 'margin-bottom' ); 49 window.setTimeout( function () { 50 target.style.removeProperty( 'height' ); 51 target.style.removeProperty( 'overflow' ); 52 target.style.removeProperty( 'transition-duration' ); 53 target.style.removeProperty( 'transition-property' ); 54 }, duration ); 55} 56 57function setupFAQ() { 58 const pattern = new RegExp( '^[\\w\\-]+$' ); 59 const hashval = window.location.hash.substring( 1 ); 60 const expandFirstelements = document.getElementsByClassName( 'uagb-faq-expand-first-true' ); 61 const inactiveOtherelements = document.getElementsByClassName( 'uagb-faq-inactive-other-false' ); 62 63 if ( 64 document.getElementById( hashval ) !== undefined && 65 document.getElementById( hashval ) !== null && 66 document.getElementById( hashval ) !== '' && 67 pattern.test( hashval ) 68 ) { 69 const elementToOpen = document.getElementById( hashval ); 70 71 if ( elementToOpen !== undefined ) { 72 elementToOpen.classList.add( 'uagb-faq-item-active' ); 73 elementToOpen.setAttribute( 'aria-expanded', true ); 74 const faqContent = elementToOpen.getElementsByClassName( 'uagb-faq-content' )[ 0 ]; 75 if ( faqContent ) { 76 slideDown( faqContent, 500 ); 77 } 78 } 79 } else { 80 for ( let item = 0; item < expandFirstelements.length; item++ ) { 81 if ( true === expandFirstelements[ item ].classList.contains( 'uagb-faq-layout-accordion' ) ) { 82 let faqItem = expandFirstelements[ item ].querySelectorAll( 83 '.uagb-faq-child__outer-wrap.uagb-faq-item' 84 )[ 0 ]; 85 86 if ( ! faqItem ) { 87 faqItem = expandFirstelements[ item ].querySelectorAll( 88 '.uagb-faq-child__outer-wrap .uagb-faq-item' 89 )[ 0 ]; 90 } 91 92 faqItem.classList.add( 'uagb-faq-item-active' ); 93 94 faqItem.setAttribute( 'aria-expanded', true ); 95 faqItem.querySelectorAll( '.uagb-faq-content' )[ 0 ].style.display = 'block'; 96 } 97 } 98 } 99 for ( let item = 0; item < inactiveOtherelements.length; item++ ) { 100 if ( true === inactiveOtherelements[ item ].classList.contains( 'uagb-faq-layout-accordion' ) ) { 101 let otherItems = inactiveOtherelements[ item ].querySelectorAll( 102 '.uagb-faq-child__outer-wrap.uagb-faq-item' 103 ); 104 105 if ( ! otherItems || 0 === otherItems.length ) { 106 otherItems = inactiveOtherelements[ item ].querySelectorAll( 107 '.uagb-faq-child__outer-wrap .uagb-faq-item' 108 ); 109 } 110 111 for ( let childItem = 0; childItem < otherItems.length; childItem++ ) { 112 otherItems[ childItem ].classList.add( 'uagb-faq-item-active' ); 113 otherItems[ childItem ].setAttribute( 'aria-expanded', true ); 114 otherItems[ childItem ].querySelectorAll( '.uagb-faq-content' )[ 0 ].style.display = 'block'; 115 } 116 } 117 } 118} 119 120window.addEventListener( 'load', function () { 121 setupFAQ(); 122 123 const accordionElements = document.getElementsByClassName( 'uagb-faq-layout-accordion' ); 124 for ( let item = 0; item < accordionElements.length; item++ ) { 125 const questionButtons = accordionElements[ item ].querySelectorAll( '.uagb-faq-questions-button' ); 126 const faqItems = accordionElements[ item ].querySelectorAll( '.uagb-faq-item' ); 127 128 for ( let button = 0; button < questionButtons.length; button++ ) { 129 questionButtons[ button ].addEventListener( 'click', function ( e ) { 130 faqClick( e, this.parentElement, questionButtons ); 131 } ); 132 } 133 134 for ( let button = 0; button < faqItems.length; button++ ) { 135 faqItems[ button ].addEventListener( 'keyup', function ( e ) { 136 faqClick( e, this, questionButtons ); 137 } ); 138 } 139 } 140} ); 141 142function faqClick( e, faqItem, questionButtons ) { 143 if ( e.keyCode === 13 || e.keyCode === 32 || e.button === 0 ) {
144 // enter || spacebar || left mouse click. 145 if ( faqItem.classList.contains( 'uagb-faq-item-active' ) ) { 146 faqItem.classList.remove( 'uagb-faq-item-active' ); 147 faqItem.setAttribute( 'aria-expanded', false ); 148 slideUp( faqItem.getElementsByClassName( 'uagb-faq-content' )[ 0 ], 500 ); 149 } else { 150 const parent = e.currentTarget.closest( '.wp-block-uagb-faq' ); 151 let faqToggle = 'true'; 152 if ( parent.classList.contains( 'wp-block-uagb-faq' ) ) { 153 faqToggle = parent.getAttribute( 'data-faqtoggle' ); 154 } 155 faqItem.classList.add( 'uagb-faq-item-active' ); 156 faqItem.setAttribute( 'aria-expanded', true ); 157 slideDown( faqItem.getElementsByClassName( 'uagb-faq-content' )[ 0 ], 500 ); 158 if ( 'true' === faqToggle ) { 159 questionButtons = parent.querySelectorAll( '.uagb-faq-content' ); 160 for ( let buttonChild = 0; buttonChild < questionButtons.length; buttonChild++ ) { 161 const buttonItem = questionButtons[ buttonChild ].parentElement; 162 if ( buttonItem === faqItem ) { 163 continue; 164 } 165 buttonItem.classList.remove( 'uagb-faq-item-active' ); 166 buttonItem.setAttribute( 'aria-expanded', false ); 167 slideUp( buttonItem.getElementsByClassName( 'uagb-faq-content' )[ 0 ], 500 ); 168 } 169 } 170 } 171 } 172}
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.