* Use jquery-ui's autocomplete module instead of typeahead
* Enable support for multiple tag autocomplete
This commit is contained in:
@@ -3,17 +3,32 @@
|
||||
|
||||
Danbooru.WikiPage.initialize_all = function() {
|
||||
if ($("#c-wiki-pages").length) {
|
||||
if (Danbooru.meta("enable-auto-complete") === "true") {
|
||||
$("#quick_search_title,#wiki_page_title").typeahead({
|
||||
name: "wiki_pages",
|
||||
remote: "/wiki_pages.json?search[title]=*%QUERY*",
|
||||
limit: 10,
|
||||
valueKey: "title",
|
||||
template: function(context) {
|
||||
return "<p>" + context.title.replace(/_/g, " ") + "</p>";
|
||||
}
|
||||
});
|
||||
}
|
||||
this.initialize_typeahead();
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.WikiPage.initialize_typeahead = function() {
|
||||
if (Danbooru.meta("enable-auto-complete") === "true") {
|
||||
$("#quick_search_title,#wiki_page_title").autocomplete({
|
||||
source: function(req, resp) {
|
||||
$.ajax({
|
||||
url: "/wiki_pages.json",
|
||||
data: {
|
||||
"search[title]": "*" + req.term + "*"
|
||||
},
|
||||
method: "get",
|
||||
minLength: 2,
|
||||
success: function(data) {
|
||||
resp($.map(data, function(tag) {
|
||||
return {
|
||||
label: tag.title.replace(/_/g, " "),
|
||||
value: tag.title
|
||||
};
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user