forked from e621ng/e621ng
autocomplete style consistency
This commit is contained in:
parent
cc463fdc4f
commit
7a764b5047
@ -9,4 +9,3 @@
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
|
@ -3,36 +3,37 @@
|
||||
|
||||
Danbooru.WikiPage.initialize_all = function() {
|
||||
if ($("#c-wiki-pages").length) {
|
||||
this.initialize_typeahead();
|
||||
if (Danbooru.meta("enable-auto-complete") === "true") {
|
||||
this.initialize_autocomplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.WikiPage.initialize_typeahead = function() {
|
||||
if (Danbooru.meta("enable-auto-complete") === "true") {
|
||||
var $fields = $("#search_title,#quick_search_title");
|
||||
Danbooru.WikiPage.initialize_autocomplete = function() {
|
||||
var $fields = $("#search_title,#quick_search_title");
|
||||
|
||||
$fields.autocomplete({
|
||||
minLength: 1,
|
||||
source: function(req, resp) {
|
||||
$.ajax({
|
||||
url: "/wiki_pages.json",
|
||||
data: {
|
||||
"search[title]": "*" + req.term + "*",
|
||||
"limit": 10
|
||||
},
|
||||
method: "get",
|
||||
success: function(data) {
|
||||
resp($.map(data, function(wiki_page) {
|
||||
return {
|
||||
label: wiki_page.title.replace(/_/g, " "),
|
||||
value: wiki_page.title,
|
||||
category: wiki_page.category_name
|
||||
};
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$fields.autocomplete({
|
||||
minLength: 1,
|
||||
source: function(req, resp) {
|
||||
$.ajax({
|
||||
url: "/wiki_pages.json",
|
||||
data: {
|
||||
"search[title]": "*" + req.term + "*",
|
||||
"limit": 10
|
||||
},
|
||||
method: "get",
|
||||
success: function(data) {
|
||||
resp($.map(data, function(wiki_page) {
|
||||
return {
|
||||
label: wiki_page.title.replace(/_/g, " "),
|
||||
value: wiki_page.title,
|
||||
category: wiki_page.category_name
|
||||
};
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var render_wiki_page = function(list, wiki_page) {
|
||||
var $link = $("<a/>").addClass("tag-type-" + wiki_page.category).text(wiki_page.label);
|
||||
@ -42,7 +43,6 @@
|
||||
$fields.each(function(i, field) {
|
||||
$(field).data("uiAutocomplete")._renderItem = render_wiki_page;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user