Skip to content

Modified document body to adjust left margin according to toggling on off of side bar in docs. #88301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ function hideThemeButtonState() {
if (search === null || typeof search === 'undefined') {
search = searchState.outputElement();
}
if (getCurrentValue("rustdoc-source-sidebar-show") === "true"){
var logo = document.getElementsByClassName("sidebar")[0];
document.body.style.left = "0px";
logo.style.left = "0px";
}
addClass(main, "hidden");
removeClass(search, "hidden");
searchState.mouseMovedAfterSearch = false;
Expand All @@ -199,6 +204,11 @@ function hideThemeButtonState() {
if (search === null || typeof search === 'undefined') {
search = searchState.outputElement();
}
if (getCurrentValue("rustdoc-source-sidebar-show") === "true"){
var logo = document.getElementsByClassName("sidebar")[0];
document.body.style.left = "300px";
logo.style.left = "300px";
}
addClass(search, "hidden");
removeClass(main, "hidden");
document.title = searchState.titleBeforeSearch;
Expand Down
12 changes: 12 additions & 0 deletions src/librustdoc/html/static/js/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,23 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {

function toggleSidebar() {
var sidebar = document.getElementById("source-sidebar");
var logo = document.getElementsByClassName("sidebar")[0];
document.body.style.transition = "left 0.5s ease 0s";
logo.style.transition = "left 0.5s ease 0s";
var child = this.children[0].children[0];
if (child.innerText === ">") {
sidebar.style.left = "";
this.style.left = "";
child.innerText = "<";
logo.style.left = "300px";
document.body.style.left = "300px";
updateLocalStorage("rustdoc-source-sidebar-show", "true");
} else {
sidebar.style.left = "-300px";
this.style.left = "0";
child.innerText = ">";
logo.style.left = "0px";
document.body.style.left = "0px";
updateLocalStorage("rustdoc-source-sidebar-show", "false");
}
}
Expand All @@ -97,16 +104,21 @@ function createSidebarToggle() {
sidebarToggle.id = "sidebar-toggle";
sidebarToggle.onclick = toggleSidebar;

var logo = document.getElementsByClassName("sidebar")[0];
var inner1 = document.createElement("div");
inner1.style.position = "relative";

var inner2 = document.createElement("div");
inner2.style.paddingTop = "3px";
if (getCurrentValue("rustdoc-source-sidebar-show") === "true") {
inner2.innerText = "<";
logo.style.left = "300px";
document.body.style.left ='300px';
} else {
inner2.innerText = ">";
sidebarToggle.style.left = "0";
logo.style.left = "0px";
document.body.style.left ="0px";
}

inner1.appendChild(inner2);
Expand Down