Verified Commit ff55fe36 authored by Camil Staps's avatar Camil Staps 🚀

Documentation browser improvements

parent c19e66f5
......@@ -102,7 +102,7 @@ Element.prototype.browser = function(opts) {
if (i < path.length - 1) {
toggle(children[k]);
e = children[k].childNodes[1];
} else {
} else if (!children[k].classList.contains('directory')) {
children[k].classList.add('active');
}
break;
......@@ -111,8 +111,11 @@ Element.prototype.browser = function(opts) {
}
},
openTo: function(elem) {
if (elem == null)
return;
var path = [];
elem.classList.add('active');
if (!elem.classList.contains('directory'))
elem.classList.add('active');
while (elem != root && elem != null) {
if (elem.classList.contains('toggle-container'))
toggle(elem, true);
......
......@@ -63,11 +63,11 @@ class Toc {
echo '<div class="browser togglee">';
foreach ($this->children as $child) {
if ($child->isLeaf()) {
echo '<div class="browser-item module" id="' . $child->link .
echo '<div class="browser-item module" id="doc-' . $child->link .
'" data-name="' . $child->link . '">' .
$child->title . '</span></div>';
} else {
echo '<div class="browser-item directory toggle-container">' .
echo '<div class="browser-item directory toggle-container" id="doc-' . $child->link . '">' .
'<span class="toggler" onclick="toggle(this)">' .
'<span class="toggle-icon">&#x229e</span>' .
'<span class="title">' . $child->title . '</span></span>';
......
......@@ -19,7 +19,7 @@ window.onload = function() {
if (hashelems[i].substring(0,5) == 'jump=')
this.state.jump = hashelems[i].substring(5);
this.newState();
browser.openTo(document.getElementById(hash));
browser.openTo(document.getElementById('doc-' + hash));
},
newState: function () {
var hash = this.state.loc;
......@@ -51,4 +51,9 @@ window.onload = function() {
sidebar.style.height = (height - 20) + 'px';
viewer.style.height = height + 'px';
}
}
window.onhashchange = function () {
browser.open();
browser.triggerChange();
};
};
......@@ -16,6 +16,16 @@
padding: 1em;
}
#sidebar h3 {
background: none;
font-family: serif;
font-size: 1.17em;
font-weight: bold;
line-height: 22px;
margin-bottom: 17.55px;
margin-left: 0;
}
.Heading1Chapter img, .Newchapter img {
display: none;
}
......
......@@ -123,4 +123,4 @@ window.onload = function() {
sidebar.style.height = (height - 20) + 'px';
viewer.style.height = height + 'px';
}
}
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment