Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce spotlight/"important traits" feature #74111

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ function defocusSearchBar() {
function handleEscape(ev) {
var help = getHelpElement();
var search = getSearchElement();
hideModal();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add the hideModal calls BTW?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't intend to. Will fix.

if (hasClass(help, "hidden") === false) {
displayHelp(false, ev, help);
} else if (hasClass(search, "hidden") === false) {
Expand Down Expand Up @@ -395,6 +396,7 @@ function defocusSearchBar() {
case "s":
case "S":
displayHelp(false, ev);
hideModal();
ev.preventDefault();
focusSearchBar();
break;
Expand All @@ -407,6 +409,7 @@ function defocusSearchBar() {

case "?":
if (ev.shiftKey) {
hideModal();
displayHelp(true, ev);
}
break;
Expand Down Expand Up @@ -2621,6 +2624,16 @@ function defocusSearchBar() {
});
}());

function showImportantTraits(content) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this function is never used. Please remove it.

let list = content.classList
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is list used for?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing ; too. :)

}

onEachLazy(document.getElementsByClassName("important-traits"), function(e) {
e.onclick = function() {
e.getElementsByClassName('important-traits-tooltiptext')[0].classList.toggle("force-tooltip")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to use either this or event.target in here (event would be the first argument given to onclick).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that just be e anyway?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too confident about the variable capture process in JS so I prefer to minimize it as much as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also missing ;.

};
});

// In the search display, allows to switch between tabs.
function printTab(nb) {
if (nb === 0 || nb === 1 || nb === 2) {
Expand Down
Loading