Skip to content

Commit 29e3639

Browse files
committed
fix merge
1 parent 2bd9bca commit 29e3639

File tree

1 file changed

+32
-87
lines changed
  • scaladoc/resources/dotty_res/scripts

1 file changed

+32
-87
lines changed

scaladoc/resources/dotty_res/scripts/ux.js

Lines changed: 32 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -6,88 +6,47 @@ function attachAllListeners() {
66
}
77

88
var scrollPosition = sessionStorage.getItem("scroll_value");
9-
console.log(scrollPosition);
109
if (scrollPosition) {
1110
var sideMenu = document.querySelector(".side-menu");
1211
sideMenu.scrollTo(0, scrollPosition);
1312
}
1413

15-
var elements = document.getElementsByClassName("documentableElement");
14+
var elements = document.getElementsByClassName("documentableElement")
1615
if (elements) {
1716
for (i = 0; i < elements.length; i++) {
18-
var expanderChild = elements[i].querySelector(
19-
".documentableElement-expander",
20-
);
21-
if (
22-
elements[i].querySelector(".show-content") !== null &&
23-
expanderChild !== null
24-
) {
17+
var expanderChild = elements[i].querySelector(".documentableElement-expander")
18+
if (elements[i].querySelector(".show-content") !== null && expanderChild !== null) {
2519
expanderChild.onclick = function (e) {
2620
if (!$(e.target).is("a") && e.fromSnippet !== true) {
27-
this.parentElement.classList.toggle("expand");
28-
this.querySelector(".show-content").classList.toggle("expand");
21+
this.parentElement.classList.toggle("expand")
22+
this.querySelector(".show-content").classList.toggle("expand")
2923
}
30-
};
24+
}
3125
}
3226
}
3327
}
3428

35-
var documentableLists = document.getElementsByClassName("documentableList");
29+
var documentableLists = document.getElementsByClassName("documentableList")
3630
if (documentableLists) {
3731
for (i = 0; i < documentableLists.length; i++) {
3832
documentableLists[i].children[0].onclick = function (e) {
3933
this.classList.toggle("expand");
4034
this.parentElement.classList.toggle("expand");
41-
};
35+
}
4236
}
4337
}
4438

45-
var memberLists = document.getElementsByClassName("tab");
39+
var memberLists = document.getElementsByClassName("tab")
4640
if (memberLists) {
4741
for (i = 0; i < memberLists.length; i++) {
4842
if ($(memberLists[i].children[0]).is("button")) {
4943
memberLists[i].children[0].onclick = function (e) {
5044
this.classList.toggle("expand");
5145
this.parentElement.classList.toggle("expand");
52-
};
46+
}
5347
}
5448
}
5549
}
56-
$(".side-menu span").on("click", function () {
57-
$(this).parent().toggleClass("expanded");
58-
});
59-
document.querySelectorAll('a').forEach(el => {
60-
const href = el.href
61-
if (href === "") { return }
62-
const url = new URL(href)
63-
el.addEventListener('click', e => {
64-
if (url.href.replace("#", "") === window.location.href.replace("#", "")) { return }
65-
if (url.origin !== window.location.origin) { return }
66-
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) { return }
67-
e.preventDefault()
68-
e.stopPropagation()
69-
$.get(href, function (data) {
70-
const html = $.parseHTML(data)
71-
const title = html.find(node => node.nodeName === "TITLE").innerText
72-
const bodyDiv = html.find(node => node.nodeName === "DIV")
73-
const { children } = document.body.firstChild
74-
if (window.history.state === null) {
75-
window.history.replaceState({
76-
leftColumn: children[3].innerHTML,
77-
mainDiv: children[6].innerHTML,
78-
title: document.title,
79-
}, '')
80-
}
81-
document.title = title
82-
const leftColumn = bodyDiv.children[3].innerHTML
83-
const mainDiv = bodyDiv.children[6].innerHTML
84-
window.history.pushState({ leftColumn, mainDiv, title }, '', href)
85-
children[3].innerHTML = leftColumn
86-
children[6].innerHTML = mainDiv
87-
attachAllListeners()
88-
})
89-
})
90-
})
9150

9251
document.querySelectorAll('a').forEach(el => {
9352
const href = el.href
@@ -122,10 +81,10 @@ function attachAllListeners() {
12281
})
12382
})
12483

125-
$(".ar").on("click", function (e) {
126-
$(this).parent().parent().toggleClass("expanded");
127-
$(this).toggleClass("expanded");
128-
e.stopPropagation();
84+
$(".ar").on('click', function (e) {
85+
$(this).parent().parent().toggleClass("expanded")
86+
$(this).toggleClass("expanded")
87+
e.stopPropagation()
12988
});
13089

13190
document.querySelectorAll(".nh").forEach(el => el.addEventListener('click', () => {
@@ -137,38 +96,24 @@ function attachAllListeners() {
13796
}
13897
}))
13998

140-
document.querySelectorAll(".supertypes").forEach((el) =>
141-
el.firstChild.addEventListener("click", () => {
142-
el.classList.toggle("collapsed");
143-
el.firstChild.classList.toggle("expand");
144-
}),
145-
);
146-
147-
document.querySelectorAll(".subtypes").forEach((el) =>
148-
el.firstChild.addEventListener("click", () => {
149-
el.classList.toggle("collapsed");
150-
el.firstChild.classList.toggle("expand");
151-
}),
152-
);
153-
154-
document.querySelectorAll(".nh").forEach((el) =>
155-
el.addEventListener("click", () => {
156-
el.lastChild.click();
157-
el.first.addClass("expanded");
158-
el.parent.addClass("expanded");
159-
}),
160-
);
161-
162-
document.querySelectorAll(".ni").forEach((link) =>
163-
link.addEventListener("mouseenter", (e) => {
164-
sessionStorage.setItem(
165-
"scroll_value",
166-
link.offsetTop - window.innerHeight / 2,
167-
);
168-
}),
169-
);
170-
171-
const observer = new IntersectionObserver(entries => {
99+
document.querySelectorAll(".supertypes").forEach(el => el.firstChild.addEventListener('click', () => {
100+
el.classList.toggle("collapsed");
101+
el.firstChild.classList.toggle("expand");
102+
}))
103+
104+
105+
document.querySelectorAll(".subtypes").forEach(el => el.firstChild.addEventListener('click', () => {
106+
el.classList.toggle("collapsed");
107+
el.firstChild.classList.toggle("expand");
108+
}))
109+
110+
document.querySelectorAll(".ni").forEach(link =>
111+
link.addEventListener("mouseenter", _e => {
112+
sessionStorage.setItem("scroll_value", link.offsetTop - window.innerHeight / 2)
113+
})
114+
)
115+
116+
observer = new IntersectionObserver(entries => {
172117
entries.forEach(entry => {
173118
const id = entry.target.getAttribute('id');
174119
if (entry.intersectionRatio > 0) {

0 commit comments

Comments
 (0)