@@ -17,7 +17,7 @@ function updateNav() {
1717 var availableSpace = $btn . hasClass ( 'hidden' ) ? $nav . width ( ) : $nav . width ( ) - $btn . width ( ) - 30 ;
1818
1919 // The visible list is overflowing the nav
20- if ( $vlinks . width ( ) > availableSpace ) {
20+ if ( $vlinks . width ( ) > availableSpace ) {
2121
2222 while ( $vlinks . width ( ) > availableSpace && $vlinks . children ( '*:not(.masthead__menu-item--lg)' ) . length > 0 ) {
2323
@@ -27,26 +27,24 @@ function updateNav() {
2727 // Move item to the hidden list
2828 $vlinks . children ( '*:not(.masthead__menu-item--lg)' ) . last ( ) . prependTo ( $hlinks ) ;
2929
30- availableSpace = $btn . hasClass ( ' hidden' ) ? $nav . width ( ) : $nav . width ( ) - $btn . width ( ) - 30 ;
31-
30+ availableSpace = $btn . hasClass ( " hidden" ) ? $nav . width ( ) : $nav . width ( ) - $btn . width ( ) - 30 ;
31+
3232 // Show the dropdown btn
33- if ( $btn . hasClass ( 'hidden' ) ) {
34- $btn . removeClass ( 'hidden' ) ;
35- }
33+ $btn . removeClass ( "hidden" ) ;
3634 }
3735
3836 // The visible list is not overflowing
3937 } else {
4038
4139 // There is space for another item in the nav
42- while ( breaks . length > 0 && availableSpace > breaks [ breaks . length - 1 ] ) {
40+ while ( breaks . length > 0 && availableSpace > breaks [ breaks . length - 1 ] ) {
4341 // Move the item to the visible list
4442 $hlinks . children ( ) . first ( ) . appendTo ( $vlinks ) ;
4543 breaks . pop ( ) ;
4644 }
4745
4846 // Hide the dropdown btn if hidden list is empty
49- if ( breaks . length < 1 ) {
47+ if ( breaks . length < 1 ) {
5048 $btn . addClass ( 'hidden' ) ;
5149 $btn . removeClass ( 'close' ) ;
5250 $hlinks . addClass ( 'hidden' ) ;
@@ -56,18 +54,27 @@ function updateNav() {
5654 // Keep counter updated
5755 $btn . attr ( "count" , breaks . length ) ;
5856
57+ // update masthead height and the body/sidebar top padding
58+ var mastheadHeight = $ ( '.masthead' ) . height ( ) ;
59+ $ ( 'body' ) . css ( 'padding-top' , mastheadHeight + 'px' ) ;
60+ if ( $ ( ".author__urls-wrapper button" ) . is ( ":visible" ) ) {
61+ $ ( ".sidebar" ) . css ( "padding-top" , "" ) ;
62+ } else {
63+ $ ( ".sidebar" ) . css ( "padding-top" , mastheadHeight + "px" ) ;
64+ }
65+
5966}
6067
6168// Window listeners
6269
63- $ ( window ) . on ( 'resize' , function ( ) {
70+ $ ( window ) . on ( 'resize' , function ( ) {
6471 updateNav ( ) ;
6572} ) ;
66- screen . orientation . addEventListener ( "change" , function ( ) {
73+ screen . orientation . addEventListener ( "change" , function ( ) {
6774 updateNav ( ) ;
6875} ) ;
6976
70- $btn . on ( 'click' , function ( ) {
77+ $btn . on ( 'click' , function ( ) {
7178 $hlinks . toggleClass ( 'hidden' ) ;
7279 $ ( this ) . toggleClass ( 'close' ) ;
7380} ) ;
0 commit comments