@@ -17,7 +17,7 @@ function updateNav() {
17
17
var availableSpace = $btn . hasClass ( 'hidden' ) ? $nav . width ( ) : $nav . width ( ) - $btn . width ( ) - 30 ;
18
18
19
19
// The visible list is overflowing the nav
20
- if ( $vlinks . width ( ) > availableSpace ) {
20
+ if ( $vlinks . width ( ) > availableSpace ) {
21
21
22
22
while ( $vlinks . width ( ) > availableSpace && $vlinks . children ( '*:not(.masthead__menu-item--lg)' ) . length > 0 ) {
23
23
@@ -27,26 +27,24 @@ function updateNav() {
27
27
// Move item to the hidden list
28
28
$vlinks . children ( '*:not(.masthead__menu-item--lg)' ) . last ( ) . prependTo ( $hlinks ) ;
29
29
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
+
32
32
// Show the dropdown btn
33
- if ( $btn . hasClass ( 'hidden' ) ) {
34
- $btn . removeClass ( 'hidden' ) ;
35
- }
33
+ $btn . removeClass ( "hidden" ) ;
36
34
}
37
35
38
36
// The visible list is not overflowing
39
37
} else {
40
38
41
39
// 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 ] ) {
43
41
// Move the item to the visible list
44
42
$hlinks . children ( ) . first ( ) . appendTo ( $vlinks ) ;
45
43
breaks . pop ( ) ;
46
44
}
47
45
48
46
// Hide the dropdown btn if hidden list is empty
49
- if ( breaks . length < 1 ) {
47
+ if ( breaks . length < 1 ) {
50
48
$btn . addClass ( 'hidden' ) ;
51
49
$btn . removeClass ( 'close' ) ;
52
50
$hlinks . addClass ( 'hidden' ) ;
@@ -56,18 +54,27 @@ function updateNav() {
56
54
// Keep counter updated
57
55
$btn . attr ( "count" , breaks . length ) ;
58
56
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
+
59
66
}
60
67
61
68
// Window listeners
62
69
63
- $ ( window ) . on ( 'resize' , function ( ) {
70
+ $ ( window ) . on ( 'resize' , function ( ) {
64
71
updateNav ( ) ;
65
72
} ) ;
66
- screen . orientation . addEventListener ( "change" , function ( ) {
73
+ screen . orientation . addEventListener ( "change" , function ( ) {
67
74
updateNav ( ) ;
68
75
} ) ;
69
76
70
- $btn . on ( 'click' , function ( ) {
77
+ $btn . on ( 'click' , function ( ) {
71
78
$hlinks . toggleClass ( 'hidden' ) ;
72
79
$ ( this ) . toggleClass ( 'close' ) ;
73
80
} ) ;
0 commit comments