Changeset 4387
- Timestamp:
- 11/21/2016 03:23:52 AM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php
r4376 r4387 74 74 75 75 if ( is_singular( 'plugin' ) ) { 76 wp_enqueue_script( 'wporg-plugins-accordion', get_template_directory_uri() . '/js/section-accordion.js', array(), '2016 0525', true );76 wp_enqueue_script( 'wporg-plugins-accordion', get_template_directory_uri() . '/js/section-accordion.js', array(), '20161121', true ); 77 77 } 78 78 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/section-accordion.js
r4385 r4387 2 2 ( function( $, wporg ) { 3 3 wporg.plugins = { 4 toggle: function( sectionId ) { 5 $( sectionId ).toggleClass( 'toggled' ).attr( 'aria-expanded', function( index, attribute ) { 4 toggle: function( section ) { 5 var sectionId = '#' + section, 6 $section = $( sectionId ), 7 $button = $('button.section-toggle[aria-controls="' + section + '"]'); 8 9 $section.toggleClass( 'toggled' ).attr( 'aria-expanded', function( index, attribute ) { 6 10 var notExpanded = 'false' === attribute; 7 11 … … 14 18 15 19 $( '.read-more:not(' + sectionId + ',.short-content)' ).removeClass( 'toggled' ).attr( 'aria-expanded', false ); 20 21 $button.text( 22 $section.hasClass( 'toggled' ) ? 23 $button.data('show-less') : 24 $button.data('read-more') 25 ); 16 26 }, 17 27 initial_size: function( selector ) { 18 28 $( selector ).each( function( i, el) { 19 var $el = $(el); 29 var $el = $(el), 30 $section_toggle = $( '.section-toggle[aria-controls="' + el.id + '"]' ); 31 20 32 if ( $el.height() / el.scrollHeight > 0.8 || el.id == 'screenshots' ) { 21 33 // Force the section to expand, and hide its button 22 34 $el.toggleClass( 'toggled' ).addClass('short-content').attr( 'aria-expanded', true ); 23 $ ( '.section-toggle[aria-controls="' + el.id + '"]' ).hide();35 $section_toggle.hide(); 24 36 } else { 25 37 // If the description starts with an embed/video, set the min-height to include it. … … 34 46 // Contract the section and make sure its button is visible 35 47 $el.removeClass( 'short-content' ).attr( 'aria-expanded', false ); 36 $ ( '.section-toggle[aria-controls="' + el.id + '"]' ).show();48 $section_toggle.show(); 37 49 } 38 50 } ); … … 41 53 42 54 $( function() { 55 // Must always run first, else expand/contract buttons will get hidden incorrectly. 56 wporg.plugins.initial_size( '.read-more' ); 57 43 58 if ( document.location.hash ) { 44 wporg.plugins.toggle( document.location.hash );59 wporg.plugins.toggle( document.location.hash.substr(1) ); 45 60 } 46 61 47 wporg.plugins.initial_size( '.read-more' );48 49 62 $( window ).on( 'hashchange', function() { 50 wporg.plugins.toggle( document.location.hash );63 wporg.plugins.toggle( document.location.hash.substr(1) ); 51 64 } ); 52 65 53 66 $( '#main' ).on( 'click', '.section-toggle', function( event ) { 54 wporg.plugins.toggle( '#' +$( event.target ).attr( 'aria-controls' ) );67 wporg.plugins.toggle( $( event.target ).attr( 'aria-controls' ) ); 55 68 } ); 56 69 } ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section.php
r4223 r4387 15 15 <?php echo $section_content; ?> 16 16 </div> 17 <button type="button" class="button-link section-toggle" aria-controls="<?php echo esc_attr( $section_slug ); ?>"><?php _e( 'Read more', 'wporg-plugins' ); ?></button> 17 <button 18 type="button" 19 class="button-link section-toggle" 20 aria-controls="<?php echo esc_attr( $section_slug ); ?>" 21 data-show-less="<?php esc_attr_e( 'Show less', 'wporg-plugins' ); ?>" 22 data-read-more="<?php esc_attr_e( 'Read more', 'wporg-plugins' ); ?>" 23 ><?php _e( 'Read more', 'wporg-plugins' ); ?></button>
Note: See TracChangeset
for help on using the changeset viewer.