File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ if (!isEmbedded) {
34
34
const select = qs ( VERSIONS_DROPDOWN_SELECTOR )
35
35
select . addEventListener ( 'change' , handleVersionSelected )
36
36
adjustWidth ( select )
37
+
38
+ const versionsGoToLatest = qs ( '.sidebar-staleVersion a' )
39
+ versionsGoToLatest . addEventListener ( 'click' , handleGoToLatestClicked )
37
40
}
38
41
}
39
42
@@ -67,6 +70,22 @@ function handleVersionSelected (event) {
67
70
} )
68
71
}
69
72
73
+ function handleGoToLatestClicked ( event ) {
74
+ const url = this . href
75
+ const pathSuffix = window . location . pathname . split ( '/' ) . pop ( ) + window . location . hash
76
+ const otherVersionWithPath = `${ url } /${ pathSuffix } `
77
+ event . preventDefault ( )
78
+
79
+ checkUrlExists ( otherVersionWithPath )
80
+ . then ( exists => {
81
+ if ( exists ) {
82
+ window . location . href = otherVersionWithPath
83
+ } else {
84
+ window . location . href = url
85
+ }
86
+ } )
87
+ }
88
+
70
89
/**
71
90
* Opens the version select if available.
72
91
* Only focuses the version select if
You can’t perform that action at this time.
0 commit comments