summaryrefslogtreecommitdiff
path: root/src/librustdoc/html/static/js/source-script.js
Commit message (Collapse)AuthorAgeFilesLines
* rustdoc: lift constant string manipulation out of loopMichael Howell2023-04-211-1/+1
|
* rustdoc: use CSS `overscroll-behavior` instead of JavaScriptMichael Howell2023-04-121-3/+6
| | | | | | | | | | | | | | | | | 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.
* Clean up JS files code a bitGuillaume Gomez2023-02-261-2/+1
|
* rustdoc: name the source page sidebar-toggle `#src-sidebar-toggle`Michael Howell2022-12-151-1/+1
| | | | The old name doesn't get across where it's really supposed to be used.
* rustdoc: change `.src-line-numbers > span` to `.src-line-numbers > a`Michael Howell2022-10-311-3/+8
| | | | | | | This allows people to treat them like real links, such as right-click to copy URL, and makes the line numbers in a scraped example work at all, when before this commit was added, they had the clickable pointer cursor but did not actually do anything when clicked.
* rustdoc: factor JS mobile scroll lock into its own functionMichael Howell2022-10-171-30/+3
| | | | https://github.com/rust-lang/rust/pull/98775#issuecomment-1172728308
* rustdoc: give `.line-number` / `.line-numbers` meaningful namesMichael Howell2022-09-261-2/+2
|
* Rollup merge of #98775 - notriddle:notriddle/mobile-sidebar-scroll-lock, r=jshaMatthias Krüger2022-08-101-3/+17
|\ | | | | | | | | | | | | | | | | | | rustdoc: improve scroll locking in the rustdoc mobile sidebars This PR prevents the main content area from scrolling while the mobile sidebar is open on documentation pages (porting the scroll locking behavior from the source sidebar to the regular sidebar), and also fixes some bad behavior where opening a "mobile" sidebar, and growing the viewport so that the "desktop" mode without scroll locking is activated, could potentially leave the page stuck. This does not affect the behavior on larger screens. Only small ones, where the sidebar covers up the main content. Split out from #98772
| * rustdoc: improve scroll locking in the rustdoc mobile sidebarsMichael Howell2022-07-051-3/+17
| | | | | | | | | | | | | | | | | | | | This commit ports the scroll locking behavior from the source sidebar to the regular sidebar, and also fixes some bad behavior where opening a "mobile" sidebar, and growing the viewport so that the "desktop" mode without scroll locking is activated, could potentially leave the page stuck. This does not affect the behavior on larger screens. Only small ones, where the sidebar covers up the main content.
* | rustdoc: use a more compact encoding for source-files.jsMichael Howell2022-08-021-7/+11
| | | | | | | | This reduces the compiler-doc file from 40K to 36K, a 10% reduction in size.
* | Fix auto-expand of trees in source code page sidebarGuillaume Gomez2022-07-171-1/+1
|/
* Rollup merge of #98776 - notriddle:notriddle/mobile-sidebar-auto-close, ↵Dylan DPC2022-07-051-2/+9
|\ | | | | | | | | | | | | | | | | | | r=GuillaumeGomez rustdoc: improve click behavior of the source code mobile full-screen "sidebar" On desktop, if you open the source code sidebar, it stays open even when you move from page to page. It used to do the same thing on mobile, but I think that's stupid. Since the file list fills the entire screen on mobile, and you can't really do anything with the currently selected file other than dismiss the "sidebar" to look at it, it's safe to assume that anybody who clicks a file in that list probably wants the list to go away so they can see it. Split out separately from #98772
| * Improve click behavior of the source code mobile full-screen "sidebar"Michael Howell2022-07-011-2/+9
| | | | | | | | | | | | | | | | | | On desktop, if you open the source code sidebar, it stays open even when you move from page to page. It used to do the same thing on mobile, but I think that's stupid. Since the file list fills the entire screen on mobile, and you can't really do anything with the currently selected file other than dismiss the "sidebar" to look at it, it's safe to assume that anybody who clicks a file in that list probably wants the list to go away so they can see it.
* | Rollup merge of #98774 - notriddle:notriddle/source-code-sidebar-button, ↵Matthias Krüger2022-07-041-3/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r=GuillaumeGomez rustdoc: make source sidebar toggle a real button This fixes tab focus, so that you can open and close the sidebar from keyboard. This should cause no visible change in appearance at all. The only way you'd know anything different is if you tried to use keyboard controls to open the source code file navigation sidebar. Separated out from #98772
| * | rustdoc: make source sidebar toggle a real buttonMichael Howell2022-07-021-3/+3
| |/ | | | | | | | | This fixes tab focus, so that you can open and close the sidebar from keyboard.
* | rustdoc cleanup: remove unused functionMichael Howell2022-07-011-1/+1
| |
* | rustdoc: use <details> tag for the source code sidebarMichael Howell2022-07-011-18/+11
|/ | | | | | This fixes the extremely poor accessibility of the old system, making it possible to navigate the sidebar by keyboard, and also implicitly gives the sidebar items the correct ARIA roles.
* Fix scroll when source sidebar is open on mobileGuillaume Gomez2022-06-301-0/+15
|
* Rollup merge of #98310 - jsha:defer-source-sidebar, r=GuillaumeGomezMichael Goulet2022-06-231-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````
| * rustdoc: optimize loading of source sidebarJacob Hoffman-Andrews2022-06-201-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.
* | Improve loading of crates.js and sidebar-items.jsJacob Hoffman-Andrews2022-06-201-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
* Fix expand/collapse on source viewer sidebar foldersGuillaume Gomez2022-06-141-3/+3
|
* Fix invalid line number computation when clicking on something else than a ↵Guillaume Gomez2022-05-301-0/+4
| | | | line number
* Add new eslint rule "space-before-function-paren"Guillaume Gomez2022-05-251-1/+1
|
* Fix JS error in source code pagesGuillaume Gomez2022-05-101-2/+1
|
* Change eslint rules from configuration comments to configuration filesFolyd2022-05-071-5/+0
|
* Use "strict" mode in JS scriptsGuillaume Gomez2022-05-051-1/+4
|
* Move callback to the () => {} syntax.Folyd2022-05-041-10/+11
| | | | | | | | | | | | Fix lint Fix main.js Restore anonymous functions Fix Fix more
* Move settings into full JSGuillaume Gomez2022-04-301-2/+2
|
* Migrate source-script to ES6Guillaume Gomez2022-04-261-44/+45
|
* Scroll when the anchor change and is linking outside of the displayed contentGuillaume Gomez2022-03-051-9/+7
|
* Unify storage getter and setter functionsGuillaume Gomez2022-02-021-4/+4
|
* Simplify and unify rustdoc sidebar stylesJacob Hoffman-Andrews2022-01-181-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.
* Rename ID "main" into "main-content"Guillaume Gomez2021-12-021-5/+5
|
* rustdoc: rework source sidebarcynecx2021-11-291-16/+9
|
* rustdoc: merge source sidebar into main sidebarcynecx2021-11-291-6/+8
|
* Clean up rustdoc static filesGuillaume Gomez2021-07-071-0/+249