users: remove option to disable autocomplete.

This option was originally added in issue #1747. But only ~350 users
ever disabled autocomplete, only ~120 of these were seen in the last
year, and only 9 new users who signed up in the last year disabled it.

Users wishing to disable autocomplete can use this CSS:

    .ui-autocomplete { display: none !important: }

or this Javascript:

    $("[data-autocomplete]").autocomplete("disable");
This commit is contained in:
evazion
2021-01-14 20:31:00 -06:00
parent 4719a5ed1c
commit d408ccbd41
8 changed files with 38 additions and 46 deletions

View File

@@ -10,6 +10,8 @@
* Removed the option to disable keyboard shortcuts.
* Removed the option to disable tag autocomplete.
## 2021-01-12
### Changes

View File

@@ -289,8 +289,8 @@ module ApplicationHelper
%i[
id name level level_string theme always_resize_images can_upload_free
can_approve_posts disable_categorized_saved_searches
disable_mobile_gestures disable_post_tooltips enable_auto_complete
enable_safe_mode hide_deleted_posts show_deleted_children style_usernames
disable_mobile_gestures disable_post_tooltips enable_safe_mode
hide_deleted_posts show_deleted_children style_usernames
default_image_size
] + User::Roles.map { |role| :"is_#{role}?" }
end

View File

@@ -10,37 +10,35 @@ Autocomplete.TAG_PREFIXES = "-|~|" + Object.keys(Autocomplete.TAG_CATEGORIES).ma
Autocomplete.MAX_RESULTS = 10;
Autocomplete.initialize_all = function() {
if (CurrentUser.data("enable-auto-complete")) {
$.widget("ui.autocomplete", $.ui.autocomplete, {
options: {
delay: 0,
minLength: 1,
autoFocus: false,
focus: function() { return false; },
},
_create: function() {
this.element.on("keydown.Autocomplete.tab", null, "tab", Autocomplete.on_tab);
this._super();
},
_renderItem: Autocomplete.render_item,
search: function(value, event) {
if ($(this).data("ui-autocomplete")) {
$(this).data("ui-autocomplete").menu.bindings = $();
}
this._super(value, event);
},
});
$.widget("ui.autocomplete", $.ui.autocomplete, {
options: {
delay: 0,
minLength: 1,
autoFocus: false,
focus: function() { return false; },
},
_create: function() {
this.element.on("keydown.Autocomplete.tab", null, "tab", Autocomplete.on_tab);
this._super();
},
_renderItem: Autocomplete.render_item,
search: function(value, event) {
if ($(this).data("ui-autocomplete")) {
$(this).data("ui-autocomplete").menu.bindings = $();
}
this._super(value, event);
},
});
this.initialize_tag_autocomplete();
this.initialize_mention_autocomplete($("form div.input.dtext textarea"));
this.initialize_fields($('[data-autocomplete="tag"]'), "tag");
this.initialize_fields($('[data-autocomplete="artist"]'), "artist");
this.initialize_fields($('[data-autocomplete="pool"]'), "pool");
this.initialize_fields($('[data-autocomplete="user"]'), "user");
this.initialize_fields($('[data-autocomplete="wiki-page"]'), "wiki_page");
this.initialize_fields($('[data-autocomplete="favorite-group"]'), "favorite_group");
this.initialize_fields($('[data-autocomplete="saved-search-label"]'), "saved_search_label");
}
this.initialize_tag_autocomplete();
this.initialize_mention_autocomplete($("form div.input.dtext textarea"));
this.initialize_fields($('[data-autocomplete="tag"]'), "tag");
this.initialize_fields($('[data-autocomplete="artist"]'), "artist");
this.initialize_fields($('[data-autocomplete="pool"]'), "pool");
this.initialize_fields($('[data-autocomplete="user"]'), "user");
this.initialize_fields($('[data-autocomplete="wiki-page"]'), "wiki_page");
this.initialize_fields($('[data-autocomplete="favorite-group"]'), "favorite_group");
this.initialize_fields($('[data-autocomplete="saved-search-label"]'), "saved_search_label");
}
Autocomplete.initialize_fields = function($fields, type) {

View File

@@ -1,4 +1,3 @@
import CurrentUser from './current_user'
import Post from './posts.js.erb'
import Utility from './utility'
@@ -77,9 +76,7 @@ PostModeMenu.initialize_edit_form = function() {
PostModeMenu.close_edit_form = function() {
$("#quick-edit-div").slideUp("fast");
if (CurrentUser.data("enable-auto-complete")) {
$("#post_tag_string").data("uiAutocomplete").close();
}
$("#post_tag_string").data("uiAutocomplete").close();
}
PostModeMenu.initialize_tag_script_field = function() {

View File

@@ -117,9 +117,7 @@ Post.open_edit_dialog = function() {
of: window
},
drag: function(e, ui) {
if (CurrentUser.data("enable-auto-complete")) {
$tag_string.data("uiAutocomplete").close();
}
$tag_string.data("uiAutocomplete").close();
},
close: Post.close_edit_dialog
});

View File

@@ -698,7 +698,6 @@ class User < ApplicationRecord
def initialize_attributes
self.new_post_navigation_layout = true
self.enable_auto_complete = true
self.always_resize_images = true
end

View File

@@ -45,11 +45,10 @@ class UserPolicy < ApplicationPolicy
:blacklisted_tags, :time_zone, :per_page, :custom_style, :theme,
:receive_email_notifications, :always_resize_images,
:new_post_navigation_layout, :enable_private_favorites,
:hide_deleted_posts, :style_usernames, :enable_auto_complete,
:show_deleted_children, :disable_categorized_saved_searches,
:disable_tagged_filenames, :disable_cropped_thumbnails,
:disable_mobile_gestures, :enable_safe_mode, :enable_desktop_mode,
:disable_post_tooltips,
:hide_deleted_posts, :style_usernames, :show_deleted_children,
:disable_categorized_saved_searches, :disable_tagged_filenames,
:disable_cropped_thumbnails, :disable_mobile_gestures, :enable_safe_mode,
:enable_desktop_mode, :disable_post_tooltips,
].compact
end

View File

@@ -62,7 +62,6 @@
<%= f.input :new_post_navigation_layout, :as => :select, :label => "Navigation bar position", :include_blank => false, :collection => [["Below", "true"], ["Above", "false"]], :hint => "When browsing pools or posts, place navigation links above or below the image" %>
<%= f.input :hide_deleted_posts, :as => :select, :label => "Deleted post filter", :hint => "Remove deleted posts from search results", :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %>
<%= f.input :show_deleted_children, :as => :select, :label => "Show deleted children", :hint => "Show thumbnail borders on parent posts even if the children are deleted", :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %>
<%= f.input :enable_auto_complete, :as => :select, :hint => "Enable tag autocomplete in the search box", :collection => [["Yes", "true"], ["No", "false"]], :include_blank => false %>
<%= f.input :disable_categorized_saved_searches, :hint => "Don't show dialog box when creating a new saved search", :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
<%= f.input :enable_private_favorites, :as => :select, :hint => "Make your favorites private", :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
<%= f.input :disable_tagged_filenames, :as => :select, :hint => "Don't include tags in image filenames", :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>