Skip to content

Commit

Permalink
update toc after ajax load
Browse files Browse the repository at this point in the history
  • Loading branch information
vicancy committed Jan 13, 2016
1 parent 2fb329f commit 5b75dec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions src/docfx.website.themes/default/styles/docfx.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,38 @@ $(function () {
var hashIndex = currentHref.indexOf('#');
if (hashIndex > -1) currentHref = currentHref.substr(0, hashIndex);
$('#sidetoc').find('a[href]').each(function (i, e) {
if (e.href === currentHref) {
$(e).parent().addClass(active);
var parent = $(e).parent().parents('li').children('a');
if (parent.length > 0) {
parent.addClass(active);
var href = $(e).attr("href");
if (isRelativePath(href)) {
href = tocrel + href;
$(e).attr("href", href);
if (e.href === currentHref) {
$(e).parent().addClass(active);
var parent = $(e).parent().parents('li').children('a');
if (parent.length > 0) {
parent.addClass(active);
breadcrumb.push({
href: parent[0].href,
name: parent[0].innerHTML
});
}
// for active li, expand it
$(e).parents('ul.nav>li').addClass(expanded);

breadcrumb.push({
href: parent[0].href,
name: parent[0].innerHTML
href: e.href,
name: e.innerHTML
});
// Scroll to active item
var top = 0;
$(e).parents('li').each(function (i, e) {
top += $(e).position().top;
});
// 50 is the size of the filter box
$('.sidetoc').scrollTop(top - 50);
} else {
$(e).parent().removeClass(active);
$(e).parents('li').children('a').removeClass(active);
}
// for active li, expand it
$(e).parents('ul.nav>li').addClass(expanded);

breadcrumb.push({
href: e.href,
name: e.innerHTML
});
// Scroll to active item
var top = 0;
$(e).parents('li').each(function (i, e) {
top += $(e).position().top;
});
// 50 is the size of the filter box
$('.sidetoc').scrollTop(top - 50);
} else {
$(e).parent().removeClass(active);
$(e).parents('li').children('a').removeClass(active);
}
});
});
Expand Down
Binary file modified src/docfx/Template/default.zip
Binary file not shown.

0 comments on commit 5b75dec

Please sign in to comment.