2013-02-18 18:08:56 -05:00
|
|
|
/**
|
|
|
|
* Functionality specific to Twenty Thirteen.
|
|
|
|
*
|
|
|
|
* Provides helper functions to enhance the theme experience.
|
|
|
|
*/
|
|
|
|
|
|
|
|
( function( $ ) {
|
2013-06-25 17:09:00 -04:00
|
|
|
var body = $( 'body' ),
|
2013-06-25 17:30:43 -04:00
|
|
|
_window = $( window );
|
2013-04-11 12:11:46 -04:00
|
|
|
|
2013-04-16 17:51:07 -04:00
|
|
|
/**
|
2013-06-25 17:09:00 -04:00
|
|
|
* 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.
|
2013-04-16 17:51:07 -04:00
|
|
|
*/
|
2013-04-03 13:29:59 -04:00
|
|
|
$( function() {
|
2013-06-25 17:09:00 -04:00
|
|
|
if ( body.is( '.sidebar' ) ) {
|
|
|
|
var sidebar = $( '#secondary .widget-area' ),
|
2014-03-19 01:29:29 -04:00
|
|
|
secondary = ( 0 === sidebar.length ) ? -40 : sidebar.height(),
|
2013-06-25 17:09:00 -04:00
|
|
|
margin = $( '#tertiary .widget-area' ).height() - $( '#content' ).height() - secondary;
|
|
|
|
|
2014-03-19 01:29:29 -04:00
|
|
|
if ( margin > 0 && _window.innerWidth() > 999 ) {
|
2013-06-25 17:09:00 -04:00
|
|
|
$( '#colophon' ).css( 'margin-top', margin + 'px' );
|
2014-03-19 01:29:29 -04:00
|
|
|
}
|
2013-06-25 17:09:00 -04:00
|
|
|
}
|
2013-03-12 17:42:53 -04:00
|
|
|
} );
|
2013-02-18 18:08:56 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables menu toggle for small screens.
|
|
|
|
*/
|
|
|
|
( function() {
|
|
|
|
var nav = $( '#site-navigation' ), button, menu;
|
2014-03-19 01:29:29 -04:00
|
|
|
if ( ! nav ) {
|
2013-02-18 18:08:56 -05:00
|
|
|
return;
|
2014-03-19 01:29:29 -04:00
|
|
|
}
|
2013-02-18 18:08:56 -05:00
|
|
|
|
|
|
|
button = nav.find( '.menu-toggle' );
|
2014-03-19 01:29:29 -04:00
|
|
|
if ( ! button ) {
|
2013-02-18 18:08:56 -05:00
|
|
|
return;
|
2014-03-19 01:29:29 -04:00
|
|
|
}
|
2013-02-18 18:08:56 -05:00
|
|
|
|
|
|
|
// Hide button if menu is missing or empty.
|
2013-06-25 17:09:00 -04:00
|
|
|
menu = nav.find( '.nav-menu' );
|
2013-02-18 18:08:56 -05:00
|
|
|
if ( ! menu || ! menu.children().length ) {
|
|
|
|
button.hide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-19 01:29:29 -04:00
|
|
|
button.on( 'click.twentythirteen', function() {
|
2013-02-18 18:08:56 -05:00
|
|
|
nav.toggleClass( 'toggled-on' );
|
|
|
|
} );
|
2014-03-19 01:29:29 -04:00
|
|
|
|
|
|
|
// Better focus for hidden submenu items for accessibility.
|
|
|
|
menu.find( 'a' ).on( 'focus.twentythirteen blur.twentythirteen', function() {
|
|
|
|
$( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' );
|
|
|
|
} );
|
2013-02-18 18:08:56 -05:00
|
|
|
} )();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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/
|
|
|
|
*/
|
2013-04-16 17:51:07 -04:00
|
|
|
_window.on( 'hashchange.twentythirteen', function() {
|
2013-04-23 12:30:03 -04:00
|
|
|
var element = document.getElementById( location.hash.substring( 1 ) );
|
2013-02-18 18:08:56 -05:00
|
|
|
|
|
|
|
if ( element ) {
|
2014-03-19 01:29:29 -04:00
|
|
|
if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {
|
2013-04-23 12:30:03 -04:00
|
|
|
element.tabIndex = -1;
|
2014-03-19 01:29:29 -04:00
|
|
|
}
|
2013-02-18 18:08:56 -05:00
|
|
|
|
|
|
|
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 );
|