WordPress.org

Making WordPress.org

Changeset 3416


Ignore:
Timestamp:
06/17/2016 01:34:40 PM (5 years ago)
Author:
obenland
Message:

Plugin Directory: Be smarter about opening plugins sections.

Now opens sections on first load with hash in URL, when the hash changes,
and when the toggle is clicked.

See #1719.

File:
1 edited

Legend:

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

    r3415 r3416  
    11/* global _gaq */
    2 ( function( $ ) {
    3     $( function() {
    4         $( '#main' ).on( 'click', '.section-toggle', function( event ) {
    5             var sectionId = $( event.target ).attr( 'aria-controls' );
    6 
    7             $( '#' + sectionId ).toggleClass( 'toggled' ).attr( 'aria-expanded', function( index, attribute ) {
     2( function( $, wporg ) {
     3    wporg.plugins = {
     4        toggle: function( sectionId ) {
     5            $( sectionId ).toggleClass( 'toggled' ).attr( 'aria-expanded', function( index, attribute ) {
    86                var notExpanded = 'false' === attribute;
    97
     
    1513            } );
    1614
    17             $( '.read-more:not( #' + sectionId + ')' ).removeClass( 'toggled' ).attr( 'aria-expanded', false );
     15            $( '.read-more:not(' + sectionId + ')' ).removeClass( 'toggled' ).attr( 'aria-expanded', false );
     16        }
     17    };
     18
     19    $( function() {
     20        if ( document.location.hash ) {
     21            wporg.plugins.toggle( document.location.hash );
     22        }
     23
     24        $( window ).on( 'hashchange', function() {
     25            wporg.plugins.toggle( document.location.hash );
     26        } );
     27
     28        $( '#main' ).on( 'click', '.section-toggle', function( event ) {
     29            wporg.plugins.toggle( '#' + $( event.target ).attr( 'aria-controls' ) );
    1830        } );
    1931    } );
    20 } )( window.jQuery );
     32} )( window.jQuery, window.wporg || {} );
Note: See TracChangeset for help on using the changeset viewer.