in resources/web/docs_js/index-v1.js [163:217]
function init_toc(lang_strings) {
var title = $('#book_title');
// Make li elements in toc collapsible
$('div.toc li ul').each(function() {
var li = $(this).parent();
li.addClass('collapsible').children('span').click(function() {
if (li.hasClass('show')) {
li.add(li.find('li.show')).removeClass('show');
if (title.hasClass('show')) {
title.removeClass('show');
}
} else {
li.parents('div.toc,li').first().find('li.show').removeClass('show');
li.addClass('show');
}
});
});
// Make book title in toc collapsible
if ($('.collapsible').length > 0) {
title.addClass('collapsible').click(function() {
if (title.hasClass('show')) {
title.removeClass('show');
title.parent().find('.show').removeClass('show');
} else {
title.addClass('show');
title.parent().find('.collapsible').addClass('show');
}
});
}
// Clicking links or the version selector shouldn't fold/expand
$('div.toc a, #book_title select').click(function(e) {
e.stopPropagation();
});
// Setup version selector
var v_selected = title.find('select option:selected');
title
.find('select')
.change(function(e) {
var version = $(e.target).find('option:selected').val();
if (version === "other") {
$("#other_versions").show();
$("#live_versions").hide();
return;
}
utils.get_current_page_in_version(version).fail(function() {
v_selected.attr('selected', 'selected');
alert(lang_strings('This page is not available in the docs for version:')
+ version);
});
});
}