Make WordPress Core

Ticket #23557: 23557.3.diff

File 23557.3.diff, 1.6 KB (added by obenland, 12 years ago)
  • wp-content/themes/twentythirteen/js/functions.js

     
    55 */
    66
    77( function( $ ) {
    8         /**
    9          * Repositions the window on jump-to-anchor to account for
    10          * navbar height.
    11          */
    12         var twentyThirteenAdjustAnchor = function() {
    13                 if ( window.location.hash )
    14                         window.scrollBy( 0, -49 );
     8        var twentyThirteen = {
     9                /**
     10                 * Adds a margin to the footer, if the sidebar widget area is higher
     11                 * than the rest of the page.
     12                 */
     13                adjustFooter : function() {
     14                        var sidebar   = $('#secondary .widget-area'),
     15                            secondary = 0 == sidebar.length ? -40 : sidebar.height(),
     16                            margin    = $('#tertiary .widget-area').height() - $('#content').height() - secondary;
     17
     18                        if ( 0 < margin && 999 < window.innerWidth )
     19                                $( '#colophon' ).css( 'margin-top', margin + 'px' );
     20                },
     21
     22                /**
     23                 * Repositions the window on jump-to-anchor to account for navbar
     24                 * height.
     25                 */
     26                adjustAnchor : function() {
     27                        if ( window.location.hash )
     28                                window.scrollBy( 0, -49 );
     29                }
    1530        };
    1631
    17         $( document ).on( 'ready',    twentyThirteenAdjustAnchor );
    18         $( window ).on( 'hashchange', twentyThirteenAdjustAnchor );
     32        $( document ).on( 'ready', function() {
     33                twentyThirteen.adjustAnchor();
     34
     35                if ( body.is( '.sidebar' ) )
     36                        twentyThirteen.adjustFooter();
     37        } );
     38        $( window ).on( 'hashchange', twentyThirteen.adjustAnchor );
    1939
    2040        /**
    2141         * Displays the fixed navbar based on screen position.