summaryrefslogtreecommitdiffstats
path: root/src/librustdoc/html/static/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustdoc/html/static/js')
-rw-r--r--src/librustdoc/html/static/js/search.js29
-rw-r--r--src/librustdoc/html/static/js/src-script.js (renamed from src/librustdoc/html/static/js/source-script.js)32
-rw-r--r--src/librustdoc/html/static/js/storage.js2
3 files changed, 28 insertions, 35 deletions
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 51d8e81ca..42088e735 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -2108,29 +2108,22 @@ function initSearch(rawSearchIndex) {
const resultName = document.createElement("div");
resultName.className = "result-name";
- if (item.is_alias) {
- const alias = document.createElement("span");
- alias.className = "alias";
-
- const bold = document.createElement("b");
- bold.innerText = item.alias;
- alias.appendChild(bold);
-
- alias.insertAdjacentHTML(
- "beforeend",
- "<i class=\"grey\">&nbsp;- see&nbsp;</i>");
+ resultName.insertAdjacentHTML(
+ "beforeend",
+ `<span class="typename">${typeName}</span>`);
+ link.appendChild(resultName);
- resultName.appendChild(alias);
+ let alias = " ";
+ if (item.is_alias) {
+ alias = ` <div class="alias">\
+<b>${item.alias}</b><i class="grey">&nbsp;- see&nbsp;</i>\
+</div>`;
}
-
resultName.insertAdjacentHTML(
"beforeend",
- `\
-<span class="typename">${typeName}</span>\
-<div class="path">\
- ${item.displayPath}<span class="${type}">${name}</span>\
+ `<div class="path">${alias}\
+${item.displayPath}<span class="${type}">${name}</span>\
</div>`);
- link.appendChild(resultName);
const description = document.createElement("div");
description.className = "desc";
diff --git a/src/librustdoc/html/static/js/source-script.js b/src/librustdoc/html/static/js/src-script.js
index 6eb991360..679c2341f 100644
--- a/src/librustdoc/html/static/js/source-script.js
+++ b/src/librustdoc/html/static/js/src-script.js
@@ -1,5 +1,5 @@
// From rust:
-/* global sourcesIndex */
+/* global srcIndex */
// Local js definitions:
/* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */
@@ -74,11 +74,11 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
function toggleSidebar() {
const child = this.parentNode.children[0];
if (child.innerText === ">") {
- addClass(document.documentElement, "source-sidebar-expanded");
+ addClass(document.documentElement, "src-sidebar-expanded");
child.innerText = "<";
updateLocalStorage("source-sidebar-show", "true");
} else {
- removeClass(document.documentElement, "source-sidebar-expanded");
+ removeClass(document.documentElement, "src-sidebar-expanded");
child.innerText = ">";
updateLocalStorage("source-sidebar-show", "false");
}
@@ -101,16 +101,16 @@ function createSidebarToggle() {
return sidebarToggle;
}
-// This function is called from "source-files.js", generated in `html/render/write_shared.rs`.
+// This function is called from "src-files.js", generated in `html/render/write_shared.rs`.
// eslint-disable-next-line no-unused-vars
-function createSourceSidebar() {
+function createSrcSidebar() {
const container = document.querySelector("nav.sidebar");
const sidebarToggle = createSidebarToggle();
container.insertBefore(sidebarToggle, container.firstChild);
const sidebar = document.createElement("div");
- sidebar.id = "source-sidebar";
+ sidebar.id = "src-sidebar";
let hasFoundFile = false;
@@ -118,9 +118,9 @@ function createSourceSidebar() {
title.className = "title";
title.innerText = "Files";
sidebar.appendChild(title);
- Object.keys(sourcesIndex).forEach(key => {
- sourcesIndex[key][NAME_OFFSET] = key;
- hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "", hasFoundFile);
+ Object.keys(srcIndex).forEach(key => {
+ srcIndex[key][NAME_OFFSET] = key;
+ hasFoundFile = createDirEntry(srcIndex[key], sidebar, "", hasFoundFile);
});
container.appendChild(sidebar);
@@ -133,7 +133,7 @@ function createSourceSidebar() {
const lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/;
-function highlightSourceLines(match) {
+function highlightSrcLines(match) {
if (typeof match === "undefined") {
match = window.location.hash.match(lineNumbersRegex);
}
@@ -172,7 +172,7 @@ function highlightSourceLines(match) {
}
}
-const handleSourceHighlight = (function() {
+const handleSrcHighlight = (function() {
let prev_line_id = 0;
const set_fragment = name => {
@@ -180,7 +180,7 @@ const handleSourceHighlight = (function() {
y = window.scrollY;
if (browserSupportsHistoryApi()) {
history.replaceState(null, null, "#" + name);
- highlightSourceLines();
+ highlightSrcLines();
} else {
location.replace("#" + name);
}
@@ -221,15 +221,15 @@ const handleSourceHighlight = (function() {
window.addEventListener("hashchange", () => {
const match = window.location.hash.match(lineNumbersRegex);
if (match) {
- return highlightSourceLines(match);
+ return highlightSrcLines(match);
}
});
onEachLazy(document.getElementsByClassName("src-line-numbers"), el => {
- el.addEventListener("click", handleSourceHighlight);
+ el.addEventListener("click", handleSrcHighlight);
});
-highlightSourceLines();
+highlightSrcLines();
-window.createSourceSidebar = createSourceSidebar;
+window.createSrcSidebar = createSrcSidebar;
})();
diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js
index 71961f6f2..af3ca42a6 100644
--- a/src/librustdoc/html/static/js/storage.js
+++ b/src/librustdoc/html/static/js/storage.js
@@ -185,7 +185,7 @@ updateTheme();
if (getSettingValue("source-sidebar-show") === "true") {
// At this point in page load, `document.body` is not available yet.
// Set a class on the `<html>` element instead.
- addClass(document.documentElement, "source-sidebar-expanded");
+ addClass(document.documentElement, "src-sidebar-expanded");
}
// If we navigate away (for example to a settings page), and then use the back or