Source sidebar improvements
This commit is contained in:
parent
93520d2ad1
commit
e87f8cc49b
5 changed files with 86 additions and 60 deletions
|
|
@ -1464,25 +1464,28 @@ kbd {
|
|||
#sidebar-toggle {
|
||||
position: fixed;
|
||||
top: 30px;
|
||||
right: 300px;
|
||||
left: 300px;
|
||||
z-index: 10;
|
||||
padding: 3px;
|
||||
border-top-left-radius: 3px;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
transition: right 1s;
|
||||
transition: left .5s;
|
||||
font-size: 1.2em;
|
||||
border: 1px solid;
|
||||
border-left: 0;
|
||||
}
|
||||
#source-sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
width: 300px;
|
||||
z-index: 1;
|
||||
overflow: auto;
|
||||
transition: right 1s;
|
||||
transition: left .5s;
|
||||
border-right: 1px solid;
|
||||
}
|
||||
#source-sidebar > .title {
|
||||
font-size: 1.5em;
|
||||
|
|
@ -1495,6 +1498,11 @@ div.children {
|
|||
padding-left: 27px;
|
||||
display: none;
|
||||
}
|
||||
div.name {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
margin-left: 16px;
|
||||
}
|
||||
div.files > a {
|
||||
display: block;
|
||||
padding: 0 3px;
|
||||
|
|
@ -1507,10 +1515,13 @@ div.name.expand + .children {
|
|||
}
|
||||
div.name::before {
|
||||
content: "\25B6";
|
||||
display: inline-block;
|
||||
padding-right: 4px;
|
||||
padding-left: 4px;
|
||||
font-size: 0.7em;
|
||||
position: absolute;
|
||||
left: -16px;
|
||||
top: 4px;
|
||||
}
|
||||
div.name.expand::before {
|
||||
transform: rotate(90deg);
|
||||
left: -14px;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,21 +72,21 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
|
|||
children.appendChild(files);
|
||||
parent.appendChild(name);
|
||||
parent.appendChild(children);
|
||||
return hasFoundFile === true && search.currentFile !== null;
|
||||
return hasFoundFile === true && currentFile.startsWith(fullPath);
|
||||
}
|
||||
|
||||
function toggleSidebar() {
|
||||
var sidebar = document.getElementById("source-sidebar");
|
||||
var child = this.children[0].children[0];
|
||||
if (child.innerText === "<") {
|
||||
sidebar.style.right = "";
|
||||
this.style.right = "";
|
||||
child.innerText = ">";
|
||||
if (child.innerText === ">") {
|
||||
sidebar.style.left = "";
|
||||
this.style.left = "";
|
||||
child.innerText = "<";
|
||||
updateLocalStorage("rustdoc-source-sidebar-hidden", "false");
|
||||
} else {
|
||||
sidebar.style.right = "-300px";
|
||||
this.style.right = "0";
|
||||
child.innerText = "<";
|
||||
sidebar.style.left = "-300px";
|
||||
this.style.left = "0";
|
||||
child.innerText = ">";
|
||||
updateLocalStorage("rustdoc-source-sidebar-hidden", "true");
|
||||
}
|
||||
}
|
||||
|
|
@ -102,10 +102,10 @@ function createSidebarToggle() {
|
|||
var inner2 = document.createElement("div");
|
||||
inner2.style.marginTop = "-2px";
|
||||
if (getCurrentValue("rustdoc-source-sidebar-hidden") === "true") {
|
||||
inner2.innerText = "<";
|
||||
sidebarToggle.style.right = "0";
|
||||
} else {
|
||||
inner2.innerText = ">";
|
||||
sidebarToggle.style.left = "0";
|
||||
} else {
|
||||
inner2.innerText = "<";
|
||||
}
|
||||
|
||||
inner1.appendChild(inner2);
|
||||
|
|
@ -125,7 +125,7 @@ function createSourceSidebar() {
|
|||
var sidebar = document.createElement("div");
|
||||
sidebar.id = "source-sidebar";
|
||||
if (getCurrentValue("rustdoc-source-sidebar-hidden") === "true") {
|
||||
sidebar.style.right = "-300px";
|
||||
sidebar.style.left = "-300px";
|
||||
}
|
||||
|
||||
var currentFile = getCurrentFilePath();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue