Allow "open in new tab" for event typeahead (#4631)

* Allow "open in new tab" for event typeahead

* use default link-behaviour for e.g. open in new ...

* navigate in typeahead with tab, add esc to close

---------

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2024-11-18 17:16:02 +01:00
committed by GitHub
parent d2a364e848
commit 3e934acfa0

View File

@@ -14,6 +14,7 @@ $(function () {
var lastQuery = null;
var runQueryTimeout = null;
var loadIndicatorTimeout = null;
var focusOutTimeout = null;
function showLoadIndicator() {
$container.find("li:not(.query-holder)").remove();
$container.append("<li class='loading'><span class='fa fa-4x fa-cog fa-spin'></span></li>");
@@ -76,14 +77,7 @@ $(function () {
$("<li>").append(
$("<a>").attr("href", res.url).append(
$linkContent
).on("mousedown", function (event) {
if ($(this).length) {
location.href = $(this).attr("href");
}
$(this).parent().addClass("active");
event.preventDefault();
event.stopPropagation();
})
)
)
);
});
@@ -115,8 +109,17 @@ $(function () {
event.stopPropagation();
}
});
$query.on("blur", function (event) {
$container.removeClass('focused');
$container.add($query).on("keydown", function (event) {
if (event.which === 27) { // escape
$container.removeClass('focused');
}
}).on("focusin", function (event) {
window.clearTimeout(focusOutTimeout);
$(document.body).one("focusout", function (event) {
focusOutTimeout = window.setTimeout(function () {
$container.removeClass('focused');
}, 100);
})
});
$query.on("keyup", function (event) {
var $first = $container.find("li:not(.query-holder)").first();