mark icons colored if user has interacted with a post.
This commit is contained in:
parent
f4269f2d44
commit
a1fe55fcb7
6 changed files with 45 additions and 5 deletions
|
|
@ -13,6 +13,8 @@ class PostPresenter
|
|||
:post => self.post.as_api_response(:backbone).update(
|
||||
{
|
||||
:user_like => self.user_like,
|
||||
:user_participation => self.user_participation,
|
||||
:user_reshare => self.user_reshare,
|
||||
:next_post => self.next_post_url,
|
||||
:previous_post => self.previous_post_url
|
||||
}),
|
||||
|
|
@ -27,6 +29,19 @@ class PostPresenter
|
|||
end
|
||||
end
|
||||
|
||||
def user_participation
|
||||
return unless self.current_user.present?
|
||||
|
||||
if participation = Participation.where(:target_id => self.post.id, :target_type => "Post", :author_id => current_user.person.id).first
|
||||
participation.as_api_response(:backbone)
|
||||
end
|
||||
end
|
||||
|
||||
def user_reshare
|
||||
return unless self.current_user.present?
|
||||
Reshare.where(:root_guid => self.post.guid, :author_id => current_user.person.id).exists?
|
||||
end
|
||||
|
||||
def next_post_url
|
||||
if n = next_post
|
||||
Rails.application.routes.url_helpers.post_path(n)
|
||||
|
|
|
|||
BIN
public/images/glyphicons-halflings-blue.png
Normal file
BIN
public/images/glyphicons-halflings-blue.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
BIN
public/images/glyphicons-halflings-green.png
Normal file
BIN
public/images/glyphicons-halflings-green.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4 KiB |
BIN
public/images/glyphicons-halflings-red.png
Normal file
BIN
public/images/glyphicons-halflings-red.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4 KiB |
|
|
@ -5,16 +5,28 @@
|
|||
-->
|
||||
|
||||
<a href="#" class="label like" title="{{#if user_like}} Unlike {{else}} Like {{/if}}">
|
||||
{{#if user_like}}
|
||||
<i class="icon-heart icon-red"></i>
|
||||
{{else}}
|
||||
<i class="icon-heart icon-white"></i>
|
||||
{{/if}}
|
||||
</a>
|
||||
|
||||
<a href="#" class="label follow" title="Follow Post">
|
||||
<a href="#" class="label follow" title="{{#if user_participation}} Stop Following {{else}} Follow {{/if}} Post">
|
||||
{{#if user_participation}}
|
||||
<i class="icon-plus icon-green"></i>
|
||||
{{else}}
|
||||
<i class="icon-plus icon-white"></i>
|
||||
{{/if}}
|
||||
</a>
|
||||
|
||||
{{#if userCanReshare}}
|
||||
<a href="#" class="label reshare" title="Reshare">
|
||||
<a href="#" class="label reshare" title="{{#if user_reshare}} Reshared {{else}} Reshare {{/if}}">
|
||||
{{#if user_reshare}}
|
||||
<i class="icon-retweet icon-blue"></i>
|
||||
{{else}}
|
||||
<i class="icon-retweet icon-white"></i>
|
||||
{{/if}}
|
||||
</a>
|
||||
{{/if}}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,6 +95,19 @@ $light-grey: #999;
|
|||
100% { left: 0; }
|
||||
}
|
||||
|
||||
/* bootstrap extentions */
|
||||
.icon-red {
|
||||
background-image: url(../img/glyphicons-halflings-red.png);
|
||||
}
|
||||
|
||||
.icon-green {
|
||||
background-image: url(../img/glyphicons-halflings-green.png);
|
||||
}
|
||||
|
||||
.icon-blue {
|
||||
background-image: url(../img/glyphicons-halflings-blue.png);
|
||||
}
|
||||
|
||||
/* styles */
|
||||
|
||||
.bump-left { @include animation(bump-left) }
|
||||
|
|
|
|||
Loading…
Reference in a new issue