2014-10-14 21:48:19 +02:00
|
|
|
/* global screenReaderText */
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
/**
|
2014-11-04 21:26:23 +01:00
|
|
|
* Theme functions file.
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
*
|
|
|
|
* Contains handlers for navigation and widget area.
|
|
|
|
*/
|
|
|
|
|
|
|
|
( function( $ ) {
|
2014-10-26 16:04:21 +01:00
|
|
|
var $body, $window, sidebar, toolbarOffset;
|
|
|
|
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
// Add dropdown toggle that display child menu items.
|
2014-10-24 17:15:20 +02:00
|
|
|
$( '.main-navigation .page_item_has_children > a, .main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' );
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
|
|
|
|
$( '.dropdown-toggle' ).click( function( e ) {
|
|
|
|
var _this = $( this );
|
|
|
|
e.preventDefault();
|
|
|
|
_this.toggleClass( 'toggle-on' );
|
2014-10-24 17:15:20 +02:00
|
|
|
_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
|
|
|
|
_this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand );
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Enable menu toggle for small screens.
|
|
|
|
( function() {
|
|
|
|
var secondary = $( '#secondary' ), button, menu, widgets, social;
|
|
|
|
if ( ! secondary ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
button = $( '.site-branding' ).find( '.secondary-toggle' );
|
|
|
|
if ( ! button ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hide button if there is no widgets and menu is missing or empty.
|
|
|
|
menu = secondary.find( '.nav-menu' );
|
|
|
|
widgets = secondary.find( '#widget-area' );
|
|
|
|
social = secondary.find( '#social-navigation' );
|
|
|
|
if ( ! widgets.length && ! social.length && ( ! menu || ! menu.children().length ) ) {
|
|
|
|
button.hide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
button.on( 'click.twentyfifteen', function() {
|
|
|
|
secondary.toggleClass( 'toggled-on' );
|
|
|
|
secondary.trigger( 'resize' );
|
|
|
|
$( this ).toggleClass( 'toggled-on' );
|
|
|
|
} );
|
|
|
|
} )();
|
2014-10-26 16:04:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Sidebar (un)fixing: fix when short, un-fix when scroll needed
|
|
|
|
$body = $( 'body' );
|
|
|
|
$window = $( window );
|
|
|
|
sidebar = $( '#sidebar' )[0];
|
|
|
|
toolbarOffset = $body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
|
|
|
|
|
|
|
|
function fixedOrScrolledSidebar() {
|
|
|
|
if ( $window.width() >= 955 ) {
|
|
|
|
if ( sidebar.scrollHeight < ( $window.height() - toolbarOffset ) ) {
|
|
|
|
$body.addClass( 'sidebar-fixed' );
|
|
|
|
} else {
|
|
|
|
$body.removeClass( 'sidebar-fixed' );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$body.removeClass( 'sidebar-fixed' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function debouncedFixedOrScrolledSidebar() {
|
|
|
|
var timeout;
|
|
|
|
return function() {
|
|
|
|
clearTimeout( timeout );
|
|
|
|
timeout = setTimeout( function() {
|
|
|
|
timeout = null;
|
|
|
|
fixedOrScrolledSidebar();
|
|
|
|
}, 150 );
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
$window.on( 'load.twentyfifteen', fixedOrScrolledSidebar ).on( 'resize.twentyfifteen', debouncedFixedOrScrolledSidebar() );
|
|
|
|
|
Importing Twenty Fifteen, first pass at our new default theme for 2015, set for 4.1.
It's good for posts, it's good for pages, it might be good for you. Development will occur in trunk. Have at it.
Props matt, iandstewart, iamtakashi, obenland, cainm, kristastevens, karmatosed, chellycat, lancewillett, kwight, davidakennedy. See #29799
Built from https://develop.svn.wordpress.org/trunk@29892
git-svn-id: http://core.svn.wordpress.org/trunk@29648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 21:28:18 +02:00
|
|
|
} )( jQuery );
|