diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-10-25 00:35:45 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2019-10-27 11:42:38 +0100 |
| commit | 91ef9600db47e4e91a57909077a60ebec1122d1b (patch) | |
| tree | bcfbd1a9cf38ef4ca8904d27d07921559c22f64d /src/librustdoc/html/static | |
| parent | 1d2808341a51fe70ea5587b2c111fa4ebf106991 (diff) | |
| download | rust-91ef9600db47e4e91a57909077a60ebec1122d1b.tar.gz rust-91ef9600db47e4e91a57909077a60ebec1122d1b.zip | |
reduce size of generated HTML files by moving the popup helper code to the JS
Diffstat (limited to 'src/librustdoc/html/static')
| -rw-r--r-- | src/librustdoc/html/static/main.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index d321307b2e0..c896660f537 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2553,6 +2553,53 @@ function getSearchElement() { } window.addSearchOptions = addSearchOptions; + + function buildHelperPopup() { + var popup = document.createElement("aside"); + addClass(popup, "hidden"); + popup.id = "help"; + + var container = document.createElement("div"); + var shortcuts = [ + ["?", "Show this help dialog"], + ["S", "Focus the search field"], + ["↑", "Move up in search results"], + ["↓", "Move down in search results"], + ["↹", "Switch tab"], + ["⏎", "Go to active search result"], + ["+", "Expand all sections"], + ["-", "Collapse all sections"], + ].map(x => "<dt><kbd>" + x[0] + "</kbd></dt><dd>" + x[1] + "</dd>").join(""); + var div_shortcuts = document.createElement("div"); + addClass(div_shortcuts, "shortcuts"); + div_shortcuts.innerHTML = "<h2>Keyboard Shortcuts</h2><dl>" + shortcuts + "</dl></div>"; + + var infos = [ + "Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to \ + restrict the search to a given type.", + "Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, \ + <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, \ + and <code>const</code>.", + "Search functions by type signature (e.g., <code>vec -> usize</code> or \ + <code>* -> vec</code>)", + "Search multiple things at once by splitting your query with comma (e.g., \ + <code>str,u8</code> or <code>String,struct:Vec,test</code>)", + "You can look for items with an exact name by putting double quotes around \ + your request: <code>\"string\"</code>", + "Look for items inside another one by searching for a path: <code>vec::Vec</code>", + ].map(x => "<p>" + x + "</p>").join(""); + var div_infos = document.createElement("div"); + addClass(div_infos, "infos"); + div_infos.innerHTML = "<h2>Search Tricks</h2>" + infos; + + container.appendChild(div_shortcuts); + container.appendChild(div_infos); + + popup.appendChild(container); + insertAfter(popup, getSearchElement()); + } + + buildHelperPopup(); }()); // Sets the focus on the search bar at the top of the page |
