Make WordPress Core

Ticket #30208: 30208.1.diff

File 30208.1.diff, 1.4 KB (added by mattwiebe, 11 years ago)
  • wp-content/themes/twentyfifteen/js/functions.js

     
    5050
    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 ) {
    6055                        if ( sidebar.scrollHeight < ( $window.height() - toolbarOffset ) ) {
     
    7873                };
    7974        }
    8075
    81         $window.on( 'load.twentyfifteen', fixedOrScrolledSidebar ).on( 'resize.twentyfifteen', debouncedFixedOrScrolledSidebar() );
    8276
     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        } );
     93
    8394} )( jQuery );
     95 No newline at end of file