about summary refs log tree commit diff
path: root/src/librustdoc/html/static/storage.js
AgeCommit message (Collapse)AuthorLines
2021-07-07Clean up rustdoc static filesGuillaume Gomez-219/+0
2021-05-15Fix eslint errorsGuillaume Gomez-1/+1
2021-05-11rustdoc: remove explicit boolean comparisons.Jacob Hoffman-Andrews-7/+7
For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. Removed unused isType parameter from two functions.
2021-04-12Improve CSS for "hide contents, not items"Jacob Hoffman-Andrews-1/+0
Introduce a first use of the `<details>` and `<summary>` tags as replacements for the JS-built toggles. I think this has the potential to replace all the JS toggles and generally clean up the JS, CSS, and HTML. Split rendering of attributes into two cases: in the case where they are rendered as descendents of a `<pre>` tag, where they use indent spaces and newlines for formatting, matching their surrounding markup. In the case where they are rendered as descendants of a `<code>` tag, they are rendered as `<div>`. This let me clean up some fragile CSS that was adjusting the margin-left of attributes depending on context. Remove toggles for attributes. With the ALLOWED_ATTRIBUTES filter, it's rare for an item to have more than one attribute, so hiding attributes behind a toggle doesn't save any screen space in the common case. Fix a couple of invocations of `matches!` that didn't compile on my machine. Fix a boolean for the JS `createToggle` call that was causing "Expand description" to show up spuriously on already-expanded descriptions. Add JS for auto-hide settings and hide all / show all. Remove a z-index property and some font color tweaks made unnecessary by the <details> toggles. Add CSS for the <details> toggles.
2021-03-05Remove theme.js file creation and move its code inside main.jsGuillaume Gomez-9/+9
2021-02-15Fix ES5 errors (IE11)Guillaume Gomez-1/+1
2021-02-10Fix getCurrentValueOphir LOJKINE-1/+1
2021-02-10Catch errors on localStorage setting failureOphir LOJKINE-23/+8
Fixes https://github.com/rust-lang/rust/issues/81928 “Ask forgiveness not permission” : this makes the code both simpler and more robust
2021-01-25Fix some bugs reported by eslintGuillaume Gomez-2/+8
2020-10-28rustdoc: Provide a way to set the default settings from Rust codeIan Jackson-1/+23
rustdoc has various user-configurable preferences. These are recorded in web Local Storage (where available). But we want to provide a way to configure the default default, including for when web storage is not available. getSettingValue is the function responsible for looking up these settings. Here we make it fall back some in-DOM data, which ultimately comes from RenderOptions.default_settings. Using HTML data atrtributes is fairly convenient here, dsspite the need to transform between snake and kebab case to avoid the DOM converting kebab case to camel case (!) We cache the element and dataset lookup in a global variable, to ensure that getSettingValue remains fast. The DOM representation has to be in an element which precedes the inclusion of storage.js. That means it has to be in the <head> and we should not use an empty <div> as the container (although most browsers will accept that). An empty <script> element provides a convenient and harmless container object. <meta> would be another possibility but runs a greater risk of having unwanted behaviours on weird browsers. We trust the RenderOptions not to contain unhelpful setting names, which don't fit nicely into an HTML attribute. It's awkward to quote dataset keys. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28rustdoc: js: Use getSettingValue for all rustdoc-* valuesIan Jackson-9/+14
Currently, storage.js and main.js have many open-coded calls to getCurrentValue for "rustdoc-" values, but these are settings and should be handled by getSettingValue. So make getSettingValue part of storage.js (where everyone can call it) and use it everywhere. No functional change yet. We are going to make getSettingValue do something more sophisticated in a moment. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-23Always store Rustdoc theme when it's changednasso-5/+6
2020-10-15Set preferred-dark-theme to the last dark themenasso-0/+10
If the user doesn't have a preferred dark theme but is already using a dark theme, set the preferred dark theme to be that theme
2020-10-13Coding style fixesnasso-5/+8
2020-10-13Add a setting to use the system themenasso-6/+66
2020-05-26Fix eslint lintsGuillaume Gomez-2/+7
2019-11-07Remove old isHidden functionGuillaume Gomez-4/+0
2019-09-02Fix regex replacement in theme detectionGuillaume Gomez-1/+1
2019-08-30Rollup merge of #63847 - GuillaumeGomez:system-theme-detection, r=kinnisonMazdak Farrokhzad-1/+2
[rustdoc] Fix system theme detection Fixes #63830 The problem is that it returns the property "entirely" (so with the quotes in our case). Removing them fixes the issue. cc @fenhl r? @kinnison
2019-08-28Auto merge of #62941 - GuillaumeGomez:save-crate-filter, r=Mark-Simulacrumbors-1/+1
Save crate filtering on rustdoc Fixes #62929. I added a hashmap and a hash encoding for the current crate list in case you have multiple crates handling on a same website (who talked about docs.rs?!). Like that, for each context, you have the filter crate selected. r? @QuietMisdreavus
2019-08-28Save crate filtering on rustdocGuillaume Gomez-1/+1
2019-08-25Fix system theme detectionGuillaume Gomez-1/+2
2019-08-21Replaced skipStorage with saveTheme variableGuillaume Gomez-3/+3
2019-08-21take into account the system themeGuillaume Gomez-3/+13
2019-06-11Fix storage usage when disabledGuillaume Gomez-3/+1
2018-12-25Remove licensesMark Rousskov-12/+0
2018-12-16Fix invalid JS file generationGuillaume Gomez-1/+1
2018-12-06cleanupGuillaume Gomez-8/+9
2018-12-06Greatly improve rustdoc rendering speed issuesGuillaume Gomez-29/+18
2018-12-04Added a bare-bones eslint config (removing jslint)John Heitmann-0/+3
This change removes the small bit of jslint config, replacing it with eslint. I've currently configured eslint to mostly only report the more serious of lints, although there are still some style nits turned on. Upcoming changes will start fixing lints.
2018-11-24Add source file sidebarGuillaume Gomez-0/+40
2018-10-21Hide items if they use default docsGuillaume Gomez-4/+12
2018-10-16Move usableLocalStorage() above functions that make use of itRoy Wellington Ⅳ-15/+15
2018-10-15Extract localStorage tests out into a helper method; use in getCurrentValue()Roy Wellington Ⅳ-8/+20
1. Extract the tests for whether or not we have workable localStorage out into a helper method, so it can be more easily reused 2. Use it in getCurrentValue() too, for the same reasons, as suggested in code review
2018-10-14Detect if access to localStorage is forbidden by the user's browserRoy Wellington Ⅳ-0/+6
If the user's cookie/persistent storage setting forbid access to localStorage, catch the exception and abort the access. Currently, attempting to use the expand/contract links at the top of the page for structs/consts/etc. fails due to an unhandled error while accessing localStorage, if such access is forbidden, as the exception from the failed access propagates all the way out, interrupting the expand/contract. Instead, I would like to degrade gracefully; the access won't happen (the collapse/expand state won't get persisted) but the actual expanding/contracting of the item will go on to succeed. Fixes #55079
2018-04-04Fix anchors issue when everything is collapsedGuillaume Gomez-1/+2
2018-03-29Rename main theme into light themeGuillaume Gomez-1/+1
2018-03-12Fix blink when main theme is selectedGuillaume Gomez-1/+5
2018-03-05Add resource-suffix option for rustdocGuillaume Gomez-1/+3
2018-02-20Allow to not switch to a theme if it doesn't existGuillaume Gomez-3/+31
2018-02-20Change local storage name for rustdoc because of conflicts with mdbookGuillaume Gomez-1/+1
2018-01-23Fasten even more theme switchGuillaume Gomez-8/+0
2018-01-22Fasten up theme loadingGuillaume Gomez-0/+44