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("keydown", handleShortcut);
|
||||
|
||||
function resetMouseMoved(ev) {
|
||||
mouseMovedAfterSearch = true;
|
||||
}
|
||||
|
||||
document.addEventListener("mousemove", resetMouseMoved);
|
||||
document.addEventListener("mousemove", function() { mouseMovedAfterSearch = true; });
|
||||
|
||||
var handleSourceHighlight = (function() {
|
||||
var prev_line_id = 0;
|
||||
@ -2151,14 +2147,14 @@ function defocusSearchBar() {
|
||||
var code = document.createElement("code");
|
||||
code.innerHTML = struct.text;
|
||||
|
||||
var x = code.getElementsByTagName("a");
|
||||
var xlength = x.length;
|
||||
for (var it = 0; it < xlength; it++) {
|
||||
var href = x[it].getAttribute("href");
|
||||
onEachLazy(code.getElementsByTagName("a"), function(elem) {
|
||||
var href = elem.getAttribute("href");
|
||||
|
||||
if (href && href.indexOf("http") !== 0) {
|
||||
x[it].setAttribute("href", rootPath + href);
|
||||
elem.setAttribute("href", rootPath + href);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var display = document.createElement("h3");
|
||||
addClass(display, "impl");
|
||||
display.innerHTML = "<span class=\"in-band\"><table class=\"table-display\">" +
|
||||
@ -2547,14 +2543,12 @@ function defocusSearchBar() {
|
||||
var hiddenElems = e.getElementsByClassName("hidden");
|
||||
var needToggle = false;
|
||||
|
||||
var hlength = hiddenElems.length;
|
||||
for (var i = 0; i < hlength; ++i) {
|
||||
if (hasClass(hiddenElems[i], "content") === false &&
|
||||
hasClass(hiddenElems[i], "docblock") === false) {
|
||||
needToggle = true;
|
||||
break;
|
||||
var needToggle = onEachLazy(e.getElementsByClassName("hidden"), function(hiddenElem) {
|
||||
if (hasClass(hiddenElem, "content") === false &&
|
||||
hasClass(hiddenElem, "docblock") === false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (needToggle === true) {
|
||||
var inner_toggle = newToggle.cloneNode(true);
|
||||
inner_toggle.onclick = toggleClicked;
|
||||
|
Loading…
Reference in New Issue
Block a user