summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/source-script.js
AgeCommit message (Collapse)AuthorLines
2022-06-23Rollup merge of #98310 - jsha:defer-source-sidebar, r=GuillaumeGomezMichael Goulet-8/+2
rustdoc: optimize loading of source sidebar The source sidebar has a setting to remember whether it should be open or closed. Previously, this setting was handled in source-script.js, which is loaded with `defer`, meaning it is often run after the document is rendered. Since CSS renders the source sidebar as closed by default, changing this after the initial render results in a relayout. Instead, handle the setting in storage.js, which is the first script to load and is the only script that blocks render. This avoids a relayout and means navigating between files with the sidebar open is faster. Demo: https://rustdoc.crud.net/jsha/defer-source-sidebar/src/alloc/ffi/c_str.rs.html r? ````@GuillaumeGomez````
2022-06-20rustdoc: optimize loading of source sidebarJacob Hoffman-Andrews-8/+2
The source sidebar has a setting to remember whether it should be open or closed. Previously, this setting was handled in source-script.js, which is loaded with `defer`, meaning it is often run after the document is rendered. Since CSS renders the source sidebar as closed by default, changing this after the initial render results in a relayout. Instead, handle the setting in storage.js, which is the first script to load and is the only script that blocks render. This avoids a relayout and means navigating between files with the sidebar open is faster.
2022-06-20Improve loading of crates.js and sidebar-items.jsJacob Hoffman-Andrews-29/+12
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-14Fix expand/collapse on source viewer sidebar foldersGuillaume Gomez-3/+3
2022-05-30Fix invalid line number computation when clicking on something else than a ↵Guillaume Gomez-0/+4
line number
2022-05-25Add new eslint rule "space-before-function-paren"Guillaume Gomez-1/+1
2022-05-10Fix JS error in source code pagesGuillaume Gomez-2/+1
2022-05-07Change eslint rules from configuration comments to configuration filesFolyd-5/+0
2022-05-05Use "strict" mode in JS scriptsGuillaume Gomez-1/+4
2022-05-04Move callback to the () => {} syntax.Folyd-10/+11
Fix lint Fix main.js Restore anonymous functions Fix Fix more
2022-04-30Move settings into full JSGuillaume Gomez-2/+2
2022-04-26Migrate source-script to ES6Guillaume Gomez-44/+45
2022-03-05Scroll when the anchor change and is linking outside of the displayed contentGuillaume Gomez-9/+7
2022-02-02Unify storage getter and setter functionsGuillaume Gomez-4/+4
2022-01-18Simplify and unify rustdoc sidebar stylesJacob Hoffman-Andrews-1/+1
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.
2021-12-02Rename ID "main" into "main-content"Guillaume Gomez-5/+5
2021-11-29rustdoc: rework source sidebarcynecx-16/+9
2021-11-29rustdoc: merge source sidebar into main sidebarcynecx-6/+8
2021-07-07Clean up rustdoc static filesGuillaume Gomez-0/+249