switch autocomplete plugin to typeahead library
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
//= require jquery-ui-1.8.12.custom.min.js
|
||||
//= require jquery.hotkeys.js
|
||||
//= require jquery.timeout.js
|
||||
//= require typeahead.min.js
|
||||
//= require rails.js
|
||||
//= require common.js
|
||||
//= require_self
|
||||
|
||||
@@ -14,16 +14,14 @@
|
||||
Danbooru.Pool.initialize_add_to_pool_link = function() {
|
||||
$("#add-to-pool-dialog").dialog({autoOpen: false});
|
||||
|
||||
$("#c-pool-elements #a-new input[type=text]").autocomplete({
|
||||
source: function(req, resp) {
|
||||
$.getJSON(
|
||||
"/pools.json?search[is_active]=true&search[name_matches]=" + req.term,
|
||||
function(data) {
|
||||
resp(data.map(function(x) {return x.name.replace(/_/g, " ");}));
|
||||
}
|
||||
);
|
||||
},
|
||||
minLength: 2,
|
||||
$("#c-pool-elements #a-new input[type=text]").typeahead({
|
||||
name: "pools",
|
||||
remote: "/pools.json?search[is_active]=true&search[name_matches]=%QUERY",
|
||||
limit: 10,
|
||||
valueKey: "name",
|
||||
template: function(context) {
|
||||
return "<p>" + context.name.replace(/_/g, " ") + "</p>";
|
||||
}
|
||||
});
|
||||
|
||||
$("#pool").click(function(e) {
|
||||
|
||||
@@ -33,16 +33,14 @@
|
||||
}
|
||||
|
||||
Danbooru.Post.initialize_tag_autocomplete = function() {
|
||||
$("#tags").autocomplete({
|
||||
source: function(req, resp) {
|
||||
$.getJSON(
|
||||
"/tags.json?search[order]=count&search[name_matches]=" + req.term + "*",
|
||||
function(data) {
|
||||
resp(data.map(function(x) {return x.name;}));
|
||||
}
|
||||
);
|
||||
},
|
||||
minLength: 3,
|
||||
$("#tags").typeahead({
|
||||
name: "tags",
|
||||
remote: "/tags.json?search[order]=count&search[name_matches]=%QUERY*",
|
||||
limit: 10,
|
||||
valueKey: "name",
|
||||
template: function(context) {
|
||||
return "<p class=\"category-" + context.category + "\"><a>" + context.name + "</a></p>";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user