mirror of
https://github.com/danbulant/api_docs
synced 2026-05-19 12:19:08 +00:00
This commit has two benefits: - Now, copying the URL will actually copy the current language as well. You don't need to think to add a language - If a language moves objects on the page down, the tocify header location cache will not be invalid, since it is generated on page load. Therefore, if code moves some elements down, since the page is reloaded, the cache will also be regenerated, to reflect the real locations of the headers.
27 lines
708 B
JavaScript
27 lines
708 B
JavaScript
languages = []
|
|
function activateLanguage(language) {
|
|
$("#lang-selector a").removeClass('active');
|
|
$("#lang-selector a[data-language-name='" + language + "']").addClass('active');
|
|
for (var i=0; i < languages.length; i++) {
|
|
$(".highlight." + languages[i]).hide();
|
|
}
|
|
$(".highlight." + language).show();
|
|
}
|
|
|
|
function setupLanguages(l) {
|
|
languages = l;
|
|
currentLanguage = languages[0];
|
|
|
|
if (location.search.substr(1) != "") {
|
|
activateLanguage(location.search.substr(1));
|
|
} else {
|
|
activateLanguage(languages[0]);
|
|
}
|
|
|
|
$("#lang-selector a").bind("click", function() {
|
|
window.location.replace("?" + $(this).data("language-name") + window.location.hash);
|
|
return false;
|
|
});
|
|
|
|
}
|
|
|