mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Better dashboard layout
This commit is contained in:
@@ -9,14 +9,14 @@ $(function () {
|
||||
|
||||
$("[data-event-typeahead]").each(function () {
|
||||
var $container = $(this);
|
||||
var $query = $(this).find('[data-typeahead-query]');
|
||||
$query.closest("li").nextAll().remove();
|
||||
var $query = $(this).find('[data-typeahead-query]').length ? $(this).find('[data-typeahead-query]') : $($(this).attr("data-typeahead-field"));
|
||||
$container.find("li:not(.query-holder)").remove();
|
||||
|
||||
$query.on("change", function () {
|
||||
$.getJSON(
|
||||
$container.attr("data-source") + "?query=" + encodeURIComponent($query.val()),
|
||||
function (data) {
|
||||
$query.closest("li").nextAll().remove();
|
||||
$container.find("li:not(.query-holder)").remove();
|
||||
$.each(data.results, function (i, res) {
|
||||
$container.append(
|
||||
$("<li>").append(
|
||||
@@ -36,6 +36,7 @@ $(function () {
|
||||
)
|
||||
);
|
||||
});
|
||||
$container.toggleClass('focused', $query.is(":focus") && $container.children().length > 0);
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -50,9 +51,12 @@ $(function () {
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
$query.on("blur", function (event) {
|
||||
$container.removeClass('focused');
|
||||
});
|
||||
$query.on("keyup", function (event) {
|
||||
var $first = $query.closest("li").next();
|
||||
var $last = $query.closest("li").nextAll().last();
|
||||
var $first = $container.find("li:not(.query-holder)").first();
|
||||
var $last = $container.find("li:not(.query-holder)").last();
|
||||
var $selected = $container.find(".active");
|
||||
|
||||
if (event.which === 13) { // enter
|
||||
@@ -60,10 +64,12 @@ $(function () {
|
||||
event.stopPropagation();
|
||||
return true;
|
||||
} else if (event.which === 40) { // down
|
||||
var $next;
|
||||
if ($selected.length === 0) {
|
||||
$selected = $query.closest("li");
|
||||
$next = $first;
|
||||
} else {
|
||||
$next = $selected.next();
|
||||
}
|
||||
var $next = $selected.next();
|
||||
if ($next.length === 0) {
|
||||
$next = $first;
|
||||
}
|
||||
@@ -74,7 +80,7 @@ $(function () {
|
||||
return true;
|
||||
} else if (event.which === 38) { // up
|
||||
if ($selected.length === 0) {
|
||||
$selected = $container.first();
|
||||
$selected = $first;
|
||||
}
|
||||
var $prev = $selected.prev();
|
||||
if ($prev.length === 0 || $prev.find("input").length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user