CoreFiles by mySites.guru
akismet-admin.js37 lines, 1,290 bytes, from wordpress-6.9.7.zip
Raw History Compare with 6.9.6
md5
452760c46839a6e3c5fa0c4761f2c1b9
sha1
aecd9ab8651e4916322f0904d6950bf51bcb26a5
sha256
7b127664961d13107844c03091bbe1dbf1f18fac0ad56091a2309e37f9668cd9
document.addEventListener( 'DOMContentLoaded', function() {
	// Prevent aggressive iframe caching in Firefox
	var statsIframe = document.getElementById( 'stats-iframe' );
	if ( statsIframe ) {
		statsIframe.contentWindow.location.href = statsIframe.src;
	}

	initCompatiblePluginsShowMoreToggle();
} );

function initCompatiblePluginsShowMoreToggle() {
  const section = document.querySelector( '.akismet-compatible-plugins' );
  const list = document.querySelector( '.akismet-compatible-plugins__list' );
  const button = document.querySelector( '.akismet-compatible-plugins__show-more' );

  if ( ! section || ! list || ! button ) {
  	return;
  }

  function isElementInViewport( element ) {
    const rect = element.getBoundingClientRect();
    return rect.top >= 0 && rect.bottom <= window.innerHeight;
  }

  function toggleCards() {
    list.classList.toggle( 'is-expanded' );
    const isExpanded = list.classList.contains( 'is-expanded' );
    button.textContent = isExpanded ? button.dataset.labelOpen : button.dataset.labelClosed;
    button.setAttribute( 'aria-expanded', isExpanded.toString() );
  
    if ( ! isExpanded && ! isElementInViewport( section ) ) {
      section.scrollIntoView( { block: 'start' } );
    }
  }

  button.addEventListener( 'click', toggleCards );
}

The same content is in 43 releases, WordPress 6.8.2-RC1 to 7.0-RC2. See them all, or every version of this file.