Skip to content

Commit

Permalink
rustdoc: use functions instead of unnecessary arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Sep 11, 2023
1 parent 9b81a2a commit 01756e2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
return;
}
const isSrcPage = hasClass(document.body, "src");
const hideSidebar = () => {
function hideSidebar() {
if (isSrcPage) {
window.rustdocCloseSourceSidebar();
updateLocalStorage("src-sidebar-width", null);
Expand All @@ -1257,30 +1257,30 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
updateLocalStorage("desktop-sidebar-width", null);
document.documentElement.style.removeProperty("--desktop-sidebar-width");
}
};
const showSidebar = () => {
}
function showSidebar() {
if (isSrcPage) {
window.rustdocShowSourceSidebar();
} else {
removeClass(document.documentElement, "hide-sidebar");
updateLocalStorage("hide-sidebar", "false");
}
};
const changeSidebarSize = size => {
}
function changeSidebarSize(size) {
if (isSrcPage) {
updateLocalStorage("src-sidebar-width", size);
document.documentElement.style.setProperty("--src-sidebar-width", size + "px");
} else {
updateLocalStorage("desktop-sidebar-width", size);
document.documentElement.style.setProperty("--desktop-sidebar-width", size + "px");
}
};
const isSidebarHidden = () => {
}
function isSidebarHidden() {
return isSrcPage ?
!hasClass(document.documentElement, "src-sidebar-expanded") :
hasClass(document.documentElement, "hide-sidebar");
};
const resize = e => {
}
function resize(e) {
if (currentPointerId === null || currentPointerId !== e.pointerId) {
return;
}
Expand All @@ -1296,8 +1296,8 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
}
changeSidebarSize(Math.min(pos, window.innerWidth - 100));
}
};
const stopResize = e => {
}
function stopResize(e) {
if (currentPointerId === null) {
return;
}
Expand All @@ -1310,8 +1310,8 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
resizer.releasePointerCapture(currentPointerId);
currentPointerId = null;
}
};
const initResize = e => {
}
function initResize(e) {
if (currentPointerId !== null || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) {
return;
}
Expand All @@ -1331,7 +1331,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
window.addEventListener("pointerup", stopResize, false);
addClass(resizer, "active");
addClass(document.documentElement, "sidebar-resizing");
};
}
resizer.addEventListener("pointerdown", initResize, false);
}());

Expand Down

0 comments on commit 01756e2

Please sign in to comment.