Skip to content

Commit 1219494

Browse files
Rollup merge of #46861 - GuillaumeGomez:fix-ios-sidebar, r=QuietMisdreavus
Fix sidebar on ios r? @QuietMisdreavus
2 parents 2770fdf + 7f5c2f9 commit 1219494

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed

src/librustdoc/html/static/main.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,32 @@
109109
function showSidebar() {
110110
var elems = document.getElementsByClassName("sidebar-elems")[0];
111111
if (elems) {
112-
elems.style.display = "block";
112+
addClass(elems, "show-it");
113113
}
114114
var sidebar = document.getElementsByClassName('sidebar')[0];
115-
sidebar.style.position = 'fixed';
116-
sidebar.style.width = '100%';
117-
sidebar.style.marginLeft = '0';
115+
if (sidebar) {
116+
addClass(sidebar, 'mobile');
117+
var filler = document.getElementById("sidebar-filler");
118+
if (!filler) {
119+
var div = document.createElement("div");
120+
div.id = "sidebar-filler";
121+
sidebar.appendChild(div);
122+
}
123+
}
118124
document.getElementsByTagName("body")[0].style.marginTop = '45px';
119125
}
120126

121127
function hideSidebar() {
122128
var elems = document.getElementsByClassName("sidebar-elems")[0];
123129
if (elems) {
124-
elems.style.display = "";
130+
removeClass(elems, "show-it");
125131
}
126132
var sidebar = document.getElementsByClassName('sidebar')[0];
127-
sidebar.style.position = '';
128-
sidebar.style.width = '';
129-
sidebar.style.marginLeft = '';
133+
removeClass(sidebar, 'mobile');
134+
var filler = document.getElementById("sidebar-filler");
135+
if (filler) {
136+
filler.remove();
137+
}
130138
document.getElementsByTagName("body")[0].style.marginTop = '';
131139
}
132140

@@ -1859,7 +1867,7 @@
18591867
if (sidebar_menu) {
18601868
sidebar_menu.onclick = function() {
18611869
var sidebar = document.getElementsByClassName('sidebar')[0];
1862-
if (sidebar.style.position === "fixed") {
1870+
if (hasClass(sidebar, "mobile") === true) {
18631871
hideSidebar();
18641872
} else {
18651873
showSidebar();

src/librustdoc/html/static/rustdoc.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,33 @@ h4 > .important-traits {
10201020
#titles {
10211021
height: 50px;
10221022
}
1023+
1024+
.sidebar.mobile {
1025+
position: fixed;
1026+
width: 100%;
1027+
margin-left: 0;
1028+
background-color: rgba(0,0,0,0);
1029+
height: 100%;
1030+
}
1031+
1032+
.show-it {
1033+
display: block;
1034+
}
1035+
1036+
/* Because of ios, we need to actually have a full height sidebar title so the
1037+
* actual sidebar can show up. But then we need to make it transparent so we don't
1038+
* hide content. The filler just allows to create the background for the sidebar
1039+
* title. But because of the absolute position, I had to lower the z-index.
1040+
*/
1041+
#sidebar-filler {
1042+
position: fixed;
1043+
left: 45px;
1044+
width: calc(100% - 45px);
1045+
top: 0;
1046+
height: 45px;
1047+
z-index: -1;
1048+
border-bottom: 1px solid;
1049+
}
10231050
}
10241051

10251052

src/librustdoc/html/static/styles/main.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ a.test-arrow {
191191

192192
#help > div {
193193
background: #e9e9e9;
194-
border-color: #bfbfbf;;
194+
border-color: #bfbfbf;
195195
}
196196

197197
#help dt {
@@ -342,4 +342,9 @@ pre.ignore:hover, .information:hover + pre.ignore {
342342
background-color: #F1F1F1;
343343
border-right-color: #000;
344344
}
345+
346+
#sidebar-filler {
347+
background-color: #F1F1F1;
348+
border-bottom-color: #e0e0e0;
349+
}
345350
}

0 commit comments

Comments
 (0)