Making WordPress.org

Changeset 4385


Ignore:
Timestamp:
11/21/2016 02:27:26 AM (7 years ago)
Author:
dd32
Message:

Plugin Directory: Expand the initial description to show the full contents of any embed/videos present in the first paragraph/div.
This fixes cases where descriptions start with a video, and caused the controls to be hidden below the fold.

Fixes #1789.

File:
1 edited

Legend:

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

    r4376 r4385  
    1717        initial_size: function( selector ) {
    1818            $( selector ).each( function( i, el) {
    19                 if ( $(el).height() / el.scrollHeight > 0.8 || el.id == 'screenshots' ) {
     19                var $el = $(el);
     20                if ( $el.height() / el.scrollHeight > 0.8 || el.id == 'screenshots' ) {
    2021                    // Force the section to expand, and hide its button
    21                     $(el).toggleClass( 'toggled' ).addClass('short-content').attr( 'aria-expanded', true );
     22                    $el.toggleClass( 'toggled' ).addClass('short-content').attr( 'aria-expanded', true );
    2223                    $( '.section-toggle[aria-controls="' + el.id + '"]' ).hide();
    2324                } else {
     25                    // If the description starts with an embed/video, set the min-height to include it.
     26                    if ( 'description' == el.id && $el.children().next('p,div').first().find('video,iframe') ) {
     27                        var height = $el.children().next('p,div').first().outerHeight(true) /* embed */ + $el.children().first().outerHeight(true) /* h2 */;
     28
     29                        if ( height > parseInt($el.css( 'max-height' )) ) {
     30                            $el.css( 'min-height', height + "px" );
     31                        }
     32                    }
     33
    2434                    // Contract the section and make sure its button is visible
    25                     $(el).removeClass( 'short-content' ).attr( 'aria-expanded', false );
     35                    $el.removeClass( 'short-content' ).attr( 'aria-expanded', false );
    2636                    $( '.section-toggle[aria-controls="' + el.id + '"]' ).show();
    2737                }
Note: See TracChangeset for help on using the changeset viewer.