WordPress.org

Making WordPress.org

Changeset 9427


Ignore:
Timestamp:
01/28/2020 12:09:14 AM (15 months ago)
Author:
coffee2code
Message:

Breathe theme: Add ability for second-level handbook sidebar menu items with sub-items to be collapsible/expandable.

Nested menu items are all initially collapsed.

Syncs with change implemented in DevHub almost 8 months ago.

Props welcher.
See #4476.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/js/chapters.js

    r5875 r9427  
    11// Mobile Subnav open/close
    2 jQuery(document).ready(function() {
     2jQuery( document ).ready( function () {
     3
     4    var tocContainer = jQuery( 'div[class*="-table-of-contents-container"]' ).first();
     5
     6    if ( 0 === tocContainer.length ) {
     7        return;
     8    }
    39
    410    // Add our expandable button
    5     jQuery( '.menu-table-of-contents-container > ul > .menu-item-has-children > a' )
     11    tocContainer.find( '> ul .menu-item-has-children > a' )
    612        .wrap( '<div class="expandable"></div>' )
    713        .after( '<button class="dashicons dashicons-arrow-down-alt2" aria-expanded="false"></button>' );
    814
    9     // Invisibly open all of the submenus
    10     jQuery( '.menu-item-has-children > ul ul' ).addClass( 'default-open' );
     15    // Invisibly hide all of the submenus
     16    jQuery( '.menu-item-has-children > ul ul' ).hide();
    1117
    1218    // Open the current menu
    13     jQuery( '.menu-table-of-contents-container .current-menu-item a' ).first()
     19    tocContainer.find( '.current-menu-item a' ).first()
    1420        .addClass( 'active' )
    1521        .parents( '.menu-item-has-children' )
    16             .toggleClass( 'open' )
     22        .toggleClass( 'open' )
    1723        .find( '> div > .dashicons' )
    18             .attr( 'aria-expanded', true );
     24        .attr( 'aria-expanded', true );
    1925
     26    // Open the current submenu
     27    $secondary_menu = tocContainer.find( '.current-menu-item > ul' );
     28    if ( $secondary_menu.length ) {
     29        $secondary_menu.show();
     30    } else {
     31        tocContainer.find( '.current-menu-item' ).parents( 'ul' ).show();
     32    }
    2033    // Or if wrapped in a div.expandable
    21     jQuery( '.menu-item-has-children > div > .dashicons' ).click( function() {
     34    jQuery( '.menu-item-has-children > div > .dashicons' ).click( function () {
    2235        var menuToggle = jQuery( this ).closest( '.menu-item-has-children' );
    2336
    24         jQuery( this ).parent().siblings( '.children' ).slideToggle();
     37        jQuery( this ).parent().siblings( '.sub-menu' ).length
     38            ? jQuery( this ).parent().siblings( '.sub-menu' ).slideToggle()
     39            : jQuery( this ).parent().siblings( '.children' ).slideToggle()
    2540
    2641        menuToggle.toggleClass( 'open' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/style.css

    r9425 r9427  
    13361336}
    13371337.menu-table-of-contents-container .current_page_ancestor:not(.open) .expandable .dashicons:not(:focus),
    1338 .menu-table-of-contents-container .current_page_item .expandable .dashicons:not(:focus) {
     1338.menu-table-of-contents-container .current_page_item > .expandable .dashicons:not(:focus) {
    13391339    background: #fff;
    13401340    color: #0073aa;
Note: See TracChangeset for help on using the changeset viewer.