Allow #image-container to share data attributes with previews

Related to #1902
This commit is contained in:
Toks
2013-08-07 20:07:47 -04:00
parent 1c44aa0271
commit f3167f1f62
5 changed files with 16 additions and 17 deletions

View File

@@ -12,7 +12,7 @@ class PostPresenter < Presenter
path = options[:path_prefix] || "/posts"
html = %{<article class="#{preview_class(post)}" #{preview_attributes(post)}>}
html = %{<article id="post_#{post.id}" class="#{preview_class(post)}" #{data_attributes(post)}>}
if options[:tags].present?
tag_param = "?tags=#{CGI::escape(options[:tags])}"
elsif options[:pool_id]
@@ -37,20 +37,19 @@ class PostPresenter < Presenter
klass
end
def self.preview_attributes(post)
def self.data_attributes(post)
%{
id="post_#{post.id}"
data-id="#{post.id}"
data-tags="#{h(post.tag_string)}"
data-id="#{post.id}"
data-tags="#{h(post.tag_string)}"
data-pools="#{post.pool_string}"
data-uploader="#{h(post.uploader_name)}"
data-rating="#{post.rating}"
data-width="#{post.image_width}"
data-height="#{post.image_height}"
data-flags="#{post.status_flags}"
data-parent-id="#{post.parent_id}"
data-has-children="#{post.has_children?}"
data-score="#{post.score}"
data-uploader="#{h(post.uploader_name)}"
data-rating="#{post.rating}"
data-width="#{post.image_width}"
data-height="#{post.image_height}"
data-flags="#{post.status_flags}"
data-parent-id="#{post.parent_id}"
data-has-children="#{post.has_children?}"
data-score="#{post.score}"
data-fav-count="#{post.fav_count}"
}.html_safe
end

View File

@@ -5,7 +5,7 @@
<div class="comments-for-post">
<div class="list-of-comments">
<% @comments.each do |comment| %>
<div class="post <%= PostPresenter.preview_class(comment.post) %>" <%= PostPresenter.preview_attributes(comment.post) %>>
<div id="post_<%= comment.post.id %>" class="post <%= PostPresenter.preview_class(comment.post) %>" <%= PostPresenter.data_attributes(comment.post) %>>
<div class="preview">
<% if comment.post.visible? %>
<%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %>

View File

@@ -12,7 +12,7 @@
<% end %>
<% @posts.select {|x| Danbooru.config.can_user_see_post?(CurrentUser.user, x)}.each do |post| %>
<div class="post <%= PostPresenter.preview_class(post) %>" <%= PostPresenter.preview_attributes(post) %>>
<div id="post_<%= post.id %>" class="post <%= PostPresenter.preview_class(post) %>" <%= PostPresenter.data_attributes(post) %>>
<div class="preview">
<% if post.visible? %>
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>

View File

@@ -2,7 +2,7 @@
<div id="a-show">
<div class="comments-for-post">
<div class="list-of-comments">
<div class="post <%= PostPresenter.preview_class(@comment.post) %>" data-tags="<%= @comment.post.tag_string %>" data-uploader="<%= @comment.post.uploader_name %>" data-rating="<%= @comment.post.rating %>" data-flags="<%= @comment.post.status %>" data-score="<%= @comment.post.score %>" data-parent-id="<%= @comment.post.parent_id %>" data-has-children="<%= @comment.post.has_children? %>">
<div id="post_<%= @comment.post.id %>" class="post <%= PostPresenter.preview_class(@comment.post) %>" <%= PostPresenter.data_attributes(@comment.post) %>>
<div class="preview">
<% if @comment.post.visible? %>
<%= link_to(image_tag(@comment.post.preview_file_url), post_path(@comment.post)) %>

View File

@@ -40,7 +40,7 @@
<%= render "posts/partials/show/notices", :post => @post %>
<section id="image-container" data-tags="<%= @post.tag_string %>" data-uploader="<%= @post.uploader_name %>" data-rating="<%= @post.rating %>" data-flags="<%= @post.status_flags %>">
<section id="image-container" <%= PostPresenter.data_attributes(@post) %>>
<div id="note-container"></div>
<div id="note-preview"></div>
<%= @post.presenter.image_html(self) %>