| 1 |
jQuery( function( $ ) { |
| 2 |
// Accordion handling in various areas. |
| 3 |
$( '.activitypub-settings-accordion' ).on( 'click', '.activitypub-settings-accordion-trigger', function() { |
| 4 |
var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) ); |
| 5 |
|
| 6 |
if ( isExpanded ) { |
| 7 |
$( this ).attr( 'aria-expanded', 'false' ); |
| 8 |
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', true ); |
| 9 |
} else { |
| 10 |
$( this ).attr( 'aria-expanded', 'true' ); |
| 11 |
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', false ); |
| 12 |
} |
| 13 |
} ); |
| 14 |
|
| 15 |
$(document).on( 'wp-plugin-install-success', function( event, response ) { |
| 16 |
setTimeout( function() { |
| 17 |
$( '.activate-now' ).removeClass( 'thickbox open-plugin-details-modal' ); |
| 18 |
}, 1200 ); |
| 19 |
} ); |
| 20 |
|
| 21 |
/* |
| 22 |
* Lazy-load embedded iframes (e.g. the Fediverse intro video) only once their |
| 23 |
* container becomes visible. Help tab panels are rendered hidden, and players |
| 24 |
* like PeerTube abort with an "invalid width" error when initialized inside a |
| 25 |
* zero-width container. Deferring the src until the panel is shown avoids that. |
| 26 |
*/ |
| 27 |
var lazyIframes = document.querySelectorAll( 'iframe[data-src]' ); |
| 28 |
|
| 29 |
if ( lazyIframes.length && 'IntersectionObserver' in window ) { |
| 30 |
var iframeObserver = new IntersectionObserver( function( entries, observer ) { |
| 31 |
entries.forEach( function( entry ) { |
| 32 |
if ( entry.isIntersecting ) { |
| 33 |
// Set once, then stop observing so it never reloads. |
| 34 |
entry.target.src = entry.target.dataset.src; |
| 35 |
observer.unobserve( entry.target ); |
| 36 |
} |
| 37 |
} ); |
| 38 |
} ); |
| 39 |
|
| 40 |
lazyIframes.forEach( function( iframe ) { |
| 41 |
iframeObserver.observe( iframe ); |
| 42 |
} ); |
| 43 |
} else { |
| 44 |
// IntersectionObserver unsupported: load immediately as a fallback. |
| 45 |
lazyIframes.forEach( function( iframe ) { |
| 46 |
iframe.src = iframe.dataset.src; |
| 47 |
} ); |
| 48 |
} |
| 49 |
} ); |
| 50 |
|