Skip to content

Commit 40ca89e

Browse files
committed
auto merge of #15037 : zzmp/rust/doc/hotkeys, r=alexcrichton
Continuing from #15012, this makes four changes to the `rustdoc` static files. - Change the placeholder text of the search bar to `Click or press 'S' to search, '?' for more options...` to make keyboard hotkeys more apparent (capitalizing the `S` to match the help text). - Change the `main.js` file to use browser-normalized key codes (`e.which`, from `jQuery`), instead of `e.keyCode`. - Change the key code for `?` to be the correct `191` instead of `188`, so that the hotkey works to bring up search information. - Change the search information to display `tab` and `shift+tab` instead of `up` and `down`, as those do not yet work outside of Firefox (see #15011). Also, adjust the height so it does not cut off the help text. <s>I've also opened up #15038 about the non-functional `up` and `down` functionality, although this does nothing to fix it.</s>
2 parents 22d62fc + 677e6ed commit 40ca89e

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/librustdoc/html/layout.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ r##"<!DOCTYPE html>
6363
<div class="search-container">
6464
<input class="search-input" name="search"
6565
autocomplete="off"
66-
placeholder="Click or press 's' to search, '?' for more options..."
66+
placeholder="Click or press 'S' to search, '?' for more options..."
6767
type="search">
6868
</div>
6969
</form>
@@ -82,9 +82,9 @@ r##"<!DOCTYPE html>
8282
<dd>Show this help dialog</dd>
8383
<dt>S</dt>
8484
<dd>Focus the search field</dd>
85-
<dt>&uarr;</dt>
85+
<dt>&larrb;</dt>
8686
<dd>Move up in search results</dd>
87-
<dt>&darr;</dt>
87+
<dt>&rarrb;</dt>
8888
<dd>Move down in search results</dd>
8989
<dt>&#9166;</dt>
9090
<dd>Go to active search result</dd>

src/librustdoc/html/static/main.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ p a:hover { text-decoration: underline; }
347347
margin-top: -125px;
348348
margin-left: -275px;
349349
width: 550px;
350-
height: 250px;
350+
height: 300px;
351351
border: 1px solid #bfbfbf;
352352
}
353353

src/librustdoc/html/static/main.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@
7171
return;
7272
}
7373

74-
if (e.keyCode === 188 && $('#help').hasClass('hidden')) { // question mark
74+
if (e.which === 191 && $('#help').hasClass('hidden')) { // question mark
7575
e.preventDefault();
7676
$('#help').removeClass('hidden');
77-
} else if (e.keyCode === 27) { // esc
77+
} else if (e.which === 27) { // esc
7878
if (!$('#help').hasClass('hidden')) {
7979
e.preventDefault();
8080
$('#help').addClass('hidden');
@@ -83,7 +83,7 @@
8383
$('#search').addClass('hidden');
8484
$('#main').removeClass('hidden');
8585
}
86-
} else if (e.keyCode === 83) { // S
86+
} else if (e.which === 83) { // S
8787
e.preventDefault();
8888
$('.search-input').focus();
8989
}
@@ -361,23 +361,23 @@
361361
$(document).on('keypress.searchnav', function(e) {
362362
var $active = $results.filter('.highlighted');
363363

364-
if (e.keyCode === 38) { // up
364+
if (e.which === 38) { // up
365365
e.preventDefault();
366366
if (!$active.length || !$active.prev()) {
367367
return;
368368
}
369369

370370
$active.prev().addClass('highlighted');
371371
$active.removeClass('highlighted');
372-
} else if (e.keyCode === 40) { // down
372+
} else if (e.which === 40) { // down
373373
e.preventDefault();
374374
if (!$active.length) {
375375
$results.first().addClass('highlighted');
376376
} else if ($active.next().length) {
377377
$active.next().addClass('highlighted');
378378
$active.removeClass('highlighted');
379379
}
380-
} else if (e.keyCode === 13) { // return
380+
} else if (e.which === 13) { // return
381381
e.preventDefault();
382382
if ($active.length) {
383383
document.location.href = $active.find('a').prop('href');

0 commit comments

Comments
 (0)