mirror of
https://github.com/danbulant/api_docs
synced 2026-05-19 04:08:40 +00:00
commit
cfa9f48dd0
1 changed files with 8 additions and 14 deletions
|
|
@ -21,6 +21,12 @@ under the License.
|
|||
|
||||
function activateLanguage(language) {
|
||||
if (!language) return;
|
||||
|
||||
var hash = window.location.hash;
|
||||
if (hash) hash = hash.replace(/^#+/, '');
|
||||
// do not reload the page every time the language is changed
|
||||
if (history) history.pushState({}, '', '?' + language + '#' + hash);
|
||||
|
||||
$("#lang-selector a").removeClass('active');
|
||||
$("#lang-selector a[data-language-name='" + language + "']").addClass('active');
|
||||
for (var i=0; i < languages.length; i++) {
|
||||
|
|
@ -48,25 +54,13 @@ under the License.
|
|||
// no language selected, so use the default
|
||||
activateLanguage(languages[0]);
|
||||
}
|
||||
|
||||
// if we click on a language tab, reload the page with that language in the URL
|
||||
$("#lang-selector a").bind("click", function() {
|
||||
window.location.replace("?" + $(this).data("language-name") + window.location.hash);
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// if we click on a language tab, activate that language
|
||||
$(function() {
|
||||
$("#lang-selector a").on("click", function() {
|
||||
var lang = $(this).data("language-name");
|
||||
var hash = window.location.hash;
|
||||
if (hash) hash = hash.replace(/^#+/, '');
|
||||
// do not reload the page every time the language is changed
|
||||
if (history) history.pushState({}, '', '?' + lang + '#' + hash);
|
||||
|
||||
activateLanguage(lang);
|
||||
var language = $(this).data("language-name");
|
||||
activateLanguage(language);
|
||||
return false;
|
||||
});
|
||||
window.onpopstate = function(event) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue