diff options
Diffstat (limited to 'src/librustdoc/html/static/main.js')
| -rw-r--r-- | src/librustdoc/html/static/main.js | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 1de4b0016c5..ec8024ffca5 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -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; @@ -667,13 +663,7 @@ function defocusSearchBar() { results = {}, results_in_args = {}, results_returned = {}, split = valLower.split("::"); - var length = split.length; - for (var z = 0; z < length; ++z) { - if (split[z] === "") { - split.splice(z, 1); - z -= 1; - } - } + split = split.filter(function(segment) { return segment !== ""; }); function transformResults(results, isType) { var out = []; @@ -2157,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\">" + @@ -2553,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; |
