Make doc search results use <a> tags instead of js for navigating
This has the primary advantage of not interfering with browser default behavior for links like being able to cmd/ctrl+click on a result to open the result in a new tab but leave the current page as-is (previous behavior both opened a new tab and changed the current tab's location to the result's)
This commit is contained in:
parent
08176a3561
commit
3dc9deb6e5
@ -218,11 +218,10 @@ nav.sub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.content .highlighted {
|
.content .highlighted {
|
||||||
cursor: pointer;
|
|
||||||
color: #000 !important;
|
color: #000 !important;
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
}
|
}
|
||||||
.content .highlighted a { color: #000 !important; }
|
.content .highlighted a, .content .highlighted span { color: #000 !important; }
|
||||||
.content .highlighted.trait { background-color: #fece7e; }
|
.content .highlighted.trait { background-color: #fece7e; }
|
||||||
.content .highlighted.mod { background-color: #afc6e4; }
|
.content .highlighted.mod { background-color: #afc6e4; }
|
||||||
.content .highlighted.enum { background-color: #b4d1b9; }
|
.content .highlighted.enum { background-color: #b4d1b9; }
|
||||||
@ -335,11 +334,11 @@ a {
|
|||||||
p a { color: #4e8bca; }
|
p a { color: #4e8bca; }
|
||||||
p a:hover { text-decoration: underline; }
|
p a:hover { text-decoration: underline; }
|
||||||
|
|
||||||
.content a.trait, .block a.current.trait { color: #ed9603; }
|
.content span.trait, .block a.current.trait { color: #ed9603; }
|
||||||
.content a.mod, .block a.current.mod { color: #4d76ae; }
|
.content span.mod, .block a.current.mod { color: #4d76ae; }
|
||||||
.content a.enum, .block a.current.enum { color: #5e9766; }
|
.content span.enum, .block a.current.enum { color: #5e9766; }
|
||||||
.content a.struct, .block a.current.struct { color: #e53700; }
|
.content span.struct, .block a.current.struct { color: #e53700; }
|
||||||
.content a.fn, .block a.current.fn { color: #8c6067; }
|
.content span.fn, .block a.current.fn { color: #8c6067; }
|
||||||
.content .fnname { color: #8c6067; }
|
.content .fnname { color: #8c6067; }
|
||||||
|
|
||||||
.search-input {
|
.search-input {
|
||||||
@ -377,6 +376,13 @@ p a:hover { text-decoration: underline; }
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search-results a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content .search-results td:first-child { padding-right: 0; }
|
||||||
|
.content .search-results td:first-child a { padding-right: 10px; }
|
||||||
|
|
||||||
#help {
|
#help {
|
||||||
background: #e9e9e9;
|
background: #e9e9e9;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
@ -395,8 +395,8 @@
|
|||||||
if (window.location.pathname == dst.pathname) {
|
if (window.location.pathname == dst.pathname) {
|
||||||
$('#search').addClass('hidden');
|
$('#search').addClass('hidden');
|
||||||
$('#main').removeClass('hidden');
|
$('#main').removeClass('hidden');
|
||||||
|
document.location.href = dst.href;
|
||||||
}
|
}
|
||||||
document.location.href = dst.href;
|
|
||||||
}).on('mouseover', function() {
|
}).on('mouseover', function() {
|
||||||
var $el = $(this);
|
var $el = $(this);
|
||||||
clearTimeout(hoverTimeout);
|
clearTimeout(hoverTimeout);
|
||||||
@ -451,7 +451,7 @@
|
|||||||
shown = [];
|
shown = [];
|
||||||
|
|
||||||
results.forEach(function(item) {
|
results.forEach(function(item) {
|
||||||
var name, type;
|
var name, type, href, displayPath;
|
||||||
|
|
||||||
if (shown.indexOf(item) !== -1) {
|
if (shown.indexOf(item) !== -1) {
|
||||||
return;
|
return;
|
||||||
@ -461,43 +461,35 @@
|
|||||||
name = item.name;
|
name = item.name;
|
||||||
type = itemTypes[item.ty];
|
type = itemTypes[item.ty];
|
||||||
|
|
||||||
output += '<tr class="' + type + ' result"><td>';
|
|
||||||
|
|
||||||
if (type === 'mod') {
|
if (type === 'mod') {
|
||||||
output += item.path +
|
displayPath = item.path + '::';
|
||||||
'::<a href="' + rootPath +
|
href = rootPath + item.path.replace(/::/g, '/') + '/' +
|
||||||
item.path.replace(/::/g, '/') + '/' +
|
name + '/index.html';
|
||||||
name + '/index.html" class="' +
|
|
||||||
type + '">' + name + '</a>';
|
|
||||||
} else if (type === 'static' || type === 'reexport') {
|
} else if (type === 'static' || type === 'reexport') {
|
||||||
output += item.path +
|
displayPath = item.path + '::';
|
||||||
'::<a href="' + rootPath +
|
href = rootPath + item.path.replace(/::/g, '/') +
|
||||||
item.path.replace(/::/g, '/') +
|
'/index.html';
|
||||||
'/index.html" class="' + type +
|
|
||||||
'">' + name + '</a>';
|
|
||||||
} else if (item.parent !== undefined) {
|
} else if (item.parent !== undefined) {
|
||||||
var myparent = item.parent;
|
var myparent = item.parent;
|
||||||
var anchor = '#' + type + '.' + name;
|
var anchor = '#' + type + '.' + name;
|
||||||
output += item.path + '::' + myparent.name +
|
displayPath = item.path + '::' + myparent.name + '::';
|
||||||
'::<a href="' + rootPath +
|
href = rootPath + item.path.replace(/::/g, '/') +
|
||||||
item.path.replace(/::/g, '/') +
|
'/' + itemTypes[myparent.ty] +
|
||||||
'/' + itemTypes[myparent.ty] +
|
'.' + myparent.name +
|
||||||
'.' + myparent.name +
|
'.html' + anchor;
|
||||||
'.html' + anchor +
|
|
||||||
'" class="' + type +
|
|
||||||
'">' + name + '</a>';
|
|
||||||
} else {
|
} else {
|
||||||
output += item.path +
|
displayPath = item.path + '::';
|
||||||
'::<a href="' + rootPath +
|
href = rootPath + item.path.replace(/::/g, '/') +
|
||||||
item.path.replace(/::/g, '/') +
|
'/' + type + '.' + name + '.html';
|
||||||
'/' + type +
|
|
||||||
'.' + name +
|
|
||||||
'.html" class="' + type +
|
|
||||||
'">' + name + '</a>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output += '</td><td><span class="desc">' + item.desc +
|
output += '<tr class="' + type + ' result"><td>' +
|
||||||
'</span></td></tr>';
|
'<a href="' + href + '">' +
|
||||||
|
displayPath + '<span class="' + type + '">' +
|
||||||
|
name + '</span></a></td><td>' +
|
||||||
|
'<a href="' + href + '">' +
|
||||||
|
'<span class="desc">' + item.desc +
|
||||||
|
' </span></a></td></tr>';
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
output += 'No results :( <a href="https://duckduckgo.com/?q=' +
|
output += 'No results :( <a href="https://duckduckgo.com/?q=' +
|
||||||
|
Loading…
Reference in New Issue
Block a user