Fix #4930: "Show scores" setting should be preserved
Make "show scores" setting persistent. The setting is stored in a `post_preview_show_votes` cookie. This means it's remembered on a per-device basis, but not on a per-account basis. This is so users without an account can use the setting, and so you can use different settings on desktop and mobile. The `view=score` URL param has been replaced by `show_votes=true`. The `show_votes` URL param overrides the `post_preview_show_votes` cookie.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
<section id="tag-box">
|
||||
<h2>Tags</h2>
|
||||
<%= render_search_tag_list(@post_set.related_tags, current_query: params[:tags], show_extra_links: policy(Post).show_extra_links?, search_params: { view: params[:view], size: params[:size] }) %>
|
||||
<%= render_search_tag_list(@post_set.related_tags, current_query: params[:tags], show_extra_links: policy(Post).show_extra_links?, search_params: { show_votes: params[:show_votes], size: params[:size] }) %>
|
||||
</section>
|
||||
|
||||
<section id="options-box">
|
||||
@@ -75,69 +75,69 @@
|
||||
<a class="mobile-only" href="#search-box">Search »</a>
|
||||
</li>
|
||||
|
||||
<%= render PopupMenuComponent.new(classes: "hidden post-preview-size-menu") do |menu| %>
|
||||
<%= render PopupMenuComponent.new(classes: "post-preview-size-menu") do |menu| %>
|
||||
<% menu.button do %>
|
||||
<span class="text-sm">Size <%= caret_down_icon %></span>
|
||||
<% end %>
|
||||
|
||||
<% menu.item do %>
|
||||
<% if @preview_size == "150" %>
|
||||
<%= link_to "Small", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "150"), class: "font-bold", rel: "nofollow" %>
|
||||
<%= link_to "Small", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "150"), class: "font-bold", rel: "nofollow" %>
|
||||
<% else %>
|
||||
<%= link_to "Small", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "150"), rel: "nofollow" %>
|
||||
<%= link_to "Small", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "150"), rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% menu.item do %>
|
||||
<% if @preview_size == "180" %>
|
||||
<%= link_to "Medium", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "180"), class: "font-bold", rel: "nofollow" %>
|
||||
<%= link_to "Medium", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "180"), class: "font-bold", rel: "nofollow" %>
|
||||
<% else %>
|
||||
<%= link_to "Medium", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "180"), rel: "nofollow" %>
|
||||
<%= link_to "Medium", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "180"), rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% menu.item do %>
|
||||
<% if @preview_size == "225" %>
|
||||
<%= link_to "Large", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "225"), class: "font-bold", rel: "nofollow" %>
|
||||
<%= link_to "Large", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "225"), class: "font-bold", rel: "nofollow" %>
|
||||
<% else %>
|
||||
<%= link_to "Large", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "225"), rel: "nofollow" %>
|
||||
<%= link_to "Large", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "225"), rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%# Mobile only %>
|
||||
<% menu.item do %>
|
||||
<% if @preview_size == "360" %>
|
||||
<%= link_to "Huge", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "360"), class: "mobile-only font-bold", rel: "nofollow" %>
|
||||
<%= link_to "Huge", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "360"), class: "mobile-only font-bold", rel: "nofollow" %>
|
||||
<% else %>
|
||||
<%= link_to "Huge", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "360"), class: "mobile-only", rel: "nofollow" %>
|
||||
<%= link_to "Huge", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "360"), class: "mobile-only", rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%# Desktop only %>
|
||||
<% menu.item do %>
|
||||
<% if @preview_size == "270" %>
|
||||
<%= link_to "Huge", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "270"), class: "desktop-only font-bold", rel: "nofollow" %>
|
||||
<%= link_to "Huge", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "270"), class: "desktop-only font-bold", rel: "nofollow" %>
|
||||
<% else %>
|
||||
<%= link_to "Huge", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "270"), class: "desktop-only", rel: "nofollow" %>
|
||||
<%= link_to "Huge", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "270"), class: "desktop-only", rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%# Desktop only %>
|
||||
<% menu.item do %>
|
||||
<% if @preview_size == "360" %>
|
||||
<%= link_to "Gigantic", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "360"), class: "desktop-only font-bold", rel: "nofollow" %>
|
||||
<%= link_to "Gigantic", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "360"), class: "desktop-only font-bold", rel: "nofollow" %>
|
||||
<% else %>
|
||||
<%= link_to "Gigantic", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: params[:view], size: "360"), class: "desktop-only", rel: "nofollow" %>
|
||||
<%= link_to "Gigantic", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: params[:show_votes], size: "360"), class: "desktop-only", rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= render PopupMenuComponent.new do |menu| %>
|
||||
<%= render PopupMenuComponent.new(classes: "post-preview-options-menu") do |menu| %>
|
||||
<% menu.item do %>
|
||||
<% if params[:view] == "score" %>
|
||||
<%= link_to "Hide scores", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: nil, size: params[:size]), rel: "nofollow" %>
|
||||
<% if @show_votes %>
|
||||
<%= link_to "Hide scores", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: nil, size: params[:size]), class: "post-preview-hide-votes", rel: "nofollow" %>
|
||||
<% else %>
|
||||
<%= link_to "Show scores", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], view: "score", size: params[:size]), rel: "nofollow" %>
|
||||
<%= link_to "Show scores", posts_path(tags: params[:tags], page: params[:page], limit: params[:limit], show_votes: true, size: params[:size]), class: "post-preview-show-votes", rel: "nofollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<% if params[:random] %>
|
||||
<%= hidden_field_tag :random, params[:random] %>
|
||||
<% end %>
|
||||
<% if params[:view] %>
|
||||
<%= hidden_field_tag :view, params[:view] %>
|
||||
<% if params[:show_votes] %>
|
||||
<%= hidden_field_tag :show_votes, params[:show_votes] %>
|
||||
<% end %>
|
||||
<% if params[:size] %>
|
||||
<%= hidden_field_tag :size, params[:size] %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% if @post.valid? %>
|
||||
var $post = $("#post_<%= @post.id %>");
|
||||
var $new_post = $("<%= j post_preview(@post, fit: :compact, show_deleted: true, show_votes: params[:view] == "score", size: @preview_size) %>");
|
||||
var $new_post = $("<%= j post_preview(@post, fit: :compact, show_deleted: true, show_votes: @show_votes, size: @preview_size) %>");
|
||||
Danbooru.Blacklist.apply_post($new_post.get(0));
|
||||
$("#post_<%= @post.id %>").replaceWith($new_post);
|
||||
<% if params[:mode] == "quick-edit" %>
|
||||
|
||||
Reference in New Issue
Block a user