Skip to content

Commit 67a43b0

Browse files
committed
Fix nav resize and nav link selection
1 parent 725f8ef commit 67a43b0

File tree

3 files changed

+47
-38
lines changed

3 files changed

+47
-38
lines changed

templates/default/fulldoc/html/css/style.css

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ body {
99
margin: 0;
1010
padding: 0;
1111
display: flex;
12-
display: -webkit-flex;
13-
display: -ms-flexbox;
1412
}
1513

1614
#nav {
@@ -28,11 +26,7 @@ body {
2826
height: 100%;
2927
position: relative;
3028
display: flex;
31-
display: -webkit-flex;
32-
display: -ms-flexbox;
3329
flex-shrink: 0;
34-
-webkit-flex-shrink: 0;
35-
-ms-flex: 1 0;
3630
}
3731
#resizer {
3832
position: absolute;
@@ -45,8 +39,6 @@ body {
4539
}
4640
#main {
4741
flex: 5 1;
48-
-webkit-flex: 5 1;
49-
-ms-flex: 5 1;
5042
outline: none;
5143
position: relative;
5244
background: #fff;
@@ -56,7 +48,8 @@ body {
5648
}
5749

5850
@media (max-width: 920px) {
59-
.nav_wrap { width: 100%; top: 0; right: 0; overflow: visible; position: absolute; }
51+
body { display: block; }
52+
.nav_wrap { width: 80vw !important; top: 0; right: 0; overflow: visible; position: absolute; }
6053
#resizer { display: none; }
6154
#nav {
6255
z-index: 9999;
@@ -205,13 +198,9 @@ p.inherited {
205198
width: 100%;
206199
font-size: 1em;
207200
display: flex;
208-
display: -webkit-flex;
209-
display: -ms-flexbox;
210201
}
211202
.box_info dl dt {
212203
flex-shrink: 0;
213-
-webkit-flex-shrink: 1;
214-
-ms-flex-shrink: 1;
215204
width: 100px;
216205
text-align: right;
217206
font-weight: bold;
@@ -222,8 +211,6 @@ p.inherited {
222211
}
223212
.box_info dl dd {
224213
flex-grow: 1;
225-
-webkit-flex-grow: 1;
226-
-ms-flex: 1;
227214
max-width: 420px;
228215
padding: 6px 0;
229216
padding-right: 20px;

templates/default/fulldoc/html/js/app.js

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function () {
1+
window.__app = function () {
22
var localStorage = {},
33
sessionStorage = {};
44
try {
@@ -277,17 +277,18 @@
277277
}
278278

279279
sessionStorage.navWidth = e.pageX.toString();
280-
$(".nav_wrap").css("width", e.pageX);
281-
$(".nav_wrap").css("-ms-flex", "inherit");
280+
$(".nav_wrap").css("width", Math.max(200, e.pageX));
282281
e.preventDefault();
283282
e.stopPropagation();
284283
},
285284
false
286285
);
287286

288287
if (sessionStorage.navWidth) {
289-
$(".nav_wrap").css("width", parseInt(sessionStorage.navWidth, 10));
290-
$(".nav_wrap").css("-ms-flex", "inherit");
288+
$(".nav_wrap").css(
289+
"width",
290+
Math.max(200, parseInt(sessionStorage.navWidth, 10))
291+
);
291292
}
292293
}
293294

@@ -326,23 +327,36 @@
326327

327328
window.addEventListener(
328329
"message",
329-
function (e) {
330+
async (e) => {
330331
if (e.data.action === "navigate") {
331-
fetch(e.data.url)
332-
.then((response) => response.text())
333-
.then((text) => {
334-
const parser = new DOMParser();
335-
const doc = parser.parseFromString(text, "text/html");
336-
document.title = doc.querySelector("head title").innerText;
337-
const content = doc.querySelector("#main").innerHTML;
338-
document.querySelector("#main").innerHTML = content;
339-
const url = new URL(e.data.url, "https://localhost");
340-
const hash = decodeURIComponent(url.hash ?? "");
341-
if (hash) {
342-
document.getElementById(hash.substring(1)).scrollIntoView();
343-
}
344-
history.pushState({}, document.title, e.data.url);
345-
});
332+
const response = await fetch(e.data.url);
333+
const text = await response.text();
334+
const parser = new DOMParser();
335+
const doc = parser.parseFromString(text, "text/html");
336+
337+
const classListLink =
338+
document.getElementById("class_list_link").classList;
339+
340+
document.documentElement.replaceChild(doc.head, document.head);
341+
const content = doc.querySelector("#main").innerHTML;
342+
document.querySelector("#main").innerHTML = content;
343+
344+
document.head.querySelectorAll("script").forEach((script) => {
345+
const newScript = document.createElement("script");
346+
newScript.textContent = script.textContent;
347+
script.parentNode.replaceChild(newScript, script);
348+
});
349+
350+
window.__app();
351+
352+
document.getElementById("class_list_link").classList = classListLink;
353+
354+
const url = new URL(e.data.url, "https://localhost");
355+
const hash = decodeURIComponent(url.hash ?? "");
356+
if (hash) {
357+
document.getElementById(hash.substring(1)).scrollIntoView();
358+
}
359+
history.pushState({}, document.title, e.data.url);
346360
}
347361
},
348362
false
@@ -363,4 +377,5 @@
363377
mainFocus();
364378
navigationChange();
365379
});
366-
})();
380+
};
381+
window.__app();

templates/default/fulldoc/html/js/full_list.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ function highlight() {
195195
});
196196
}
197197

198+
function isInView(element) {
199+
const rect = element.getBoundingClientRect();
200+
const windowHeight =
201+
window.innerHeight || document.documentElement.clientHeight;
202+
return rect.left >= 0 && rect.bottom <= windowHeight;
203+
}
204+
198205
/**
199206
* Expands the tree to the target element and its immediate
200207
* children.
@@ -210,7 +217,7 @@ function expandTo(path) {
210217
$(el).find('> div > a.toggle').attr('aria-expanded', 'true');
211218
});
212219

213-
if($target[0]) {
220+
if($target[0] && !isInView($target[0])) {
214221
window.scrollTo(window.scrollX, $target.offset().top - 250);
215222
highlight();
216223
}

0 commit comments

Comments
 (0)