Global jQuery references to navigation components we care about.
We use the first child's offset top rather than toc$.offset().top because there may be borders or other stylistic tweaks that further offset the scrollTop.
If the current node is partially or fully above the top of the viewport, scroll it into view.
Similarly, if we're below the bottom of the viewport, scroll up enough to make it visible.
We collapse up to the node's parent if the current node is already collapsed. This allows a user to quickly spam left to move up the tree.
Remove first, in case it's the same node
Fall back to the first node if anything goes wrong
Only show a filter if it matches this many or fewer nodes
An array of of [search string, node, label text] triples
Update the DOM
Filter out our immediate parent
Navigation and the table of contents are entirely managed by us.
Special case the index to go to the project root
we use the discloser in the clickLabel-closure below
Persist our references to the node
Select the current file, and expand up to it
We use the search box's focus state to toggle the table of contents. This ensures that search will always be focused while the toc is up, and that it goes away once the user clicks off.
However, we don't want to hide the table of contents if you are clicking around in the nav. The blur event doesn't give us the previous event, sadly, so we first trap mousedown events
And we refocus search if we are within a very short duration between the last mousedown in nav$.
Set up the table of contents toggle
Note: the following CSS prevents text-selection:
-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
Nevertheless, the text-selection prevention is obsolete, as we use an icon.
Crazy hack, ensuring that the defaults of multiple projects published to the same github account don't overlap with each other, hence every project gets its own cookie per path …
We get here if we're looking locally at the project or publish the project to the root of an webserver, hence clashes of defaults might occur; to fix this, we need to do more …
FIXME: If cookiePath is null, prefix the cookie's name with project name.
Private method setColumnLayout
Switches the layout class and stores the layout in a cookie or removes the
cookie if an unknown or no layout has been given …
Parameter:
Set up the layout toggle
Initialize the layout from the cookie
Arrow keys navigate the table of contents whenever it is visible
searching
Make folded code blocks toggleable; the marker and the code are clickable.
Page Behavior