diff options
| author | bors <bors@rust-lang.org> | 2021-03-19 23:53:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-19 23:53:02 +0000 |
| commit | 6bfbf0c33a86707cedd02ca985285191282a80b3 (patch) | |
| tree | 3379b7c53a90fdbb23ef8c041ae4a8eb0b1955fe /src/librustdoc/html | |
| parent | f5f33ec0e0455eefa72fc5567eb1280a4d5ee206 (diff) | |
| parent | 51a29cbb23d2146322350fbfde53fe9523e554fb (diff) | |
| download | rust-6bfbf0c33a86707cedd02ca985285191282a80b3.tar.gz rust-6bfbf0c33a86707cedd02ca985285191282a80b3.zip | |
Auto merge of #83308 - Dylan-DPC:rollup-p2j6sy8, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #79986 (Only build help popup when it's really needed) - #82570 (Add `as_str` method for split whitespace str iterators) - #83244 (Fix overflowing length in Vec<ZST> to VecDeque) - #83254 (Include output stream in `panic!()` documentation) - #83269 (Revert the second deprecation of collections::Bound) - #83277 (Mark early otherwise optimization unsound) - #83285 (Update LLVM to bring in SIMD updates for WebAssembly) - #83297 (Do not ICE on ty::Error as an error must already have been reported) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/static/main.js | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index e7b522093c7..f1ecaaa619c 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1,3 +1,4 @@ +// ignore-tidy-filelength // Local js definitions: /* global addClass, getSettingValue, hasClass */ /* global onEach, onEachLazy, hasOwnProperty, removeClass, updateLocalStorage */ @@ -374,28 +375,35 @@ function defocusSearchBar() { } } - function getHelpElement() { - buildHelperPopup(); + function getHelpElement(build) { + if (build !== false) { + buildHelperPopup(); + } return document.getElementById("help"); } function displayHelp(display, ev, help) { - help = help ? help : getHelpElement(); if (display === true) { + help = help ? help : getHelpElement(true); if (hasClass(help, "hidden")) { ev.preventDefault(); removeClass(help, "hidden"); addClass(document.body, "blur"); } - } else if (hasClass(help, "hidden") === false) { - ev.preventDefault(); - addClass(help, "hidden"); - removeClass(document.body, "blur"); + } else { + // No need to build the help popup if we want to hide it in case it hasn't been + // built yet... + help = help ? help : getHelpElement(false); + if (help && hasClass(help, "hidden") === false) { + ev.preventDefault(); + addClass(help, "hidden"); + removeClass(document.body, "blur"); + } } } function handleEscape(ev) { - var help = getHelpElement(); + var help = getHelpElement(false); var search = getSearchElement(); if (hasClass(help, "hidden") === false) { displayHelp(false, ev, help); @@ -558,6 +566,7 @@ function defocusSearchBar() { }()); document.addEventListener("click", function(ev) { + var helpElem = getHelpElement(false); if (hasClass(ev.target, "help-button")) { displayHelp(true, ev); } else if (hasClass(ev.target, "collapse-toggle")) { @@ -566,11 +575,10 @@ function defocusSearchBar() { collapseDocs(ev.target.parentNode, "toggle"); } else if (ev.target.tagName === "SPAN" && hasClass(ev.target.parentNode, "line-numbers")) { handleSourceHighlight(ev); - } else if (hasClass(getHelpElement(), "hidden") === false) { - var help = getHelpElement(); - var is_inside_help_popup = ev.target !== help && help.contains(ev.target); + } else if (helpElem && hasClass(helpElem, "hidden") === false) { + var is_inside_help_popup = ev.target !== helpElem && helpElem.contains(ev.target); if (is_inside_help_popup === false) { - addClass(help, "hidden"); + addClass(helpElem, "hidden"); removeClass(document.body, "blur"); } } else { |
