post tooltips: add disable option (#3689).
* Add "disable post tooltips" account setting. * Add back title attribute for when fancy tooltips are disabled.
This commit is contained in:
@@ -56,7 +56,11 @@ Danbooru.PostTooltip.QTIP_OPTIONS = {
|
||||
|
||||
Danbooru.PostTooltip.initialize = function () {
|
||||
$(document).on("mouseenter", Danbooru.PostTooltip.POST_SELECTOR, function (event) {
|
||||
$(this).qtip(Danbooru.PostTooltip.QTIP_OPTIONS, event);
|
||||
if (Danbooru.PostTooltip.disabled()) {
|
||||
$(this).qtip("disable");
|
||||
} else {
|
||||
$(this).qtip(Danbooru.PostTooltip.QTIP_OPTIONS, event);
|
||||
}
|
||||
});
|
||||
|
||||
// Hide tooltips when clicking thumbnails.
|
||||
@@ -67,4 +71,8 @@ Danbooru.PostTooltip.hide = function (event) {
|
||||
$(".post-tooltip:visible").qtip("hide");
|
||||
};
|
||||
|
||||
Danbooru.PostTooltip.disabled = function (event) {
|
||||
return Danbooru.meta("disable-post-tooltips") === "true";
|
||||
};
|
||||
|
||||
$(document).ready(Danbooru.PostTooltip.initialize);
|
||||
|
||||
@@ -91,7 +91,7 @@ class UsersController < ApplicationController
|
||||
enable_auto_complete show_deleted_children
|
||||
disable_categorized_saved_searches disable_tagged_filenames
|
||||
enable_recent_searches disable_cropped_thumbnails disable_mobile_gestures
|
||||
enable_safe_mode disable_responsive_mode
|
||||
enable_safe_mode disable_responsive_mode disable_post_tooltips
|
||||
]
|
||||
|
||||
permitted_params += [dmail_filter_attributes: %i[id words]]
|
||||
|
||||
@@ -277,6 +277,10 @@ class AnonymousUser
|
||||
false
|
||||
end
|
||||
|
||||
def disable_post_tooltips?
|
||||
false
|
||||
end
|
||||
|
||||
User::Roles.reject {|r| r == :anonymous}.each do |name|
|
||||
define_method("is_#{name}?") do
|
||||
false
|
||||
|
||||
@@ -58,6 +58,7 @@ class User < ApplicationRecord
|
||||
disable_mobile_gestures
|
||||
enable_safe_mode
|
||||
disable_responsive_mode
|
||||
disable_post_tooltips
|
||||
)
|
||||
|
||||
include Danbooru::HasBitFlags
|
||||
|
||||
@@ -40,7 +40,8 @@ class PostPresenter < Presenter
|
||||
src = post.preview_file_url
|
||||
end
|
||||
|
||||
html << %{<img itemprop="thumbnailUrl" src="#{src}" alt="#{h(post.tag_string)}">}
|
||||
tooltip = "#{post.tag_string} rating:#{post.rating} score:#{post.score}"
|
||||
html << %{<img itemprop="thumbnailUrl" src="#{src}" title="#{h(tooltip)}" alt="#{h(post.tag_string)}">}
|
||||
html << %{</a>}
|
||||
|
||||
if options[:pool]
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<meta name="style-usernames" content="<%= CurrentUser.user.style_usernames? %>">
|
||||
<meta name="last-forum-read-at" content="<%= CurrentUser.user.last_forum_read_at %>">
|
||||
<meta name="disable-labeled-saved-searches" content="<%= CurrentUser.disable_categorized_saved_searches? %>">
|
||||
<meta name="disable-post-tooltips" content="<%= CurrentUser.disable_post_tooltips? %>">
|
||||
<%= content_tag(:meta, nil, name: "disable-mobile-gestures", content: CurrentUser.disable_mobile_gestures?) %>
|
||||
<%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" integrity="sha256-rByPlHULObEjJ6XQxW/flG2r+22R5dKiAoef+aXWfik=" crossorigin="anonymous" />
|
||||
|
||||
@@ -78,6 +78,8 @@
|
||||
|
||||
<%= f.input :disable_mobile_gestures, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
|
||||
|
||||
<%= f.input :disable_post_tooltips, :as => :select, :hint => "Disable advanced tooltips when hovering over thumbnails", :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
|
||||
|
||||
<%#= f.input :disable_cropped_thumbnails, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false %>
|
||||
|
||||
<div class="input text optional field_with_hint">
|
||||
|
||||
Reference in New Issue
Block a user