@@ -21,6 +21,12 @@ under the License.
21
21
22
22
function activateLanguage ( language ) {
23
23
if ( ! language ) return ;
24
+
25
+ var hash = window . location . hash ;
26
+ if ( hash ) hash = hash . replace ( / ^ # + / , '' ) ;
27
+ // do not reload the page every time the language is changed
28
+ if ( history ) history . pushState ( { } , '' , '?' + language + '#' + hash ) ;
29
+
24
30
$ ( "#lang-selector a" ) . removeClass ( 'active' ) ;
25
31
$ ( "#lang-selector a[data-language-name='" + language + "']" ) . addClass ( 'active' ) ;
26
32
for ( var i = 0 ; i < languages . length ; i ++ ) {
@@ -48,25 +54,13 @@ under the License.
48
54
// no language selected, so use the default
49
55
activateLanguage ( languages [ 0 ] ) ;
50
56
}
51
-
52
- // if we click on a language tab, reload the page with that language in the URL
53
- $ ( "#lang-selector a" ) . bind ( "click" , function ( ) {
54
- window . location . replace ( "?" + $ ( this ) . data ( "language-name" ) + window . location . hash ) ;
55
- return false ;
56
- } ) ;
57
-
58
57
}
59
58
60
59
// if we click on a language tab, activate that language
61
60
$ ( function ( ) {
62
61
$ ( "#lang-selector a" ) . on ( "click" , function ( ) {
63
- var lang = $ ( this ) . data ( "language-name" ) ;
64
- var hash = window . location . hash ;
65
- if ( hash ) hash = hash . replace ( / ^ # + / , '' ) ;
66
- // do not reload the page every time the language is changed
67
- if ( history ) history . pushState ( { } , '' , '?' + lang + '#' + hash ) ;
68
-
69
- activateLanguage ( lang ) ;
62
+ var language = $ ( this ) . data ( "language-name" ) ;
63
+ activateLanguage ( language ) ;
70
64
return false ;
71
65
} ) ;
72
66
window . onpopstate = function ( event ) {
0 commit comments