Make WordPress Core

Changeset 30324


Ignore:
Timestamp:
11/13/2014 03:08:21 AM (11 years ago)
Author:
iandstewart
Message:

Twenty Fifteen: unfix the sidebar if we have a menu with submenus as there is a chance visitors might not be able to scroll down to see submenus in some situations.

Props mattwiebe, fixes #30208.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfifteen/js/functions.js

    r30233 r30324  
    5151
    5252    // Sidebar (un)fixing: fix when short, un-fix when scroll needed
    53     $body         = $( 'body' );
    54     $window       = $( window );
    55     sidebar       = $( '#sidebar' )[0];
    56     toolbarOffset = $body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
    57 
    5853    function fixedOrScrolledSidebar() {
    5954        if ( $window.width() >= 955 ) {
     
    7974    }
    8075
    81     $window.on( 'load.twentyfifteen', fixedOrScrolledSidebar ).on( 'resize.twentyfifteen', debouncedFixedOrScrolledSidebar() );
     76
     77    $( document ).ready( function() {
     78        // But! We only want to allow fixed sidebars when there are no submenus.
     79        if ( $( '#site-navigation .sub-menu' ).length ) {
     80            return;
     81        }
     82
     83        // only initialize 'em if we need 'em
     84        $body         = $( 'body' );
     85        $window       = $( window );
     86        sidebar       = $( '#sidebar' )[0];
     87        toolbarOffset = $body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
     88
     89        $window
     90            .on( 'load.twentyfifteen', fixedOrScrolledSidebar )
     91            .on( 'resize.twentyfifteen', debouncedFixedOrScrolledSidebar() );
     92    } );
    8293
    8394} )( jQuery );
Note: See TracChangeset for help on using the changeset viewer.