about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/main.js
AgeCommit message (Collapse)AuthorLines
2023-09-13Merge settings.css into rustdoc.cssGuillaume Gomez-8/+0
2023-09-08Change syntax for anonymous functions setGuillaume Gomez-14/+14
2023-08-21rustdoc: Rename "Type Definition" to "Type Alias"Noah Lev-1/+1
This matches the name used by the Rust Reference [1], which is also what people usually call these items. [1]: https://doc.rust-lang.org/reference/items/type-aliases.html
2023-06-23Link to the corresponding channel in the help popoverGuillaume Gomez-5/+6
2023-06-23Add link to rustdoc book search chapter in help popoverGuillaume Gomez-0/+3
2023-06-16Fix invalid handling of "going back in history" when "Directly go to item in ↵Guillaume Gomez-3/+7
search if there is only one result" setting is set to true
2023-06-10rustdoc: add note about slice/array searches to help popupMichael Howell-0/+4
2023-05-31rustdoc: add jsdoc comments for complex functionsMichael Howell-1/+34
2023-05-23rustdoc: add interaction delays for tooltip popoversMichael Howell-9/+104
Designing a good hover microinteraction is a matter of guessing user intent from what are, literally, vague gestures. In this case, guessing if hovering in our out of the tooltip base is intentional or not. To figure this out, a few different techniques are used: * When the mouse pointer enters a tooltip anchor point, its hitbox is grown on the bottom, where the popover is/will appear. This was already there before this commit: search "hover tunnel" in rustdoc.css for the implementation. * This commit adds a delay when the mouse pointer enters the base anchor, in case the mouse pointer was just passing through and the user didn't want to open it. * This commit also adds a delay when the mouse pointer exits the tooltip's base anchor or its popover, before hiding it. * A fade-out animation is layered onto the pointer exit delay to immediately inform the user that they successfully dismissed the popover, while still providing a way for them to cancel it if it was a mistake and they still wanted to interact with it. * No animation is used for revealing it, because we don't want people to try to interact with an element while it's in the middle of fading in: either they're allowed to interact with it while it's fading in, meaning it can't serve as mistake- proofing for opening the popover, or they can't, but they might try and be frustrated. See also: * https://www.nngroup.com/articles/timing-exposing-content/ * https://www.nngroup.com/articles/tooltip-guidelines/ * https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown
2023-04-21rustdoc: clean up redundant search hiding results codeMichael Howell-4/+1
* There's no need to call `history.replaceState` right before calling `searchState.hideResults`, which already does it. * There's no need to implement hiding search results when that is already implemented.
2023-04-21rustdoc: use Set for ignored crates, instead of string matchingMichael Howell-2/+4
2023-04-15rustdoc: stop passing a title to `replaceState` second argumentMichael Howell-4/+2
As described on [MDN's replaceState page], this parameter is not currently used, and the empty string is "safe against future changes to the method." [MDN's replaceState page]: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
2023-04-12rustdoc: use CSS `overscroll-behavior` instead of JavaScriptMichael Howell-52/+0
Fixes the desktop scrolling weirdness mentioned in https://github.com/rust-lang/rust/pull/98775#issuecomment-1182575603 As described in the MDN page for this property: * The current Firefox ESR is 102, and the first Firefox version to support this feature is 59. * The current Chrome version 112, and the first version to support this is 63. * Edge is described as having a minor bug in `none` mode, but we use `contain` mode anyway, so it doesn't matter. * Safari 16, released September 2022, is the last browser to add this feature, and is also the oldest version we officially support.
2023-04-10rustdoc: remove redundant expandSection code from main.jsMichael Howell-14/+5
This functionality is already tested in `hash-item-expansion.goml`, and was implemented twice: * First, in code that ran at load time and at hash change: 917cdd295d2eed213c135d6f984c650f016ee3d6 * Later, the hash change event handler was itself run at load time, and the code handling both cases diverged in implementation, though their behavior still matches pretty well: f66a331335f3ac931afabca6f927a9d7dc17db3e
2023-04-06rustdoc: clean up JSMichael Howell-8/+2
* Stop checking `func` in `onEach`. It's always hard-coded right at the call site, so there's no point. * Use the ternary operator in a few spots where it makes sense. * No point in making `onEach` store `arr.length` in a variable if it's only used once anyway.
2023-03-31rustdoc-search: update docs for comma in `?` help popoverMichael Howell-3/+1
2023-03-23rustdoc: clean up `storage.js`Michael Howell-0/+5
This converts a few functions to more compact versions of themselves, and moves `RUSTDOC_MOBILE_BREAKPOINT` to main.js where it's actually used.
2023-03-08Only load one CSS theme by defaultMichael Howell-12/+27
To avoid generating a FOUC at startup, this commit uses `document.write` to load the stylesheet initially. Co-Authored-By: Guillaume Gomez <guillaume1.gomez@gmail.com>
2023-02-13Rollup merge of #107340 - notriddle:notriddle/simplify-doctest-tooltip, ↵Matthias Krüger-52/+60
r=GuillaumeGomez rustdoc: merge doctest tooltip with notable traits tooltip Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 <details><summary>a user report where the tooltip arrow overlaps the text</summary> ![](https://cdn.discordapp.com/attachments/443150878111694848/1066420139530145812/this-example-is-not-tested-busted-rendering.png) </details> Fixes #91100 Preview: <https://notriddle.com/notriddle-rustdoc-demos/simplify-doctest-tooltip/std/vec/struct.Vec.html#indexing> Screenshot: ![image](https://user-images.githubusercontent.com/1593513/214975516-72667632-4609-49fa-8c37-e8d2ba1ba7dc.png)
2023-02-11Rollup merge of #107490 - notriddle:notriddle/rm-sidebar-tooltip, ↵Dylan DPC-5/+1
r=GuillaumeGomez rustdoc: remove inconsistently-present sidebar tooltips Discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-01-31rustdoc: remove inconsistently-present sidebar tooltipsMichael Howell-5/+1
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-01-31Clean up eslint annotations and remove unused JS functionGuillaume Gomez-1/+0
2023-01-27rustdoc: remove inline javascript from copy-path buttonMichael Howell-1/+5
2023-01-27rustdoc: merge doctest tooltip with notable traits tooltipMichael Howell-52/+60
Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000 Fixes #91100
2023-01-18rustdoc: fix "?" keyboard command when radio button is focusedMichael Howell-1/+2
This extends the special case with checkbox settings to also cover radios.
2023-01-18rustdoc: put focus on the help link when opening it from keyboardMichael Howell-0/+3
This prevents some strange blur-event-related bugs with the "?" command by ensuring that the focus remains in the same spot when the settings area closes.
2023-01-17rustdoc: stop using deprecated `window.event` when there's an `ev` paramMichael Howell-1/+1
2023-01-17rustdoc: remove function `handleClick` that's only used onceMichael Howell-8/+3
2023-01-14Rollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, ↵Matthias Krüger-1/+1
r=GuillaumeGomez rustdoc: remove `docblock` class from notable trait popover This commit builds on b72de9be74dd5ac1d8b23d5ece03a7690274a14c, which removes the `docblock` class from the All Items page, and 9457380ac902db3febf92077c5b645db55998ad4, which removes the `docblock` class from the item decl. Fixes #92974
2023-01-14Rollup merge of #106819 - notriddle:notriddle/rm-h1-fqn, r=GuillaumeGomezYuki Okushi-1/+1
rustdoc: remove unnecessary DOM class `h1.fqn` It's misleading. The main heading sometimes isn't an fully qualified name at all. It's also redundant. It's always a child of `div.main-heading`, so just use that.
2023-01-13rustdoc: remove `docblock` class from notable trait popoverMichael Howell-1/+1
This commit builds on b72de9be74dd5ac1d8b23d5ece03a7690274a14c, which removes the `docblock` class from the All Items page, and 9457380ac902db3febf92077c5b645db55998ad4, which removes the `docblock` class from the item decl. Fixes #92974
2023-01-13rustdoc: rename CSS rustdoc-toggle -> toggle and toggle -> settings-toggleMichael Howell-4/+4
This swaps things around so that the class that gets used more often has the shorter name.
2023-01-13rustdoc: remove unnecessary DOM class `h1.fqn`Michael Howell-1/+1
It's misleading. The main heading sometimes isn't an fully qualified name at all. It's also redundant. It's always a child of `div.main-heading`, so just use that.
2023-01-04Rollup merge of #106437 - notriddle:notriddle/http-url, r=GuillaumeGomezMatthias Krüger-1/+1
rustdoc: fix buggy JS check for absolute URL The old code did the wrong thing when faced with a crate named "http".
2023-01-03rustdoc: fix buggy JS check for absolute URLMichael Howell-1/+1
The old code did the wrong thing when faced with a crate named "http".
2023-01-02rustdoc: allow popover child links to workArdis Lu-3/+0
No need to prevent default click behavior on a <div>, it will also disable all child click behavior.
2022-12-21rustdoc: simplify link anchor to section expand JSMichael Howell-7/+5
2022-12-12rustdoc: remove `type="text/css" from stylesheet linksMichael Howell-1/+0
MDN directly recommends this in <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link>, since "CSS is the only stylesheet language used on the web." Like 07a243b2a46384235d7e2c08688978b7cf018973, but a few places that were missed the first time.
2022-12-07Improve several aspects of the Rustdoc scrape-examples UI.Will Crichton-1/+1
* Examples take up less screen height. * Snippets from binary crates are prioritized. * toggle-all-docs does not expand "More examples" sections.
2022-11-28Add sentence when rustdoc search is runningGuillaume Gomez-4/+6
2022-11-26rustdoc: pass "true" to reset focus for notable traitsMichael Howell-11/+7
2022-11-26rustdoc: improve popover focus handling JSMichael Howell-4/+20
This commit fixes a few inconsistencies and erratic behavior from the notable traits, settings, and sidebar popups: * It makes it so that pressing Escape closes the mobile sidebar. This is a bit difficult to do on iPhone, but on other setups like desktop tiling window managers, it's easy and makes sense. * It makes sure that pressing escape while a notable trait popover is open focuses the popover's toggle button, instead of leaving nothing focused, since that makes more sense with keyboard navigation. Clicking the settings, help, or sidebar buttons, however, will not focus the notable trait popover toggle button. * It ensures that notable trait and settings popovers are exclusive with the mobile sidebar. Nothing should ever overlap a popover, and there should never be more than one popover open at once.
2022-11-20Rollup merge of #104581 - notriddle:notriddle/js-iife-2, r=GuillaumeGomezMatthias Krüger-6/+3
rustdoc: remove unused JS IIFE from main.js This [IIFE] made sense when it was added in deaf5e200e79a75ac57d3f0952f6758a38168e52 and there was a local variable scoped to it, but now it calls a function, but declares nothing. [IIFE]: https://developer.mozilla.org/en-US/docs/Glossary/IIFE "immediately invoked function expression"
2022-11-19Fix invalid focus when blurring notable traits popoverGuillaume Gomez-8/+11
2022-11-18rustdoc: remove unused JS IIFE from main.jsMichael Howell-6/+3
This [IIFE] made sense when it was added in deaf5e200e79a75ac57d3f0952f6758a38168e52 and there was a local variable scoped to it, but now it calls a function, but declares nothing. [IIFE]: https://developer.mozilla.org/en-US/docs/Glossary/IIFE "immediately invoked function expression"
2022-11-18Don't focus on notable trait parent when hiding itGuillaume Gomez-1/+0
2022-11-15rustdoc: remove unused JS IIFE from main.jsMichael Howell-4/+2
This [IIFE] made sense when it was added in f0683f98fa114cc4f9e795031f44be3eebb65790 and there was a local variable scoped to it, but now it only sets two globals, so it does nothing. [IIFE]: https://developer.mozilla.org/en-US/docs/Glossary/IIFE "immediately invoked function expression"
2022-11-11rustdoc: make notable traits popover behavior consistent with Help and SettingsMichael Howell-1/+9
2022-11-11rustdoc: use consistent "popover" styling for notable traitsMichael Howell-9/+43
2022-11-07rustdoc: fix font color inheritance from body, and testMichael Howell-2/+4