evovle перенесен на float + добавлены некоторые опциональные параметры
т.к. нет особо смысла супер быстро рассчитывать параметры. это просто вспомогательный инструмент для их параметров
This commit is contained in:
@@ -23,34 +23,16 @@
|
||||
@licend The above is the entire license notice for the JavaScript code in this file
|
||||
*/
|
||||
|
||||
function initNavTree(toroot,relpath,allMembersFile) {
|
||||
function initNavTree(toroot,relpath) {
|
||||
let navTreeSubIndices = [];
|
||||
const ARROW_DOWN = '<span class="arrowhead opened"></span>';
|
||||
const ARROW_RIGHT = '<span class="arrowhead closed"></span>';
|
||||
const ARROW_DOWN = '▼';
|
||||
const ARROW_RIGHT = '►';
|
||||
const NAVPATH_COOKIE_NAME = ''+'navpath';
|
||||
const fullSidebar = typeof page_layout!=='undefined' && page_layout==1;
|
||||
|
||||
function getScrollBarWidth () {
|
||||
let outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll', scrollbarWidth: 'thin'}).appendTo('body');
|
||||
let widthWithScroll = $('<div>').css({width: '100%'}).appendTo(outer).outerWidth();
|
||||
outer.remove();
|
||||
return 100 - widthWithScroll;
|
||||
}
|
||||
const scrollbarWidth = getScrollBarWidth();
|
||||
|
||||
function adjustSyncIconPosition() {
|
||||
if (!fullSidebar) {
|
||||
const nt = document.getElementById("nav-tree");
|
||||
const hasVerticalScrollbar = nt.scrollHeight > nt.clientHeight;
|
||||
$("#nav-sync").css({right:parseInt(hasVerticalScrollbar?scrollbarWidth:0)});
|
||||
}
|
||||
}
|
||||
|
||||
const getData = function(varName) {
|
||||
const i = varName.lastIndexOf('/');
|
||||
const n = i>=0 ? varName.substring(i+1) : varName;
|
||||
const e = n.replace(/-/g,'_');
|
||||
return window[e];
|
||||
return eval(n.replace(/-/g,'_'));
|
||||
}
|
||||
|
||||
const stripPath = function(uri) {
|
||||
@@ -95,7 +77,7 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
const script = document.createElement('script');
|
||||
script.id = scriptName;
|
||||
script.type = 'text/javascript';
|
||||
script.onload = function() { func(); adjustSyncIconPosition(); }
|
||||
script.onload = func;
|
||||
script.src = scriptName+'.js';
|
||||
head.appendChild(script);
|
||||
}
|
||||
@@ -114,8 +96,8 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
node.expandToggle.href = "javascript:void(0)";
|
||||
node.expandToggle.onclick = function() {
|
||||
if (node.expanded) {
|
||||
$(node.getChildrenUL()).slideUp("fast",adjustSyncIconPosition);
|
||||
$(node.plus_img.childNodes[0]).removeClass('opened').addClass('closed');
|
||||
$(node.getChildrenUL()).slideUp("fast");
|
||||
node.plus_img.innerHTML=ARROW_RIGHT;
|
||||
node.expanded = false;
|
||||
} else {
|
||||
expandNode(o, node, false, true);
|
||||
@@ -140,9 +122,9 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
if (ancParent.hasClass('memItemLeft') || ancParent.hasClass('memtitle') ||
|
||||
ancParent.hasClass('fieldname') || ancParent.hasClass('fieldtype') ||
|
||||
ancParent.is(':header')) {
|
||||
pos = ancParent.offset().top;
|
||||
pos = ancParent.position().top;
|
||||
} else if (anchor.position()) {
|
||||
pos = anchor.offset().top;
|
||||
pos = anchor.position().top;
|
||||
}
|
||||
if (pos) {
|
||||
const dcOffset = docContent.offset().top;
|
||||
@@ -154,33 +136,12 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
docContent.animate({
|
||||
scrollTop: pos + dcScrTop - dcOffset
|
||||
},Math.max(50,Math.min(500,dist)),function() {
|
||||
window.location.href=aname;
|
||||
animationInProgress=false;
|
||||
if (anchor.parent().attr('class')=='memItemLeft') {
|
||||
let rows = $('.memberdecls tr[class$="'+hashValue()+'"]');
|
||||
glowEffect(rows.children(),300); // member without details
|
||||
} else if (anchor.parent().attr('class')=='fieldname') {
|
||||
glowEffect(anchor.parent().parent(),1000); // enum value
|
||||
} else if (anchor.parent().attr('class')=='fieldtype') {
|
||||
glowEffect(anchor.parent().parent(),1000); // struct field
|
||||
} else if (anchor.parent().is(":header")) {
|
||||
glowEffect(anchor.parent(),1000); // section header
|
||||
} else {
|
||||
glowEffect(anchor.next(),1000); // normal member
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function htmlToNode(html) {
|
||||
const template = document.createElement('template');
|
||||
template.innerHTML = html;
|
||||
const nNodes = template.content.childNodes.length;
|
||||
if (nNodes !== 1) {
|
||||
throw new Error(`html parameter must represent a single node; got ${nNodes}. `);
|
||||
}
|
||||
return template.content.firstChild;
|
||||
}
|
||||
|
||||
const newNode = function(o, po, text, link, childrenData, lastNode) {
|
||||
const node = {
|
||||
children : [],
|
||||
@@ -192,6 +153,7 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
parentNode : po,
|
||||
itemDiv : document.createElement("div"),
|
||||
labelSpan : document.createElement("span"),
|
||||
label : document.createTextNode(text),
|
||||
expanded : false,
|
||||
childrenUL : null,
|
||||
getChildrenUL : function() {
|
||||
@@ -214,7 +176,7 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
const a = document.createElement("a");
|
||||
node.labelSpan.appendChild(a);
|
||||
po.getChildrenUL().appendChild(node.li);
|
||||
a.appendChild(htmlToNode('<span>'+text+'</span>'));
|
||||
a.appendChild(node.label);
|
||||
if (link) {
|
||||
let url;
|
||||
if (link.substring(0,1)=='^') {
|
||||
@@ -279,8 +241,8 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
if (!node.childrenVisited) {
|
||||
getNode(o, node);
|
||||
}
|
||||
$(node.getChildrenUL()).slideDown("fast",adjustSyncIconPosition);
|
||||
$(node.plus_img.childNodes[0]).addClass('opened').removeClass('closed');
|
||||
$(node.getChildrenUL()).slideDown("fast");
|
||||
node.plus_img.innerHTML = ARROW_DOWN;
|
||||
node.expanded = true;
|
||||
if (setFocus) {
|
||||
$(node.expandToggle).focus();
|
||||
@@ -298,6 +260,18 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
const highlightAnchor = function() {
|
||||
const aname = hashUrl();
|
||||
const anchor = $(aname);
|
||||
if (anchor.parent().attr('class')=='memItemLeft') {
|
||||
let rows = $('.memberdecls tr[class$="'+hashValue()+'"]');
|
||||
glowEffect(rows.children(),300); // member without details
|
||||
} else if (anchor.parent().attr('class')=='fieldname') {
|
||||
glowEffect(anchor.parent().parent(),1000); // enum value
|
||||
} else if (anchor.parent().attr('class')=='fieldtype') {
|
||||
glowEffect(anchor.parent().parent(),1000); // struct field
|
||||
} else if (anchor.parent().is(":header")) {
|
||||
glowEffect(anchor.parent(),1000); // section header
|
||||
} else {
|
||||
glowEffect(anchor.next(),1000); // normal member
|
||||
}
|
||||
gotoAnchor(anchor,aname);
|
||||
}
|
||||
|
||||
@@ -319,6 +293,7 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
if ($('#nav-tree-contents .item:first').hasClass('selected')) {
|
||||
topOffset+=25;
|
||||
}
|
||||
$('#nav-sync').css('top',topOffset+'px');
|
||||
showRoot();
|
||||
}
|
||||
|
||||
@@ -335,7 +310,7 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
getNode(o, node);
|
||||
}
|
||||
$(node.getChildrenUL()).css({'display':'block'});
|
||||
$(node.plus_img.childNodes[0]).removeClass('closed').addClass('opened');
|
||||
node.plus_img.innerHTML = ARROW_DOWN;
|
||||
node.expanded = true;
|
||||
const n = node.children[o.breadcrumbs[index]];
|
||||
if (index+1<o.breadcrumbs.length) {
|
||||
@@ -360,47 +335,41 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
}
|
||||
}
|
||||
|
||||
const removeToInsertLater = function(element) {
|
||||
const parentNode = element.parentNode;
|
||||
const nextSibling = element.nextSibling;
|
||||
parentNode.removeChild(element);
|
||||
return function() {
|
||||
if (nextSibling) {
|
||||
parentNode.insertBefore(element, nextSibling);
|
||||
} else {
|
||||
parentNode.appendChild(element);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const getNode = function(o, po) {
|
||||
const insertFunction = removeToInsertLater(po.li);
|
||||
po.childrenVisited = true;
|
||||
const l = po.childrenData.length-1;
|
||||
for (let i in po.childrenData) {
|
||||
const nodeData = po.childrenData[i];
|
||||
po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2], i==l);
|
||||
}
|
||||
insertFunction();
|
||||
}
|
||||
|
||||
const gotoNode = function(o,subIndex,root,hash,relpath) {
|
||||
const nti = navTreeSubIndices[subIndex][root+hash];
|
||||
if (nti==undefined && hash.length>0) { // try root page without hash as fallback
|
||||
gotoUrl(o,root,'',relpath);
|
||||
} else {
|
||||
o.breadcrumbs = $.extend(true, [], nti);
|
||||
if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index
|
||||
navTo(o,NAVTREE[0][1],"",relpath);
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
}
|
||||
if (o.breadcrumbs) {
|
||||
o.breadcrumbs.unshift(0); // add 0 for root node
|
||||
showNode(o, o.node, 0, hash);
|
||||
}
|
||||
o.breadcrumbs = $.extend(true, [], nti ? nti : navTreeSubIndices[subIndex][root]);
|
||||
if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index
|
||||
navTo(o,NAVTREE[0][1],"",relpath);
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
}
|
||||
}
|
||||
|
||||
const gotoUrl = function(o,root,hash,relpath) {
|
||||
const url=root+hash;
|
||||
let i=-1;
|
||||
while (NAVTREEINDEX[i+1]<=url) i++;
|
||||
if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index
|
||||
if (navTreeSubIndices[i]) {
|
||||
gotoNode(o,i,root,hash,relpath)
|
||||
} else {
|
||||
getScript(relpath+'navtreeindex'+i,function() {
|
||||
navTreeSubIndices[i] = window['NAVTREEINDEX'+i];
|
||||
if (navTreeSubIndices[i]) {
|
||||
gotoNode(o,i,root,hash,relpath);
|
||||
}
|
||||
});
|
||||
if (o.breadcrumbs) {
|
||||
o.breadcrumbs.unshift(0); // add 0 for root node
|
||||
showNode(o, o.node, 0, hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,15 +385,28 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
glowEffect(anchor.parent(),1000); // line number
|
||||
hash=''; // strip line number anchors
|
||||
}
|
||||
gotoUrl(o,root,hash,relpath);
|
||||
const url=root+hash;
|
||||
let i=-1;
|
||||
while (NAVTREEINDEX[i+1]<=url) i++;
|
||||
if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index
|
||||
if (navTreeSubIndices[i]) {
|
||||
gotoNode(o,i,root,hash,relpath)
|
||||
} else {
|
||||
getScript(relpath+'navtreeindex'+i,function() {
|
||||
navTreeSubIndices[i] = eval('NAVTREEINDEX'+i);
|
||||
if (navTreeSubIndices[i]) {
|
||||
gotoNode(o,i,root,hash,relpath);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const showSyncOff = function(n,relpath) {
|
||||
n.html('<div class="nav-sync-icon" title="'+SYNCOFFMSG+'"><span class="sync-icon-left"></span><span class="sync-icon-right"></span></div>');
|
||||
n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>');
|
||||
}
|
||||
|
||||
const showSyncOn = function(n,relpath) {
|
||||
n.html('<div class="nav-sync-icon active" title="'+SYNCONMSG+'"><span class="sync-icon-left"></span><span class="sync-icon-right"></span></div>');
|
||||
n.html('<img src="'+relpath+'sync_on.png" title="'+SYNCONMSG+'"/>');
|
||||
}
|
||||
|
||||
const o = {
|
||||
@@ -471,429 +453,30 @@ function initNavTree(toroot,relpath,allMembersFile) {
|
||||
showRoot();
|
||||
|
||||
$(window).bind('hashchange', () => {
|
||||
if (!animationInProgress) {
|
||||
if (window.location.hash && window.location.hash.length>1) {
|
||||
let a;
|
||||
if ($(location).attr('hash')) {
|
||||
const clslink=stripPath(pathName())+':'+hashValue();
|
||||
a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
|
||||
}
|
||||
if (a==null || !$(a).parent().parent().hasClass('selected')) {
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
}
|
||||
const link=stripPath2(pathName());
|
||||
navTo(o,link,hashUrl(),relpath);
|
||||
} else {
|
||||
$('#doc-content').scrollTop(0);
|
||||
if (window.location.hash && window.location.hash.length>1) {
|
||||
let a;
|
||||
if ($(location).attr('hash')) {
|
||||
const clslink=stripPath(pathName())+':'+hashValue();
|
||||
a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
|
||||
}
|
||||
if (a==null || !$(a).parent().parent().hasClass('selected')) {
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
navTo(o,toroot,hashUrl(),relpath);
|
||||
}
|
||||
const link=stripPath2(pathName());
|
||||
navTo(o,link,hashUrl(),relpath);
|
||||
} else if (!animationInProgress) {
|
||||
$('#doc-content').scrollTop(0);
|
||||
$('.item').removeClass('selected');
|
||||
$('.item').removeAttr('id');
|
||||
navTo(o,toroot,hashUrl(),relpath);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize(function() { adjustSyncIconPosition(); });
|
||||
|
||||
let navtree_trampoline = {
|
||||
updateContentTop : function() {}
|
||||
}
|
||||
|
||||
function initResizable() {
|
||||
let sidenav,mainnav,pagenav,container,navtree,content,header,footer,barWidth=6;
|
||||
const RESIZE_COOKIE_NAME = ''+'width';
|
||||
const PAGENAV_COOKIE_NAME = ''+'pagenav';
|
||||
const fullSidebar = typeof page_layout!=='undefined' && page_layout==1;
|
||||
|
||||
function showHideNavBar() {
|
||||
let bar = $('div.sm-dox');
|
||||
if (fullSidebar && mainnav && bar) {
|
||||
if (mainnav.width()<768) {
|
||||
bar.hide();
|
||||
} else {
|
||||
bar.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function constrainPanelWidths(leftPanelWidth,rightPanelWidth,dragLeft) {
|
||||
const contentWidth = container.width()-leftPanelWidth-rightPanelWidth;
|
||||
const minContentWidth = 250;
|
||||
const minPanelWidth = barWidth;
|
||||
if (contentWidth<minContentWidth) // need to shrink panels
|
||||
{
|
||||
const deficit = minContentWidth - contentWidth;
|
||||
if (dragLeft) { // dragging left handle -> try to keep right panel width
|
||||
const shrinkLeft = Math.min(deficit, leftPanelWidth-minPanelWidth);
|
||||
leftPanelWidth -= shrinkLeft;
|
||||
const remainingDeficit = deficit - shrinkLeft;
|
||||
const shrinkRight = Math.min(remainingDeficit, rightPanelWidth-minPanelWidth);
|
||||
rightPanelWidth -= shrinkRight;
|
||||
} else { // dragging right handle -> try to keep left panel width
|
||||
const shrinkRight = Math.min(deficit, rightPanelWidth-minPanelWidth);
|
||||
rightPanelWidth -= shrinkRight;
|
||||
const remainingDeficit = deficit - shrinkRight;
|
||||
const shrinkLeft = Math.min(remainingDeficit, leftPanelWidth-minPanelWidth);
|
||||
leftPanelWidth -= shrinkLeft;
|
||||
}
|
||||
} else {
|
||||
rightPanelWidth = pagenav.length ? Math.max(minPanelWidth,rightPanelWidth) : 0;
|
||||
leftPanelWidth = Math.max(minPanelWidth,leftPanelWidth);
|
||||
}
|
||||
return { leftPanelWidth, rightPanelWidth }
|
||||
}
|
||||
|
||||
function updateWidths(sidenavWidth,pagenavWidth,dragLeft)
|
||||
{
|
||||
const widths = constrainPanelWidths(sidenavWidth,pagenavWidth,dragLeft);
|
||||
const widthStr = parseInt(widths.leftPanelWidth)+"px";
|
||||
content.css({marginLeft:widthStr});
|
||||
if (fullSidebar) {
|
||||
footer.css({marginLeft:widthStr});
|
||||
if (mainnav) {
|
||||
mainnav.css({marginLeft:widthStr});
|
||||
}
|
||||
}
|
||||
sidenav.css({width:widthStr});
|
||||
if (pagenav.length) {
|
||||
container.css({gridTemplateColumns:'auto '+parseInt(widths.rightPanelWidth)+'px'});
|
||||
pagenav.css({width:parseInt(widths.rightPanelWidth-1)+'px'});
|
||||
}
|
||||
return widths;
|
||||
}
|
||||
|
||||
function resizeWidth(dragLeft) {
|
||||
const sidenavWidth = $(sidenav).outerWidth()-barWidth;
|
||||
const pagenavWidth = pagenav.length ? $(pagenav).outerWidth() : 0;
|
||||
const widths = updateWidths(sidenavWidth,pagenavWidth,dragLeft);
|
||||
Cookie.writeSetting(RESIZE_COOKIE_NAME,widths.leftPanelWidth-barWidth);
|
||||
if (pagenav.length) {
|
||||
Cookie.writeSetting(PAGENAV_COOKIE_NAME,widths.rightPanelWidth);
|
||||
}
|
||||
}
|
||||
|
||||
function restoreWidth(sidenavWidth,pagenavWidth) {
|
||||
updateWidths(sidenavWidth,pagenavWidth,false);
|
||||
showHideNavBar();
|
||||
}
|
||||
|
||||
function resizeHeight() {
|
||||
const headerHeight = header.outerHeight();
|
||||
const windowHeight = $(window).height();
|
||||
let contentHeight;
|
||||
const footerHeight = footer.outerHeight();
|
||||
let navtreeHeight,sideNavHeight;
|
||||
if (!fullSidebar) {
|
||||
contentHeight = windowHeight - headerHeight - footerHeight - 1;
|
||||
navtreeHeight = contentHeight;
|
||||
sideNavHeight = contentHeight;
|
||||
} else if (fullSidebar) {
|
||||
contentHeight = windowHeight - footerHeight - 1;
|
||||
navtreeHeight = windowHeight - headerHeight - 1;
|
||||
sideNavHeight = windowHeight - 1;
|
||||
if (mainnav) {
|
||||
contentHeight -= mainnav.outerHeight();
|
||||
}
|
||||
}
|
||||
navtree.css({height:navtreeHeight + "px"});
|
||||
sidenav.css({height:sideNavHeight + "px"});
|
||||
content.css({height:contentHeight + "px"});
|
||||
resizeWidth(false);
|
||||
showHideNavBar();
|
||||
if (location.hash.slice(1)) {
|
||||
(document.getElementById(location.hash.slice(1))||document.body).scrollIntoView();
|
||||
}
|
||||
}
|
||||
|
||||
header = $("#top");
|
||||
content = $("#doc-content");
|
||||
footer = $("#nav-path");
|
||||
sidenav = $("#side-nav");
|
||||
if (document.getElementById('main-nav')) {
|
||||
mainnav = $("#main-nav");
|
||||
}
|
||||
navtree = $("#nav-tree");
|
||||
pagenav = $("#page-nav");
|
||||
container = $("#container");
|
||||
$(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(true); } });
|
||||
$(sidenav).resizable({ minWidth: 0 });
|
||||
if (pagenav.length) {
|
||||
pagehandle = $("#page-nav-resize-handle");
|
||||
pagehandle.on('mousedown touchstart',function(e) {
|
||||
$('body').addClass('resizing');
|
||||
pagehandle.addClass('dragging');
|
||||
$(document).on('mousemove touchmove',function(e) {
|
||||
const clientX = e.clientX || e.originalEvent.touches[0].clientX;
|
||||
let pagenavWidth = container[0].offsetWidth-clientX+barWidth/2;
|
||||
const sidenavWidth = sidenav.width();
|
||||
const widths = constrainPanelWidths(sidenavWidth,pagenavWidth,false);
|
||||
container.css({gridTemplateColumns:'auto '+parseInt(widths.rightPanelWidth)+'px'});
|
||||
pagenav.css({width:parseInt(widths.rightPanelWidth-1)+'px'});
|
||||
content.css({marginLeft:parseInt(widths.leftPanelWidth)+'px'});
|
||||
Cookie.writeSetting(PAGENAV_COOKIE_NAME,pagenavWidth);
|
||||
});
|
||||
$(document).on('mouseup touchend', function(e) {
|
||||
$('body').removeClass('resizing');
|
||||
pagehandle.removeClass('dragging');
|
||||
$(document).off('mousemove mouseup touchmove touchend');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
container.css({gridTemplateColumns:'auto'});
|
||||
}
|
||||
const width = parseInt(Cookie.readSetting(RESIZE_COOKIE_NAME,250));
|
||||
const pagenavWidth = parseInt(Cookie.readSetting(PAGENAV_COOKIE_NAME,250));
|
||||
if (width) { restoreWidth(width+barWidth,pagenavWidth); } else { resizeWidth(); }
|
||||
const url = location.href;
|
||||
const i=url.indexOf("#");
|
||||
if (i>=0) window.location.hash=url.substr(i);
|
||||
const _preventDefault = function(evt) { evt.preventDefault(); };
|
||||
$("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
|
||||
$(window).ready(function() {
|
||||
let lastWidth = -1;
|
||||
let lastHeight = -1;
|
||||
$(window).resize(function() {
|
||||
const newWidth = $(this).width(), newHeight = $(this).height();
|
||||
if (newWidth!=lastWidth || newHeight!=lastHeight) {
|
||||
resizeHeight();
|
||||
navtree_trampoline.updateContentTop();
|
||||
lastWidth = newWidth;
|
||||
lastHeight = newHeight;
|
||||
}
|
||||
});
|
||||
resizeHeight();
|
||||
lastWidth = $(window).width();
|
||||
lastHeight = $(window).height();
|
||||
content.scroll(function() {
|
||||
navtree_trampoline.updateContentTop();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initPageToc() {
|
||||
const topMapping = [];
|
||||
const toc_contents = $('#page-nav-contents');
|
||||
const content=$('<ul>').addClass('page-outline');
|
||||
|
||||
var entityMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/',
|
||||
'`': '`',
|
||||
'=': '='
|
||||
};
|
||||
function escapeHtml (string) {
|
||||
return String(string).replace(/[&<>"'`=\/]/g, function (s) {
|
||||
return entityMap[s];
|
||||
});
|
||||
}
|
||||
|
||||
// for ClassDef/GroupDef/ModuleDef/ConceptDef/DirDef
|
||||
const groupSections = [];
|
||||
let currentGroup = null;
|
||||
$('h2.groupheader, h2.memtitle').each(function(){
|
||||
const $element = $(this);
|
||||
if ($element.hasClass('groupheader')) {
|
||||
currentGroup = { groupHeader: $element, memTitles: [] };
|
||||
groupSections.push(currentGroup);
|
||||
} else if ($element.hasClass('memtitle') && currentGroup) {
|
||||
currentGroup.memTitles.push($element);
|
||||
}
|
||||
});
|
||||
groupSections.forEach(function(item){
|
||||
const title = item.groupHeader.text().trim();
|
||||
let id = item.groupHeader.attr('id');
|
||||
const table = item.groupHeader.parents('table.memberdecls');
|
||||
let rows = $();
|
||||
if (table.length>0) {
|
||||
rows = table.find("tr[class^='memitem:'] td.memItemRight, tr[class^='memitem:'] td.memItemLeft.anon, tr[class=groupHeader] td");
|
||||
}
|
||||
function hasSubItems() {
|
||||
return item.memTitles.length>0 || rows.toArray().some(function(el) { return $(el).is(':visible'); });
|
||||
}
|
||||
const li = $('<li>').attr('id','nav-'+id);
|
||||
const div = $('<div>').addClass('item');
|
||||
const span = $('<span>').addClass('arrow').css({ paddingLeft:'0' });
|
||||
if (hasSubItems()) {
|
||||
span.append($('<span>').addClass('arrowhead opened'));
|
||||
}
|
||||
const ahref = $('<a>').attr('href','#'+id).append(title);
|
||||
content.append(li.append(div.append(span).append(ahref)));
|
||||
topMapping.push(id);
|
||||
const ulStack = [];
|
||||
ulStack.push(content);
|
||||
if (hasSubItems()) {
|
||||
let last_id = undefined;
|
||||
let inMemberGroup = false;
|
||||
// declaration sections have rows for items
|
||||
rows.each(function(){
|
||||
let td = $(this);
|
||||
let tr = $(td).parent();
|
||||
const is_anon_enum = td.contents().first().text().trim()=='{';
|
||||
if (tr.hasClass('template')) {
|
||||
tr = tr.prev();
|
||||
}
|
||||
id = $(tr).attr('id');
|
||||
const text = is_anon_enum ? 'anonymous enum' : $(this).find('a:first,b,div.groupHeader').text();
|
||||
let isMemberGroupHeader = $(tr).hasClass('groupHeader');
|
||||
if ($(tr).is(":visible") && last_id!=id && id!==undefined) {
|
||||
if (isMemberGroupHeader && inMemberGroup) {
|
||||
ulStack.pop();
|
||||
inMemberGroup=false;
|
||||
}
|
||||
const li2 = $('<li>').attr('id','nav-'+id);
|
||||
const div2 = $('<div>').addClass('item');
|
||||
const span2 = $('<span>').addClass('arrow').css({ paddingLeft:parseInt(ulStack.length*16)+'px' });
|
||||
const ahref = $('<a>').attr('href','#'+id).append(escapeHtml(text));
|
||||
li2.append(div2.append(span2).append(ahref));
|
||||
topMapping.push(id);
|
||||
if (isMemberGroupHeader) {
|
||||
span2.append($('<span>').addClass('arrowhead opened'));
|
||||
ulStack[ulStack.length-1].append(li2);
|
||||
const ul2 = $('<ul>');
|
||||
ulStack.push(ul2);
|
||||
li2.append(div2).append(ul2);
|
||||
inMemberGroup=true;
|
||||
} else {
|
||||
ulStack[ulStack.length-1].append(li2);
|
||||
}
|
||||
last_id=id;
|
||||
}
|
||||
});
|
||||
// detailed documentation has h2.memtitle sections for items
|
||||
item.memTitles.forEach(function(data) {
|
||||
const text = $(data).contents().not($(data).children().first()).text();
|
||||
const name = text.replace(/\(\)(\s*\[\d+\/\d+\])?$/, '') // func() [2/8] -> func
|
||||
id = $(data).find('span.permalink a').attr('href')
|
||||
if (id!==undefined && name!==undefined) {
|
||||
const li2 = $('<li>').attr('id','nav-'+id.substring(1));
|
||||
const div2 = $('<div>').addClass('item');
|
||||
const span2 = $('<span>').addClass('arrow').css({paddingLeft:parseInt(ulStack.length*16)+'px'});
|
||||
const ahref = $('<a>').attr('href',id).append(escapeHtml(name));
|
||||
ulStack[ulStack.length-1].append(li2.append(div2.append(span2).append(ahref)));
|
||||
topMapping.push(id.substring(1));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (allMembersFile.length) { // add entry linking to all members page
|
||||
const url = location.href;
|
||||
let srcBaseUrl = '';
|
||||
let dstBaseUrl = '';
|
||||
if (relpath.length) { // CREATE_SUBDIRS=YES -> find target location
|
||||
srcBaseUrl = url.substring(0, url.lastIndexOf('/')) + '/' + relpath;
|
||||
dstBaseUrl = allMembersFile.substr(0, allMembersFile.lastIndexOf('/'))+'/';
|
||||
}
|
||||
const pageName = url.split('/').pop().split('#')[0].replace(/(\.[^/.]+)$/, '-members$1');
|
||||
const li = $('<li>');
|
||||
const div = $('<div>').addClass('item');
|
||||
const span = $('<span>').addClass('arrow').css({ paddingLeft:'0' });
|
||||
const ahref = $('<a>').attr('href',srcBaseUrl+dstBaseUrl+pageName).addClass('noscroll');
|
||||
content.append(li.append(div.append(span).append(ahref.append(LISTOFALLMEMBERS))));
|
||||
}
|
||||
|
||||
if (groupSections.length==0) {
|
||||
// for PageDef
|
||||
const sectionTree = [], sectionStack = [];
|
||||
$('h1.doxsection, h2.doxsection, h3.doxsection, h4.doxsection, h5.doxsection, h6.doxsection').each(function(){
|
||||
const level = parseInt(this.tagName[1]);
|
||||
const anchor = $(this).find('a.anchor').attr('id');
|
||||
const node = { text: $(this).html(), id: anchor, children: [] };
|
||||
while (sectionStack.length && sectionStack[sectionStack.length - 1].level >= level) sectionStack.pop();
|
||||
(sectionStack.length ? sectionStack[sectionStack.length - 1].children : sectionTree).push(node);
|
||||
sectionStack.push({ ...node, level });
|
||||
});
|
||||
if (sectionTree.length>0) {
|
||||
function render(nodes, level=0) {
|
||||
nodes.map(n => {
|
||||
const li = $('<li>').attr('id','nav-'+n.id);
|
||||
const div = $('<div>').addClass('item');
|
||||
const span = $('<span>').addClass('arrow').attr('style','padding-left:'+parseInt(level*16)+'px;');
|
||||
if (n.children.length > 0) { span.append($('<span>').addClass('arrowhead opened')); }
|
||||
const url = $('<a>').attr('href','#'+n.id);
|
||||
content.append(li.append(div.append(span).append(url.append(n.text))));
|
||||
topMapping.push(n.id);
|
||||
render(n.children,level+1);
|
||||
});
|
||||
}
|
||||
render(sectionTree);
|
||||
}
|
||||
}
|
||||
|
||||
toc_contents.append(content);
|
||||
|
||||
$(".page-outline a[href]:not(.noscroll)").click(function(e) {
|
||||
e.preventDefault();
|
||||
const aname = $(this).attr("href");
|
||||
gotoAnchor($(aname),aname);
|
||||
});
|
||||
|
||||
let lastScrollSourceOffset = -1;
|
||||
let lastScrollTargetOffset = -1;
|
||||
let lastScrollTargetId = '';
|
||||
|
||||
navtree_trampoline.updateContentTop = function() {
|
||||
const pagenavcontents = $("#page-nav-contents");
|
||||
if (pagenavcontents.length) {
|
||||
const content = $("#doc-content");
|
||||
const height = content.height();
|
||||
const navy = pagenavcontents.offset().top;
|
||||
const yc = content.offset().top;
|
||||
let offsets = []
|
||||
for (let i=0;i<topMapping.length;i++) {
|
||||
const heading = $('#'+topMapping[i]);
|
||||
if (heading.parent().hasClass('doxsection')) {
|
||||
offsets.push({id:topMapping[i],y:heading.parent().offset().top-yc});
|
||||
} else {
|
||||
offsets.push({id:topMapping[i],y:heading.offset().top-yc});
|
||||
}
|
||||
}
|
||||
offsets.push({id:'',y:1e10});
|
||||
let scrollTarget = undefined, numItems=0;
|
||||
for (let i=0;i<topMapping.length;i++) {
|
||||
const ys = offsets[i].y;
|
||||
const ye = offsets[i+1].y;
|
||||
const id = offsets[i].id;
|
||||
const nav = $('#nav-'+id);
|
||||
const margin = 10; // #pixels before content show as visible
|
||||
if ((ys>margin || ye>margin) && (ys<height-margin || ye<height-margin)) {
|
||||
if (!scrollTarget) scrollTarget=nav;
|
||||
nav.addClass('vis'); // mark navigation entry as visible within content area
|
||||
numItems+=1;
|
||||
} else {
|
||||
nav.removeClass('vis');
|
||||
}
|
||||
}
|
||||
const contentScrollOffset = $('div.contents').offset().top;
|
||||
if (scrollTarget && lastScrollTargetId!=scrollTarget.attr('id')) { // new item to scroll to
|
||||
const scrollDown = contentScrollOffset<lastScrollSourceOffset;
|
||||
const range = 22*numItems;
|
||||
const my = range/2-height/2;
|
||||
const ulOffset = $('ul.page-outline').offset().top-navy;
|
||||
const targetPos=scrollTarget.offset().top-navy-ulOffset;
|
||||
const targetOffset=targetPos+my;
|
||||
if ( (scrollDown && targetOffset>lastScrollTargetOffset) ||
|
||||
(!scrollDown && targetOffset<lastScrollTargetOffset))
|
||||
{ // force panel to scroll in the same direction as content window
|
||||
pagenavcontents.stop(); // avoid build-up of history
|
||||
pagenavcontents.scrollTo({ left:0, top:targetOffset },{ duration: 500, interrupt: true });
|
||||
lastScrollTargetOffset = targetOffset;
|
||||
}
|
||||
lastScrollTargetId = scrollTarget.attr('id');
|
||||
}
|
||||
lastScrollSourceOffset = contentScrollOffset;
|
||||
}
|
||||
}
|
||||
// TODO: find out how to avoid a timeout
|
||||
setTimeout(() => {
|
||||
navtree_trampoline.updateContentTop();
|
||||
},200);
|
||||
}
|
||||
$(document).ready(function() { initPageToc(); initResizable(); });
|
||||
|
||||
$("div.toc a[href]").click(function(e) {
|
||||
e.preventDefault();
|
||||
const aname = $(this).attr("href");
|
||||
gotoAnchor($(aname),aname);
|
||||
});
|
||||
}
|
||||
/* @license-end */
|
||||
|
||||
Reference in New Issue
Block a user