Make WordPress Core

Changeset 23676


Ignore:
Timestamp:
03/12/2013 09:42:53 PM (14 years ago)
Author:
lancewillett
Message:

Twenty Thirteen: enable a JavaScript-based fix for long sidebar areas that overflow the footer. Props obenland, fixes #23557.

File:
1 edited

Legend:

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

    r23645 r23676  
    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 top margin to the footer if the sidebar widget area is
     11                 * higher than the rest of the page, to help the footer always
     12                 * visually clear the sidebar.
     13                 */
     14                adjustFooter : function() {
     15                        var sidebar   = $( '#secondary .widget-area' ),
     16                            secondary = ( 0 == sidebar.length ) ? -40 : sidebar.height(),
     17                            margin    = $( '#tertiary .widget-area' ).height() - $( '#content' ).height() - secondary;
     18
     19                        if ( margin > 0 && window.innerWidth > 999 )
     20                                $( '#colophon' ).css( 'margin-top', margin + 'px' );
     21                        else
     22                                console.log( 'nothing' );
     23                },
     24
     25                /**
     26                 * Repositions the window on jump-to-anchor to account for navbar
     27                 * height.
     28                 */
     29                adjustAnchor : function() {
     30                        if ( window.location.hash )
     31                                window.scrollBy( 0, -49 );
     32                }
    1533        };
    1634
    17         $( document ).on( 'ready',    twentyThirteenAdjustAnchor );
    18         $( window ).on( 'hashchange', twentyThirteenAdjustAnchor );
     35        $( document ).on( 'ready', function() {
     36                twentyThirteen.adjustAnchor();
     37
     38                if ( body.is( '.sidebar' ) )
     39                        twentyThirteen.adjustFooter();
     40        } );
     41        $( window ).on( 'hashchange', twentyThirteen.adjustAnchor );
    1942
    2043        /**
Note: See TracChangeset for help on using the changeset viewer.