Include aliased tags in autocomplete

This commit is contained in:
Toks
2015-04-03 19:31:46 -04:00
parent d59b442f38
commit 558fd4d8ef
8 changed files with 65 additions and 4 deletions

View File

@@ -173,11 +173,9 @@
}
$.ajax({
url: "/tags.json",
url: "/tags/autocomplete.json",
data: {
"search[order]": "count",
"search[name_matches]": term + "*",
"limit": 10
},
method: "get",
success: function(data) {
@@ -185,6 +183,7 @@
return {
type: "tag",
label: tag.name.replace(/_/g, " "),
antecedent: tag.antecedent_name,
value: tag.name,
category: tag.category,
post_count: tag.post_count
@@ -202,7 +201,16 @@
}
Danbooru.Autocomplete.render_item = function(list, item) {
var $link = $("<a/>").text(item.label);
var $link = $("<a/>");
if (item.antecedent) {
var antecedent = item.antecedent.replace(/_/g, " ");
var arrow = $("<span/>").html(" &rarr; ").addClass("autocomplete-arrow");
$link.append(document.createTextNode(antecedent));
$link.append(arrow);
}
$link.append(document.createTextNode(item.label));
$link.attr("href", "/posts?tags=" + encodeURIComponent(item.value));
$link.click(function(e) {
e.preventDefault();