|
40 | 40 | "union",
|
41 | 41 | "foreigntype"];
|
42 | 42 |
|
| 43 | + var search_input = document.getElementsByClassName('search-input')[0]; |
| 44 | + |
43 | 45 | // On the search screen, so you remain on the last tab you opened.
|
44 | 46 | //
|
45 | 47 | // 0 for "In Names"
|
|
411 | 413 | // but only if the input bar is empty. This avoid the obnoxious issue
|
412 | 414 | // where you start trying to do a search, and the index loads, and
|
413 | 415 | // suddenly your search is gone!
|
414 |
| - if (document.getElementsByClassName("search-input")[0].value === "") { |
415 |
| - document.getElementsByClassName("search-input")[0].value = params.search || ''; |
| 416 | + if (search_input.value === "") { |
| 417 | + search_input.value = params.search || ''; |
416 | 418 | }
|
417 | 419 |
|
418 | 420 | /**
|
|
1118 | 1120 | });
|
1119 | 1121 | });
|
1120 | 1122 |
|
1121 |
| - var search_input = document.getElementsByClassName('search-input')[0]; |
1122 | 1123 | search_input.onkeydown = function(e) {
|
1123 | 1124 | // "actives" references the currently highlighted item in each search tab.
|
1124 | 1125 | // Each array in "actives" represents a tab.
|
|
1169 | 1170 | // Does nothing, it's just to avoid losing "focus" on the highlighted element.
|
1170 | 1171 | } else if (e.which === 27) { // escape
|
1171 | 1172 | removeClass(actives[currentTab][0], 'highlighted');
|
1172 |
| - document.getElementsByClassName('search-input')[0].value = ''; |
| 1173 | + search_input.value = ''; |
1173 | 1174 | defocusSearchBar();
|
1174 | 1175 | } else if (actives[currentTab].length > 0) {
|
1175 | 1176 | removeClass(actives[currentTab][0], 'highlighted');
|
|
1206 | 1207 | return;
|
1207 | 1208 | }
|
1208 | 1209 |
|
1209 |
| - console.log(item); |
1210 | 1210 | shown.push(id_ty);
|
1211 | 1211 | name = item.name;
|
1212 | 1212 | type = itemTypes[item.ty];
|
|
1268 | 1268 | }
|
1269 | 1269 |
|
1270 | 1270 | function showResults(results) {
|
1271 |
| - var output, query = getQuery(document.getElementsByClassName('search-input')[0].value); |
| 1271 | + var output, query = getQuery(search_input.value); |
1272 | 1272 |
|
1273 | 1273 | currentResults = query.id;
|
1274 | 1274 | output = '<h1>Results for ' + escape(query.query) +
|
|
1375 | 1375 |
|
1376 | 1376 | function search(e) {
|
1377 | 1377 | var params = getQueryStringParams();
|
1378 |
| - var search_input = document.getElementsByClassName('search-input')[0]; |
1379 | 1378 | var query = getQuery(search_input.value.trim());
|
1380 | 1379 |
|
1381 | 1380 | if (e) {
|
1382 | 1381 | e.preventDefault();
|
1383 | 1382 | }
|
1384 | 1383 |
|
1385 |
| - if (!query.query || query.id === currentResults) { |
| 1384 | + if (query.query.length === 0 || query.id === currentResults) { |
1386 | 1385 | if (query.query.length > 0) {
|
1387 | 1386 | putBackSearch(search_input);
|
1388 | 1387 | }
|
|
1468 | 1467 | function startSearch() {
|
1469 | 1468 | var searchTimeout;
|
1470 | 1469 | var callback = function() {
|
1471 |
| - var search_input = document.getElementsByClassName('search-input'); |
1472 |
| - if (search_input.length < 1) { return; } |
1473 |
| - search_input = search_input[0]; |
1474 | 1470 | clearTimeout(searchTimeout);
|
1475 | 1471 | if (search_input.value.length === 0) {
|
1476 | 1472 | if (browserSupportsHistoryApi()) {
|
|
1488 | 1484 | searchTimeout = setTimeout(search, 500);
|
1489 | 1485 | }
|
1490 | 1486 | };
|
1491 |
| - var search_input = document.getElementsByClassName("search-input")[0]; |
1492 | 1487 | search_input.onkeyup = callback;
|
1493 | 1488 | search_input.oninput = callback;
|
1494 | 1489 | document.getElementsByClassName("search-form")[0].onsubmit = function(e) {
|
|
1538 | 1533 | // nothing there, which lets you really go back to a
|
1539 | 1534 | // previous state with nothing in the bar.
|
1540 | 1535 | if (params.search) {
|
1541 |
| - document.getElementsByClassName('search-input')[0].value = params.search; |
| 1536 | + search_input.value = params.search; |
1542 | 1537 | } else {
|
1543 |
| - document.getElementsByClassName('search-input')[0].value = ''; |
| 1538 | + search_input.value = ''; |
1544 | 1539 | }
|
1545 | 1540 | // Some browsers fire 'onpopstate' for every page load
|
1546 | 1541 | // (Chrome), while others fire the event only when actually
|
|
1950 | 1945 | return wrapper;
|
1951 | 1946 | }
|
1952 | 1947 |
|
1953 |
| - onEach(document.getElementById('main').getElementsByClassName('docblock'), function(e) { |
1954 |
| - if (e.parentNode.id === "main") { |
1955 |
| - var otherMessage; |
1956 |
| - if (hasClass(e, "type-decl")) { |
1957 |
| - otherMessage = ' Show type declaration'; |
1958 |
| - } |
1959 |
| - e.parentNode.insertBefore(createToggle(otherMessage), e); |
1960 |
| - if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") { |
1961 |
| - collapseDocs(e.previousSibling.childNodes[0], "toggle"); |
1962 |
| - } |
1963 |
| - } |
1964 |
| - }); |
1965 |
| - |
1966 | 1948 | onEach(document.getElementsByClassName('docblock'), function(e) {
|
1967 | 1949 | if (hasClass(e, 'autohide')) {
|
1968 | 1950 | var wrap = e.previousElementSibling;
|
1969 | 1951 | if (wrap && hasClass(wrap, 'toggle-wrapper')) {
|
1970 | 1952 | var toggle = wrap.childNodes[0];
|
| 1953 | + var extra = false; |
1971 | 1954 | if (e.childNodes[0].tagName === 'H3') {
|
1972 |
| - onEach(toggle.getElementsByClassName('toggle-label'), function(i_e) { |
1973 |
| - i_e.innerHTML = " Show " + e.childNodes[0].innerHTML; |
1974 |
| - }); |
| 1955 | + extra = true; |
1975 | 1956 | }
|
1976 | 1957 | e.style.display = 'none';
|
1977 | 1958 | addClass(wrap, 'collapsed');
|
|
1980 | 1961 | });
|
1981 | 1962 | onEach(toggle.getElementsByClassName('toggle-label'), function(e) {
|
1982 | 1963 | e.style.display = 'inline-block';
|
| 1964 | + if (extra === true) { |
| 1965 | + i_e.innerHTML = " Show " + e.childNodes[0].innerHTML; |
| 1966 | + } |
1983 | 1967 | });
|
1984 | 1968 | }
|
1985 | 1969 | }
|
| 1970 | + if (e.parentNode.id === "main") { |
| 1971 | + var otherMessage; |
| 1972 | + if (hasClass(e, "type-decl")) { |
| 1973 | + otherMessage = ' Show type declaration'; |
| 1974 | + } |
| 1975 | + e.parentNode.insertBefore(createToggle(otherMessage), e); |
| 1976 | + if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") { |
| 1977 | + collapseDocs(e.previousSibling.childNodes[0], "toggle"); |
| 1978 | + } |
| 1979 | + } |
1986 | 1980 | })
|
1987 | 1981 |
|
1988 | 1982 | autoCollapseAllImpls(getPageId());
|
|
2088 | 2082 | }
|
2089 | 2083 | }
|
2090 | 2084 |
|
2091 |
| - var search_input = document.getElementsByClassName("search-input")[0]; |
2092 |
| - |
2093 | 2085 | if (search_input) {
|
2094 | 2086 | search_input.onfocus = function() {
|
2095 | 2087 | putBackSearch(this);
|
|
0 commit comments