Making WordPress.org

Changeset 4303


Ignore:
Timestamp:
10/28/2016 06:32:52 AM (7 years ago)
Author:
tellyworth
Message:

Plugin Directory Theme: don't show Read More links if the content is less than 125% of the available height.

See #1744

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/section-accordion.js

    r4223 r4303  
    1313            } );
    1414
    15             $( '.read-more:not(' + sectionId + ')' ).removeClass( 'toggled' ).attr( 'aria-expanded', false );
     15            $( '.read-more:not(' + sectionId + ',.short-content)' ).removeClass( 'toggled' ).attr( 'aria-expanded', false );
     16        },
     17        initial_size: function( selector ) {
     18            $( selector ).each( function( i, el) {
     19                if ( $(el).height() / el.scrollHeight > 0.8 ) {
     20                    // Force the section to expand, and hide its button
     21                    $(el).toggleClass( 'toggled' ).addClass('short-content').attr( 'aria-expanded', true );
     22                    $( '.section-toggle[aria-controls="' + el.id + '"]' ).hide();
     23                } else {
     24                    // Contract the section and make sure its button is visible
     25                    $(el).removeClass( 'short-content' ).attr( 'aria-expanded', false );
     26                    $( '.section-toggle[aria-controls="' + el.id + '"]' ).show();
     27                }
     28            } );
    1629        }
    1730    };
     
    2134            wporg.plugins.toggle( document.location.hash );
    2235        }
     36
     37        wporg.plugins.initial_size( '.read-more' );
    2338
    2439        $( window ).on( 'hashchange', function() {
Note: See TracChangeset for help on using the changeset viewer.