2013-02-18 18:08:56 -05:00
|
|
|
/**
|
|
|
|
* Functionality specific to Twenty Thirteen.
|
|
|
|
*
|
|
|
|
* Provides helper functions to enhance the theme experience.
|
|
|
|
*/
|
|
|
|
|
|
|
|
( function( $ ) {
|
|
|
|
/**
|
|
|
|
* Repositions the window on jump-to-anchor to account for
|
|
|
|
* navbar height.
|
|
|
|
*/
|
|
|
|
var twentyThirteenAdjustAnchor = function() {
|
|
|
|
if ( window.location.hash )
|
|
|
|
window.scrollBy( 0, -49 );
|
|
|
|
};
|
|
|
|
|
|
|
|
$( document ).on( 'ready', twentyThirteenAdjustAnchor );
|
|
|
|
$( window ).on( 'hashchange', twentyThirteenAdjustAnchor );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays the fixed navbar based on screen position.
|
|
|
|
*/
|
|
|
|
var html = $( 'html' ),
|
2013-03-07 12:57:16 -05:00
|
|
|
body = $( 'body' ),
|
2013-02-18 18:08:56 -05:00
|
|
|
navbar = $( '#navbar' ),
|
|
|
|
navbarOffset = -1,
|
2013-03-07 12:57:16 -05:00
|
|
|
toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0;
|
2013-02-18 18:08:56 -05:00
|
|
|
|
|
|
|
$( window ).scroll( function() {
|
|
|
|
if ( navbarOffset < 0 )
|
|
|
|
navbarOffset = navbar.offset().top - toolbarOffset;
|
|
|
|
|
2013-02-28 14:49:26 -05:00
|
|
|
if ( window.scrollY >= navbarOffset && 644 < window.innerWidth )
|
2013-02-18 18:08:56 -05:00
|
|
|
html.addClass( 'navbar-fixed' );
|
|
|
|
else
|
|
|
|
html.removeClass( 'navbar-fixed' );
|
|
|
|
} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows clicking the navbar to scroll to top.
|
|
|
|
*/
|
|
|
|
navbar.on( 'click', function( event ) {
|
|
|
|
// Ensure that the navbar element was the target of the click.
|
|
|
|
if ( 'navbar' == event.target.id || 'site-navigation' == event.target.id )
|
|
|
|
$( 'html, body' ).animate( { scrollTop: 0 }, 'fast' );
|
|
|
|
} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables menu toggle for small screens.
|
|
|
|
*/
|
|
|
|
( function() {
|
|
|
|
var nav = $( '#site-navigation' ), button, menu;
|
|
|
|
if ( ! nav )
|
|
|
|
return;
|
|
|
|
|
|
|
|
button = nav.find( '.menu-toggle' );
|
|
|
|
menu = nav.find( '.nav-menu' );
|
|
|
|
if ( ! button )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Hide button if menu is missing or empty.
|
|
|
|
if ( ! menu || ! menu.children().length ) {
|
|
|
|
button.hide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$( '.menu-toggle' ).on( 'click', function() {
|
|
|
|
nav.toggleClass( 'toggled-on' );
|
|
|
|
} );
|
|
|
|
} )();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes "skip to content" link work correctly in IE9 and Chrome for better
|
|
|
|
* accessibility.
|
|
|
|
*
|
|
|
|
* @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
|
|
|
|
*/
|
|
|
|
$( window ).on( 'hashchange', function() {
|
|
|
|
var element = $( location.hash );
|
|
|
|
|
|
|
|
if ( element ) {
|
|
|
|
if ( ! /^(?:a|select|input|button)$/i.test( element.tagName ) )
|
|
|
|
element.attr( 'tabindex', -1 );
|
|
|
|
|
|
|
|
element.focus();
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Arranges footer widgets vertically.
|
|
|
|
*/
|
|
|
|
if ( $.isFunction( $.fn.masonry ) ) {
|
2013-03-07 12:57:16 -05:00
|
|
|
var columnWidth = body.is( '.sidebar' ) ? 228 : 245;
|
2013-02-18 18:08:56 -05:00
|
|
|
|
2013-02-28 16:35:26 -05:00
|
|
|
$( '#secondary .widget-area' ).masonry( {
|
2013-02-18 18:08:56 -05:00
|
|
|
itemSelector: '.widget',
|
2013-03-07 12:57:16 -05:00
|
|
|
columnWidth: columnWidth,
|
|
|
|
gutterWidth: 20,
|
2013-03-07 13:22:58 -05:00
|
|
|
isRTL: body.is( '.rtl' )
|
2013-02-18 18:08:56 -05:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
} )( jQuery );
|