Pressing enter on global search goes to the first result (#9587)

This commit is contained in:
Tony Murray
2019-01-08 20:14:15 -06:00
committed by GitHub
parent ef8d7adad0
commit c6e5a3f283
2 changed files with 14 additions and 12 deletions

View File

@@ -814,9 +814,6 @@ if ($(window).width() < 768) {
devices.initialize();
ports.initialize();
bgp.initialize();
$('#gsearch').bind('typeahead:select', function(ev, suggestion) {
window.location.href = suggestion.url;
});
$('#gsearch').typeahead({
hint: true,
highlight: true,
@@ -857,9 +854,13 @@ $('#gsearch').typeahead({
header: '<h5><strong>&nbsp;BGP Sessions</strong></h5>',
suggestion: Handlebars.compile('<p><a href="{{url}}"><small>{{{bgp_image}}} {{name}} - {{hostname}}<br />AS{{localas}} -> AS{{remoteas}}</small></a></p>')
}
});
$('#gsearch').bind('typeahead:open', function(ev, suggestion) {
$('#gsearch').addClass('search-box');
}).on('typeahead:select', function(ev, suggestion) {
window.location.href = suggestion.url;
}).on('keyup', function(e) {
// on enter go to the first selection
if(e.which === 13) {
$('.tt-selectable').first().click();
}
});
</script>

View File

@@ -470,9 +470,6 @@
devices.initialize();
ports.initialize();
bgp.initialize();
$('#gsearch').bind('typeahead:select', function(ev, suggestion) {
window.location.href = suggestion.url;
});
$('#gsearch').typeahead({
hint: true,
highlight: true,
@@ -513,8 +510,12 @@
header: '<h5><strong>&nbsp;BGP Sessions</strong></h5>',
suggestion: Handlebars.compile('<p><a href="@{{url}}"><small>@{{bgp_image}} @{{name}} - @{{hostname}}<br />AS@{{localas}} -> AS@{{remoteas}}</small></a></p>')
}
}).on('typeahead:select', function (ev, suggestion) {
window.location.href = suggestion.url;
}).on('keyup', function (e) {
// on enter go to the first selection
if (e.which === 13) {
$('.tt-selectable').first().click();
}
});
$('#gsearch').bind('typeahead:open', function(ev, suggestion) {
$('#gsearch').addClass('search-box');
});
</script>