jquery-ui: fix autocomplete menu styling (#3671).

* Wrap menu items in a div.
* Replace ui-state-focus with ui-state-active.
* Make active items have a grey background.

ref: http://jqueryui.com/upgrade-guide/1.12/#require-wrappers-for-each-menu-item
ref: http://jqueryui.com/upgrade-guide/1.12/#use-consistent-styling-for-focused-and-active-items
This commit is contained in:
evazion
2018-04-26 23:18:00 -05:00
parent a11dbb9186
commit dd2abeb180
4 changed files with 18 additions and 6 deletions

View File

@@ -344,7 +344,7 @@
return;
}
if ($autocomplete_menu.has(".ui-state-focus").length === 0) {
if ($autocomplete_menu.has(".ui-state-active").length === 0) {
var $first_item = $autocomplete_menu.find(".ui-menu-item").first();
var completion = $first_item.data().uiAutocompleteItem.value;
@@ -358,6 +358,7 @@
Danbooru.Autocomplete.render_item = function(list, item) {
var $link = $("<a/>");
var $menu_item = $("<div/>").append($link);
if (item.antecedent) {
var antecedent = item.antecedent.replace(/_/g, " ");
@@ -396,7 +397,7 @@
$link.addClass("pool-category-" + item.category);
}
return $("<li/>").data("item.autocomplete", item).append($link).appendTo(list);
return $("<li/>").data("item.autocomplete", item).append($menu_item).appendTo(list);
};
Danbooru.Autocomplete.static_metatags = {

View File

@@ -1,6 +1,13 @@
.ui-autocomplete {
font-size: 0.9em;
z-index: 1000;
.ui-state-active {
border: none;
margin: 0 -1px;
background-color: #F0F0F0;
border-left: 1px solid #C5C5C5;
border-right: 1px solid #C5C5C5;
}
.ui-menu-item a {
padding: 1px .2em;
@@ -9,4 +16,4 @@
.autocomplete-arrow {
color: black;
}
}
}

View File

@@ -1,5 +1,5 @@
<% TagCategory.css_mapping.each do |category,cssmap| %>
.category-<%= category %> a, a.tag-type-<%= category %>, .ui-state-focus a.tag-type-<%= category %> {
.category-<%= category %> a, a.tag-type-<%= category %>, .ui-state-active a.tag-type-<%= category %> {
color: <%= cssmap["color"] %>;
&:hover {
@@ -8,7 +8,7 @@
}
<% end %>
.category-banned a, a.tag-type-banned, .ui-state-focus a.tag-type-banned {
.category-banned a, a.tag-type-banned, .ui-state-active a.tag-type-banned {
color: black;
background-color: red;
}

View File

@@ -57,3 +57,7 @@ div.ui-dialog {
background: linear-gradient(#fefefe, #f0f0f0);
}
}
.ui-front {
z-index: 1000;
}