summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/main.js
AgeCommit message (Collapse)AuthorLines
2022-08-02Replace `* -> vec` with `-> vec` in docsNoah Lev-1/+1
Rustdoc's current syntax is `-> vec`.
2022-07-14Correctly handle crate level page on docs.rs as wellGuillaume Gomez-17/+14
2022-06-30Rollup merge of #98709 - GuillaumeGomez:rm-decl-for-old-browsers, r=Dylan-DPCMatthias Krüger-34/+0
Remove unneeded methods declaration for old web browsers All these methods were not defined for IE mostly. But since we don't support it anymore, no need to keep them around. cc ```@jsha``` r? ```@notriddle```
2022-06-30Remove unneeded methods declaration for old web browsersGuillaume Gomez-34/+0
2022-06-28rustdoc: make keyboard commands work when checkboxes are selectedMichael Howell-1/+2
2022-06-28rustdoc: fix keyboard shortcuts bug in settings menuMichael Howell-1/+1
This commit fixes the keyboard shorts code to call localStorage every time a key is pressed. This matters because you're supposed to be able to change a setting and have it immediately take effect.
2022-06-28rustdoc: fix help menu popover togglingMichael Howell-0/+3
2022-06-23Merge all popover hide functions into oneGuillaume Gomez-20/+13
2022-06-23Move help popup into a pocket menu as wellGuillaume Gomez-70/+106
2022-06-20Improve loading of crates.js and sidebar-items.jsJacob Hoffman-Andrews-69/+61
Now that the "All Crates" dropdown is only rendered on the search results page, there is no need to load crates.js on most pages. Load it only on crate pages. Also, add the `defer` attribute so it does not block page rendering. For sidebar-items.js, move the script tag to `<head>`. Since it already has the defer attribute it won't block loading. The defer attribute does preserve ordering between scripts, so instead of the callback on load, it can set a global variable on load, which is slightly simpler. Also, since it is required to finish rendering the page, beginning its load earlier is better. Remove generation and handling of sidebar-vars. Everything there can be computed with information available in JS via other means. Remove the "other" wrapper in the sidebar. It was unnecessary. Remove excess script fields
2022-06-06Add "no-confusing-arrow" eslint checkGuillaume Gomez-1/+1
2022-05-27Add "eqeqeq" eslint ruleGuillaume Gomez-2/+2
2022-05-25Add new eslint rule "space-before-function-paren"Guillaume Gomez-2/+2
2022-05-15Add new eslint rule about brace styleGuillaume Gomez-2/+2
2022-05-14Remove theme picker buttonGuillaume Gomez-135/+2
2022-05-07Enforce quote rule for JS source codeGuillaume Gomez-15/+15
2022-05-07Change eslint rules from configuration comments to configuration filesFolyd-4/+0
2022-05-06Rollup merge of #96754 - notriddle:notriddle/impl-dups, r=GuillaumeGomezGuillaume Gomez-1/+7
rustdoc: ensure HTML/JS side implementors don't have dups Fixes #94641 Rendered: - https://notriddle.com/notriddle-rustdoc-test/impl-dups/std/iter/trait.Iterator.html - https://notriddle.com/notriddle-rustdoc-test/impl-dups/core/iter/trait.Iterator.html
2022-05-05Rollup merge of #96741 - GuillaumeGomez:improve-settings-loading-strategy, ↵Michael Goulet-0/+3
r=jsha Improve settings loading strategy I learned about this thanks to ```@jsha``` who suggested this approach: It improves the settings loading strategy by loading CSS and JS at the same time to prevent the style to be applied afterwards on slow connections. r? ```@jsha```
2022-05-05Rollup merge of #96704 - GuillaumeGomez:rotation-animation, r=jshaMichael Goulet-0/+1
Add rotation animation on settings button when loading As discussed, I added an animation when the settings JS file is loading (I voluntarily made the timeout at the end of the `settings.js` super long so we can see what the animation looks like): https://user-images.githubusercontent.com/3050060/166693243-816a08b7-5e39-4142-acd3-686ad9950d8e.mp4 r? ````@jsha````
2022-05-05rustdoc: ensure HTML/JS side implementors don't have dupsMichael Howell-1/+7
2022-05-05Improve settings loading strategy by loading CSS and JS at the same time to ↵Guillaume Gomez-0/+3
prevent the style to be applied afterwards on slow connections
2022-05-05Add rotation animation on settings button when loadingGuillaume Gomez-1/+1
2022-05-05Use "strict" mode in JS scriptsGuillaume Gomez-3/+2
2022-05-04Move callback to the () => {} syntax.Folyd-56/+49
Fix lint Fix main.js Restore anonymous functions Fix Fix more
2022-05-01* Add documentation for settings page rendering functions.Guillaume Gomez-6/+6
* Improve code. * Fix some documentation argument types. * Make settings order the same as before this PR. * Change timeout to 0 so that browser will render it as fast as possible.
2022-04-30Move settings into full JSGuillaume Gomez-34/+145
2022-04-26Remove dead code in main.jsGuillaume Gomez-23/+0
2022-04-26Migrate main.js to ES6Guillaume Gomez-128/+130
2022-03-08Unify inherent impl blocks by wrapping them into a divGuillaume Gomez-1/+1
2022-02-05Linkify sidebar headings for sibling itemsJacob Hoffman-Andrews-16/+24
Also adjust CSS so this doesn't produce excess padding/margin.
2022-02-04Rollup merge of #92735 - GuillaumeGomez:crate-filter-url-param, r=jshaMatthias Krüger-20/+3
Add crate filter parameter in URL Fixes #92621. r? `@jsha`
2022-02-03Add filter-crate URL parameterGuillaume Gomez-20/+3
2022-01-29rustdoc: small fixes to mobile navigationJacob Hoffman-Andrews-1/+1
- Make sure the mobile-topbar doesn't overflow its height if the user sets a bigger font. - Make sure the sidebar can be scrolled all the way to the bottom by shortening it to accommodate the mobile-topbar. - Make the item name in the mobile-topbar clickable to go to the top of the page. - Remove excess padding sidebar in mobile mode.
2022-01-18Simplify and unify rustdoc sidebar stylesJacob Hoffman-Andrews-39/+21
This switches to just use size, weight, and spacing to distinguish headings in the sidebar. We no longer use boxes, horizontal bars, or centering to distinguish headings. This makes it much easier to understand the hierarchy of headings, and reduces visual noise. I also refactored how the mobile topbar works. Previously, we tried to shift around elements from the sidebar to make the topbar. Now, the topbar gets its own elements, which can be styled on their own. This makes styling and reasoning about those elements simpler. Because the heading font sizes are bigger, increase the sidebar width slightly. As a very minor change, removed version from the "All types" page. It's now only on the crate page.
2022-01-18Rollup merge of #92830 - jsha:style-cleanups, r=GuillaumeGomezMatthias Krüger-27/+0
Rustdoc style cleanups - Make "since" version numbers grey again (regressed in #92602). - Remove unneeded selectors for when crate filter dropdown is a sibling of search-input. - Crate filter dropdown doesn't need to be 100% width on mobile. - Only build crate filter dropdown when there is more than one crate. - Remove unused addCrateDropdown Demo: https://rustdoc.crud.net/jsha/style-cleanups/std/string/struct.String.html r? `@GuillaumeGomez`
2022-01-18Rollup merge of #92803 - jsha:hide-sidebar, r=GuillaumeGomezMatthias Krüger-0/+4
Hide mobile sidebar on some clicks When the user clicks outside the sidebar, the sidebar should close. Also, when the user clicks an internal link in the sidebar, it should close. Fixes #92682 Demo: https://rustdoc.crud.net/jsha/hide-sidebar/std/string/struct.String.html
2022-01-17Hide mobile sidebar on some clicksJacob Hoffman-Andrews-0/+4
When the user clicks outside the sidebar, the sidebar should close. Also, when the user clicks an internal link in the sidebar, it should close.
2022-01-17Rustdoc style cleanupsJacob Hoffman-Andrews-27/+0
- Make "since" version numbers grey again (regressed in #92602). - Remove unneeded selectors for when crate filter dropdown is a sibling of search-input. - Crate filter dropdown doesn't need to be 100% width on mobile. - Only build crate filter dropdown when there is more than one crate. - Remove unused addCrateDropdown.
2022-01-14Pick themes on settings page, not every pageJacob Hoffman-Andrews-0/+5
This hides the paintbrush icon on most pages by default, in preference for the settings on the settings page. When loading from a local file, and not in mobile view, continue to show the theme picker. That's because some browsers limit access to localStorage from file:/// URLs, so choosing a theme from settings.html doesn't take effect.
2022-01-06Create CSS class instead of using inline style for search resultsGuillaume Gomez-2/+2
2021-12-22Add some JSDoc comments to rustdoc JSJacob Hoffman-Andrews-0/+7
This follows the Closure Compiler dialect of JSDoc, so we can use it to do some basic type checking. We don't plan to compile with Closure Compiler, just use it to check types. See https://github.com/google/closure-compiler/wiki/ for details.
2021-12-02Rename ID "main" into "main-content"Guillaume Gomez-2/+3
2021-11-29rustdoc: use flexbox to layout sidebar and main contentcynecx-1/+1
2021-11-24Consistentize the system for image URLs in CSS.Jacob Hoffman-Andrews-2/+2
2021-11-24Move themes and version into rustdoc-varsJacob Hoffman-Andrews-9/+24
We had been injecting the list of themes and the rustdoc version into main.js by rewriting it at doc generation time. By avoiding this rewrite, we can make it easier to edit main.js without regenerating all the docs. Added a more convenient accessor for rustdoc-vars. Changed storage.js to not rely on resourcesSuffix. It could in theory use rustdoc-vars, but because rustdoc-vars is at the end of the HTML, it's not available when storage.js runs (very early in page load).
2021-11-24Fix clicking on anchors inside summary tags.Jacob Hoffman-Andrews-1/+1
2021-11-22Add GUI test for clicking on non-toggle summaryJacob Hoffman-Andrews-1/+1
2021-11-21Inhibit clicks on summary's childrenJacob Hoffman-Andrews-0/+8
A byproduct of using `<details>` and `<summary>` to show/hide detailed documentation was that clicking any part of a method heading (or impl heading) would show or hide the documentation. This was not super noticeable because clicking a link inside the method heading would navigate to that link. But clicking any unlinked black text in a method heading would trigger the behavior. That behavior was somewhat unexpected, and means that if you try to click a type name in a method heading, but miss by a few pixels, you get a confusing surprise. This change inhibits that behavior by putting an event listener on most summaries that cancels the event unless the event target was the summary itself. In practice, that means it cancels the event unless the target was the "[+]" / "[-]", because the rest of the heading is wrapped inside a `<div>`, which is the target for anything that doesn't have a more specific target.
2021-11-04Fix missing bottom border for headings in sidebarGuillaume Gomez-2/+7