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

git-svn-id: http://core.svn.wordpress.org/trunk@23676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Lance Willett 2013-03-12 21:42:53 +00:00
parent 9adef0fcec
commit e18309bc0e

View File

@ -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.