The extensions have yet to receive this treatment and CSS needs work, but for now this is fine.
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
$(document).ready(function () {
|
|
var sections = $('div.section');
|
|
var activeLink = null;
|
|
var bottomHeightThreshold = $(document).height() - 30;
|
|
|
|
$(window).scroll(function (event) {
|
|
var distanceFromTop = $(this).scrollTop();
|
|
var currentSection = null;
|
|
|
|
if(distanceFromTop + window.innerHeight > bottomHeightThreshold) {
|
|
currentSection = $(sections[sections.length - 1]);
|
|
}
|
|
else {
|
|
sections.each(function () {
|
|
var section = $(this);
|
|
if (section.offset().top - 1 < distanceFromTop) {
|
|
currentSection = section;
|
|
}
|
|
});
|
|
}
|
|
|
|
if (activeLink) {
|
|
activeLink.parent().removeClass('active');
|
|
}
|
|
|
|
if (currentSection) {
|
|
activeLink = $('.sphinxsidebar a[href="#' + currentSection.attr('id') + '"]');
|
|
activeLink.parent().addClass('active');
|
|
}
|
|
|
|
const tables = document.querySelectorAll('.py-attribute-table[data-move-to-id]');
|
|
tables.forEach(table => {
|
|
let element = document.getElementById(table.getAttribute('data-move-to-id'));
|
|
let parent = element.parentNode;
|
|
// insert ourselves after the element
|
|
parent.insertBefore(table, element.nextSibling);
|
|
});
|
|
});
|
|
});
|