From 297f1c0f20c0a35a69f04c5be4d099defb22285f Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Tue, 12 Mar 2013 21:42:53 +0000 Subject: [PATCH] Twenty Thirteen: enable a JavaScript-based fix for long sidebar areas that overflow the footer. Props obenland, fixes #23557. git-svn-id: https://develop.svn.wordpress.org/trunk@23676 602fd350-edb4-49c9-b593-d223f7449a82 --- .../themes/twentythirteen/js/functions.js | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/wp-content/themes/twentythirteen/js/functions.js b/wp-content/themes/twentythirteen/js/functions.js index f47ffcc514..f9aca37ea0 100644 --- a/wp-content/themes/twentythirteen/js/functions.js +++ b/wp-content/themes/twentythirteen/js/functions.js @@ -5,17 +5,40 @@ */ ( function( $ ) { - /** - * Repositions the window on jump-to-anchor to account for - * navbar height. - */ - var twentyThirteenAdjustAnchor = function() { - if ( window.location.hash ) - window.scrollBy( 0, -49 ); + var twentyThirteen = { + /** + * Adds a top margin to the footer if the sidebar widget area is + * higher than the rest of the page, to help the footer always + * visually clear the sidebar. + */ + adjustFooter : function() { + var sidebar = $( '#secondary .widget-area' ), + secondary = ( 0 == sidebar.length ) ? -40 : sidebar.height(), + margin = $( '#tertiary .widget-area' ).height() - $( '#content' ).height() - secondary; + + if ( margin > 0 && window.innerWidth > 999 ) + $( '#colophon' ).css( 'margin-top', margin + 'px' ); + else + console.log( 'nothing' ); + }, + + /** + * Repositions the window on jump-to-anchor to account for navbar + * height. + */ + adjustAnchor : function() { + if ( window.location.hash ) + window.scrollBy( 0, -49 ); + } }; - $( document ).on( 'ready', twentyThirteenAdjustAnchor ); - $( window ).on( 'hashchange', twentyThirteenAdjustAnchor ); + $( document ).on( 'ready', function() { + twentyThirteen.adjustAnchor(); + + if ( body.is( '.sidebar' ) ) + twentyThirteen.adjustFooter(); + } ); + $( window ).on( 'hashchange', twentyThirteen.adjustAnchor ); /** * Displays the fixed navbar based on screen position.