[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-content/plugins/akismet/_inc/ -> akismet-admin.js (source)

   1  document.addEventListener( 'DOMContentLoaded', function() {
   2      // Prevent aggressive iframe caching in Firefox
   3      var statsIframe = document.getElementById( 'stats-iframe' );
   4      if ( statsIframe ) {
   5          statsIframe.contentWindow.location.href = statsIframe.src;
   6      }
   7  
   8      initCompatiblePluginsShowMoreToggle();
   9  } );
  10  
  11  function initCompatiblePluginsShowMoreToggle() {
  12    const section = document.querySelector( '.akismet-compatible-plugins' );
  13    const list = document.querySelector( '.akismet-compatible-plugins__list' );
  14    const button = document.querySelector( '.akismet-compatible-plugins__show-more' );
  15  
  16    if ( ! section || ! list || ! button ) {
  17        return;
  18    }
  19  
  20    function isElementInViewport( element ) {
  21      const rect = element.getBoundingClientRect();
  22      return rect.top >= 0 && rect.bottom <= window.innerHeight;
  23    }
  24  
  25    function toggleCards() {
  26      list.classList.toggle( 'is-expanded' );
  27      const isExpanded = list.classList.contains( 'is-expanded' );
  28      button.textContent = isExpanded ? button.dataset.labelOpen : button.dataset.labelClosed;
  29      button.setAttribute( 'aria-expanded', isExpanded.toString() );
  30    
  31      if ( ! isExpanded && ! isElementInViewport( section ) ) {
  32        section.scrollIntoView( { block: 'start' } );
  33      }
  34    }
  35  
  36    button.addEventListener( 'click', toggleCards );
  37  }


Generated : Sat Jun 14 08:20:01 2025 Cross-referenced by PHPXref