about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/main.js
AgeCommit message (Collapse)AuthorLines
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
2022-11-07rustdoc: use javascript to layout notable traits popupsMichael Howell-2/+83
Fixes #102576
2022-10-29rustdoc: add hash to filename of toolchain filesJacob Hoffman-Andrews-5/+5
All static files used by rustdoc are now stored in static.files/ and include a hash of their contents. They no longer include the contents of the --resource-suffix flag. This clarifies caching semantics. Anything in static.files can use Cache-Control: immutable because any updates will show up as a new URL. Invocation-specific files like crates-NN.js, search-index-NN.js, and sidebar-items-NN.js still get the resource suffix. The --disable-minification flag is removed because it would vary the output of static files based on invocation flags. Instead, for rustdoc development purposes it's preferable to symlink static files to a non-minified copy for quick iteration.
2022-10-27rustdoc: remove redundant `div.search-container`Michael Howell-1/+1
This wrapper DIV was originally added in 89e1fb322321c05497caa01372ceb7d5b57fa680, when it allowed the search bar's size to be calculated without using `calc()`. This `width` hack can be removed using flexbox.
2022-10-20+/- shortcut now only expand/collapse, not bothGuillaume Gomez-29/+30
2022-10-19Rollup merge of #103211 - notriddle:notriddle/dot-location, r=GuillaumeGomezMatthias Krüger-1/+1
rustdoc: remove class name `location` from sidebar sibling nav Preview: https://notriddle.com/notriddle-rustdoc-demos/sidebar-location/std/vec/struct.Vec.html This change tweaks the CSS to apply most of its styles to `.sidebar h2`, cleaning up a few redundant rules from `.mobile-topbar .location` and restoring useful navigation aids in mobile mode. ## Before ![location-before](https://user-images.githubusercontent.com/1593513/196521014-d8730830-c3a2-4ed7-9266-05454cd31e05.png) ## After ![location-after](https://user-images.githubusercontent.com/1593513/196521020-75ec1fa5-b3dc-4c5d-97b6-afccb5fbe00a.png)
2022-10-18rustdoc: remove class name `location` from sidebar sibling navMichael Howell-1/+1
This change tweaks the CSS to apply most of its styles to `.sidebar h2`, cleaning up a few redundant rules from `.mobile-topbar .location` and restoring useful navigation aids in mobile mode.
2022-10-17rustdoc: change mobile breakpoint to match CSSMichael Howell-2/+2
Since it's possible to have a 700.5px viewport width, the JS needs to not switch to mobile mode in such a setup.
2022-10-17rustdoc: factor JS mobile scroll lock into its own functionMichael Howell-11/+25
https://github.com/rust-lang/rust/pull/98775#issuecomment-1172728308
2022-10-15rustdoc: make help button a no-op when on help pageMichael Howell-0/+15
2022-10-15rustdoc: fix Ctrl-Click on help and settings linksMichael Howell-1/+8
2022-10-15rustdoc: make the help button a link to a pageMichael Howell-23/+40
This allows you to open the help section in a new browser tab, which is a pretty reasonable thing to want for a documentation page.
2022-10-11rustdoc: remove unused classes from sidebarMichael Howell-5/+3
Since 98f05a0282625a5fda6e90ebf3b05a4bd7608f65 removed separate colors from the currently-selected item, there's no need to have item classes on sidebar links.
2022-10-10rustdoc: remove unneeded `<div>` wrapper from sidebar DOMMichael Howell-15/+11
When this was added, the sidebar had a bit more complex style. It can be removed, now.
2022-10-08rustdoc: remove mobile topbar from source pages instead of hiding itMichael Howell-6/+8
2022-10-05rustdoc: remove unused CSS class `in-band`Michael Howell-1/+1
Since a7c25b29575c17434406b69773f8c2961af343b3 removed `in-band` from code headers, the only remaining uses of the `in-band` class are: https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/write_shared.rs#L520-L521 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/templates/print_item.html#L2-L3 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/context.rs#L637-L638 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L368-L369 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/render/mod.rs#L401-L402 https://github.com/rust-lang/rust/blob/02cd79afb8080fce8c8ce35533c54d8ecf8f390e/src/librustdoc/html/static/js/main.js#L525 Since all of these uses are nested below `h1.fqn`, we can get rid of it, and the support code that was used for when `in-band` was part of item rendering.