autocomplete: unify autocomplete options.
Use a single set of default options so that autocomplete behaves the same way everywhere.
This commit is contained in:
@@ -12,6 +12,16 @@
|
|||||||
Danbooru.Autocomplete.initialize_all = function() {
|
Danbooru.Autocomplete.initialize_all = function() {
|
||||||
if (Danbooru.meta("enable-auto-complete") === "true") {
|
if (Danbooru.meta("enable-auto-complete") === "true") {
|
||||||
$.widget("ui.autocomplete", $.ui.autocomplete, {
|
$.widget("ui.autocomplete", $.ui.autocomplete, {
|
||||||
|
options: {
|
||||||
|
delay: 100,
|
||||||
|
minLength: 1,
|
||||||
|
autoFocus: false,
|
||||||
|
focus: function() { return false; },
|
||||||
|
},
|
||||||
|
_create: function() {
|
||||||
|
this.element.on("keydown.danbooru.autocomplete.tab", null, "tab", Danbooru.Autocomplete.on_tab);
|
||||||
|
this._super();
|
||||||
|
},
|
||||||
_renderItem: Danbooru.Autocomplete.render_item,
|
_renderItem: Danbooru.Autocomplete.render_item,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -51,14 +61,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Autocomplete.initialize_mention_autocomplete = function($fields) {
|
Danbooru.Autocomplete.initialize_mention_autocomplete = function($fields) {
|
||||||
$fields.on("keydown.danbooru.autocomplete.tab", null, "tab", Danbooru.Autocomplete.on_tab);
|
|
||||||
$fields.autocomplete({
|
$fields.autocomplete({
|
||||||
delay: 500,
|
|
||||||
minLength: 2,
|
|
||||||
autoFocus: false,
|
|
||||||
focus: function() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
select: function(event, ui) {
|
select: function(event, ui) {
|
||||||
Danbooru.Autocomplete.insert_completion(this, ui.item.value);
|
Danbooru.Autocomplete.insert_completion(this, ui.item.value);
|
||||||
return false;
|
return false;
|
||||||
@@ -96,13 +99,7 @@
|
|||||||
var $fields_multiple = $('[data-autocomplete="tag-query"], [data-autocomplete="tag-edit"]');
|
var $fields_multiple = $('[data-autocomplete="tag-query"], [data-autocomplete="tag-edit"]');
|
||||||
var $fields_single = $('[data-autocomplete="tag"]');
|
var $fields_single = $('[data-autocomplete="tag"]');
|
||||||
|
|
||||||
$fields_multiple.on("keydown.danbooru.autocomplete.tab", null, "tab", Danbooru.Autocomplete.on_tab);
|
|
||||||
$fields_multiple.autocomplete({
|
$fields_multiple.autocomplete({
|
||||||
delay: 100,
|
|
||||||
autoFocus: false,
|
|
||||||
focus: function() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
select: function(event, ui) {
|
select: function(event, ui) {
|
||||||
// Prevent Danbooru.Upload.initialize_enter_on_tags from running if the
|
// Prevent Danbooru.Upload.initialize_enter_on_tags from running if the
|
||||||
// Enter key is used to select a tag from the autocomplete menu.
|
// Enter key is used to select a tag from the autocomplete menu.
|
||||||
@@ -187,8 +184,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$fields_single.autocomplete({
|
$fields_single.autocomplete({
|
||||||
minLength: 1,
|
|
||||||
autoFocus: true,
|
|
||||||
source: function(req, resp) {
|
source: function(req, resp) {
|
||||||
Danbooru.Autocomplete.normal_source(req.term, resp);
|
Danbooru.Autocomplete.normal_source(req.term, resp);
|
||||||
}
|
}
|
||||||
@@ -197,7 +192,6 @@
|
|||||||
|
|
||||||
Danbooru.Autocomplete.initialize_artist_autocomplete = function($fields) {
|
Danbooru.Autocomplete.initialize_artist_autocomplete = function($fields) {
|
||||||
$fields.autocomplete({
|
$fields.autocomplete({
|
||||||
minLength: 1,
|
|
||||||
source: function(req, resp) {
|
source: function(req, resp) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/artists.json",
|
url: "/artists.json",
|
||||||
@@ -225,7 +219,6 @@
|
|||||||
|
|
||||||
Danbooru.Autocomplete.initialize_pool_autocomplete = function($fields) {
|
Danbooru.Autocomplete.initialize_pool_autocomplete = function($fields) {
|
||||||
$fields.autocomplete({
|
$fields.autocomplete({
|
||||||
minLength: 1,
|
|
||||||
source: function(req, resp) {
|
source: function(req, resp) {
|
||||||
Danbooru.Autocomplete.pool_source(req.term, resp);
|
Danbooru.Autocomplete.pool_source(req.term, resp);
|
||||||
},
|
},
|
||||||
@@ -234,7 +227,6 @@
|
|||||||
|
|
||||||
Danbooru.Autocomplete.initialize_wiki_autocomplete = function($fields) {
|
Danbooru.Autocomplete.initialize_wiki_autocomplete = function($fields) {
|
||||||
$fields.autocomplete({
|
$fields.autocomplete({
|
||||||
minLength: 1,
|
|
||||||
source: function(req, resp) {
|
source: function(req, resp) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/wiki_pages.json",
|
url: "/wiki_pages.json",
|
||||||
|
|||||||
Reference in New Issue
Block a user