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

Adjust sidebar division & store panel sizes in session storage (#4)

parent 052d34ce
Pipeline #14663 failed with stage
in 53 seconds
......@@ -17,17 +17,15 @@ a.hidden {
position: relative;
}
#container > div {
display: inline-block;
vertical-align: top;
}
#sidebar {
background: white;
border-color: black;
border-style: solid;
border-width: 0 1px 0 0;
height: 100%;
box-sizing: border-box;
display: flex;
flex-flow: column;
height: 100vh;
min-width: 200px;
overflow: auto;
position: fixed;
......@@ -41,9 +39,13 @@ a.hidden {
}
#toc {
height: 70%;
flex-shrink: 0;
height: 50%;
max-height: 90%;
min-height: 10%;
outline: 1px solid black;
overflow: auto;
resize: vertical;
}
#toc h1 {
......@@ -68,7 +70,7 @@ a.hidden {
}
#search {
height: 30%;
flex-grow: 1;
overflow: auto;
}
......
......@@ -54,14 +54,6 @@ function highlightCallback(span, cls, str) {
}
(function(){
/* Resizable sidebar */
let sidebar = document.getElementById('sidebar');
sidebar.onmouseup = function () { /* not every browser supports onresize on div */
let content = document.getElementById('content');
content.style.left = this.offsetWidth + 'px';
};
sidebar.onmouseup();
/* Collapsable */
let collapsables = document.getElementsByClassName('collapsable');
for (let i = 0; i < collapsables.length; i++) {
......@@ -147,6 +139,19 @@ function highlightCallback(span, cls, str) {
}
};
/* Resizable sidebar */
let sidebar = document.getElementById('sidebar');
sidebar.onmouseup = function () { /* not every browser supports onresize on div */
let content = document.getElementById('content');
content.style.left = this.offsetWidth + 'px';
sessionStorage['sidebar-width'] = this.offsetWidth;
};
let toc = document.getElementById('toc');
toc.onmouseup = function () {
sessionStorage['toc-height'] = this.offsetHeight;
};
let savedScrollDivs = ['toc', 'search'];
for (let i in savedScrollDivs) {
let elem = document.getElementById(savedScrollDivs[i]);
......@@ -171,10 +176,17 @@ function highlightCallback(span, cls, str) {
}
if (typeof sessionStorage['scrollTop-toc'] == 'undefined') {
var toc = document.getElementById('toc');
var active = toc.querySelector('.active');
let toc = document.getElementById('toc');
let active = toc.querySelector('.active');
if (active != null)
toc.scrollTop = active.offsetTop - 50;
}
if (typeof sessionStorage['sidebar-width'] != 'undefined')
sidebar.style.width = sessionStorage['sidebar-width'] + 'px';
sidebar.onmouseup();
if (typeof sessionStorage['toc-height'] != 'undefined')
toc.style.height = sessionStorage['toc-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