autocomplete style consistency

This commit is contained in:
Toks 2013-06-28 10:00:45 -04:00
parent cc463fdc4f
commit 7a764b5047
2 changed files with 27 additions and 28 deletions

View File

@ -9,4 +9,3 @@
});
}
})();

View File

@ -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;
});
}
}
})();