rustdoc: simplify the codeblock tooltip
This commit moves the tooltip into example-wrap, simplifying allowing several
overly-complex things to be fixed:
* The mousover javascript can be removed, because hovering example-wrap can
style the tooltip inside.
* The sibling selecor can be removed, because hovering the tooltip also
hovers the wrapper, which can hover the codeblock itself.
* The relative positioning of the `<li>` tag, which was added in
e861efd9f9
to fix the positioning of the code
tooltip, can now be removed, because example-wrap itself already has
relative positioning.
This commit is contained in:
parent
f9da510cff
commit
cbcb74e939
6 changed files with 61 additions and 83 deletions
|
@ -699,9 +699,8 @@ function loadCss(cssFileName) {
|
|||
|
||||
(function() {
|
||||
// To avoid checking on "rustdoc-line-numbers" value on every loop...
|
||||
let lineNumbersFunc = () => {};
|
||||
if (getSettingValue("line-numbers") === "true") {
|
||||
lineNumbersFunc = x => {
|
||||
onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
|
||||
const count = x.textContent.split("\n").length;
|
||||
const elems = [];
|
||||
for (let i = 0; i < count; ++i) {
|
||||
|
@ -711,26 +710,8 @@ function loadCss(cssFileName) {
|
|||
addClass(node, "line-number");
|
||||
node.innerHTML = elems.join("\n");
|
||||
x.parentNode.insertBefore(node, x);
|
||||
};
|
||||
});
|
||||
}
|
||||
onEachLazy(document.getElementsByClassName("rust-example-rendered"), e => {
|
||||
if (hasClass(e, "compile_fail")) {
|
||||
e.addEventListener("mouseover", function() {
|
||||
this.parentElement.previousElementSibling.childNodes[0].style.color = "#f00";
|
||||
});
|
||||
e.addEventListener("mouseout", function() {
|
||||
this.parentElement.previousElementSibling.childNodes[0].style.color = "";
|
||||
});
|
||||
} else if (hasClass(e, "ignore")) {
|
||||
e.addEventListener("mouseover", function() {
|
||||
this.parentElement.previousElementSibling.childNodes[0].style.color = "#ff9200";
|
||||
});
|
||||
e.addEventListener("mouseout", function() {
|
||||
this.parentElement.previousElementSibling.childNodes[0].style.color = "";
|
||||
});
|
||||
}
|
||||
lineNumbersFunc(e);
|
||||
});
|
||||
}());
|
||||
|
||||
let oldSidebarScrollPosition = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue