This repository has been archived on 2020-05-08. You can view files and clone it, but cannot push or open issues or pull requests.
2016-10-23 15:54:40 +00:00
|
|
|
/**
|
|
|
|
* Vertical page navigation
|
|
|
|
* A temporary source file providing smooth scrolling navigation to Pages
|
|
|
|
*/
|
2016-10-25 16:38:36 +00:00
|
|
|
(function( $ ) {
|
|
|
|
var currentPage = location.href;
|
|
|
|
var adjustedHeight = $( 'body' ).hasClass( 'admin-bar' ) ? 36 : 0;
|
|
|
|
var blogPage = vars.homeUrl + '/' + vars.pageForPosts;
|
|
|
|
if ( currentPage.substr( -1 ) === '/' ) {
|
|
|
|
currentPage = currentPage.substr( 0, currentPage.length - 1 );
|
|
|
|
}
|
2016-10-23 15:54:40 +00:00
|
|
|
|
2016-10-25 16:38:36 +00:00
|
|
|
$( document ).ready(function() {
|
|
|
|
// smoothly scroll to an ID
|
|
|
|
$( 'a[href*="#"]:not([href="#"])' ).click( function ( e ) {
|
|
|
|
var target;
|
|
|
|
// if not on root URL
|
|
|
|
if ( currentPage === blogPage || vars.isSingle ) {
|
|
|
|
target = $(this);
|
|
|
|
target = vars.homeUrl + '/' + target[0].hash;
|
|
|
|
location = target;
|
|
|
|
}
|
|
|
|
target = $( this.hash );
|
|
|
|
target = target.length ? target : $( '[name=' + this.hash.slice(1) + ']' );
|
|
|
|
if ( target.length ) {
|
2016-10-23 15:54:40 +00:00
|
|
|
|
2016-10-25 16:38:36 +00:00
|
|
|
$( 'html, body' ).delay( 100 ).animate({
|
|
|
|
scrollTop: target.offset().top - adjustedHeight
|
|
|
|
}, 800);
|
|
|
|
// put the hash in location bar
|
|
|
|
window.history.pushState( null, null, e.delegateTarget.href );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})( jQuery );
|