Auto merge of #80554 - GuillaumeGomez:more-js-cleanup, r=jyn514
More js cleanup Part of #79052 (Same kind as #80515). This one is about some small fixes: * Replacing some loops with `onEachLazy`. * Removing unused function arguments. * Turn `buildHelperPopup` into a variable so it can be "replaced" once the function has been called once so it's not called again. r? `@jyn514`
This commit is contained in:
commit
0cd459fd62
@ -493,11 +493,7 @@ function defocusSearchBar() {
|
|||||||
document.addEventListener("keypress", handleShortcut);
|
document.addEventListener("keypress", handleShortcut);
|
||||||
document.addEventListener("keydown", handleShortcut);
|
document.addEventListener("keydown", handleShortcut);
|
||||||
|
|
||||||
function resetMouseMoved(ev) {
|
document.addEventListener("mousemove", function() { mouseMovedAfterSearch = true; });
|
||||||
mouseMovedAfterSearch = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("mousemove", resetMouseMoved);
|
|
||||||
|
|
||||||
var handleSourceHighlight = (function() {
|
var handleSourceHighlight = (function() {
|
||||||
var prev_line_id = 0;
|
var prev_line_id = 0;
|
||||||
@ -2151,14 +2147,14 @@ function defocusSearchBar() {
|
|||||||
var code = document.createElement("code");
|
var code = document.createElement("code");
|
||||||
code.innerHTML = struct.text;
|
code.innerHTML = struct.text;
|
||||||
|
|
||||||
var x = code.getElementsByTagName("a");
|
onEachLazy(code.getElementsByTagName("a"), function(elem) {
|
||||||
var xlength = x.length;
|
var href = elem.getAttribute("href");
|
||||||
for (var it = 0; it < xlength; it++) {
|
|
||||||
var href = x[it].getAttribute("href");
|
|
||||||
if (href && href.indexOf("http") !== 0) {
|
if (href && href.indexOf("http") !== 0) {
|
||||||
x[it].setAttribute("href", rootPath + href);
|
elem.setAttribute("href", rootPath + href);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var display = document.createElement("h3");
|
var display = document.createElement("h3");
|
||||||
addClass(display, "impl");
|
addClass(display, "impl");
|
||||||
display.innerHTML = "<span class=\"in-band\"><table class=\"table-display\">" +
|
display.innerHTML = "<span class=\"in-band\"><table class=\"table-display\">" +
|
||||||
@ -2547,14 +2543,12 @@ function defocusSearchBar() {
|
|||||||
var hiddenElems = e.getElementsByClassName("hidden");
|
var hiddenElems = e.getElementsByClassName("hidden");
|
||||||
var needToggle = false;
|
var needToggle = false;
|
||||||
|
|
||||||
var hlength = hiddenElems.length;
|
var needToggle = onEachLazy(e.getElementsByClassName("hidden"), function(hiddenElem) {
|
||||||
for (var i = 0; i < hlength; ++i) {
|
if (hasClass(hiddenElem, "content") === false &&
|
||||||
if (hasClass(hiddenElems[i], "content") === false &&
|
hasClass(hiddenElem, "docblock") === false) {
|
||||||
hasClass(hiddenElems[i], "docblock") === false) {
|
return true;
|
||||||
needToggle = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (needToggle === true) {
|
if (needToggle === true) {
|
||||||
var inner_toggle = newToggle.cloneNode(true);
|
var inner_toggle = newToggle.cloneNode(true);
|
||||||
inner_toggle.onclick = toggleClicked;
|
inner_toggle.onclick = toggleClicked;
|
||||||
|
Loading…
Reference in New Issue
Block a user