Author
|
zPlus <->
2016-03-19 06:40:05
|
Committer
|
zPlus <->
2016-03-19 06:40:05
|
Commit
|
dc75391
(patch)
|
Tree
|
c41d2da
|
Parent(s)
|
|
Votes template: remove vote arrows if user is not logged in
commits diff:
76b2407..dc75391
4 files changed,
25 insertions,
11 deletions
—
download
Diffstat
Diff options
+2/-1
M template/comment.twig
19
|
19
|
|
target: 'comment',
|
20
|
20
|
|
hash_id: comment.hashId,
|
21
|
21
|
|
vote: votes[comment.id] is defined ? votes[comment.id].vote : null,
|
22
|
|
- |
vote_count: comment.vote
|
|
22
|
+ |
vote_count: comment.vote,
|
|
23
|
+ |
user: user is defined ? user : null
|
23
|
24
|
|
} only
|
24
|
25
|
|
%}
|
25
|
26
|
|
|
+2/-1
M template/index.twig
23
|
23
|
|
target: 'post',
|
24
|
24
|
|
hash_id: post.hashId,
|
25
|
25
|
|
vote: votes[post.id] is defined ? votes[post.id].vote : null,
|
26
|
|
- |
vote_count: post.vote
|
|
26
|
+ |
vote_count: post.vote,
|
|
27
|
+ |
user: user is defined ? user : null
|
27
|
28
|
|
} only
|
28
|
29
|
|
%}
|
29
|
30
|
|
|
+2/-1
M template/post.twig
18
|
18
|
|
target: 'post',
|
19
|
19
|
|
hash_id: post.hashId,
|
20
|
20
|
|
vote: votes.post[post.id] is defined ? votes.post[post.id].vote : null,
|
21
|
|
- |
vote_count: post.vote
|
|
21
|
+ |
vote_count: post.vote,
|
|
22
|
+ |
user: user is defined ? user : null
|
22
|
23
|
|
} only
|
23
|
24
|
|
%}
|
24
|
25
|
|
|
+19/-8
M template/vote.twig
5
|
5
|
|
# - hash_id: the post/comment hashId
|
6
|
6
|
|
# - vote: (optional) the vote already cast by current logged in user
|
7
|
7
|
|
# - vote_count: the sum of votes for this post/comment
|
|
8
|
+ |
# - user: reference to logged in user
|
8
|
9
|
|
#}
|
9
|
10
|
|
|
10
|
11
|
|
<span class="vote">
|
11
|
|
- |
<a href="vote?up&{{ target }}={{ hash_id }}" target="vote_sink" class="{{ vote is defined and vote == 1 ? 'upvoted' }}" onclick="vote ('up', this.parentNode)">
|
12
|
|
- |
<img title="bump" alt="bump" src="images/upvote.png" />
|
13
|
|
- |
</a>
|
14
|
12
|
|
|
15
|
|
- |
{# Show number of votes #}
|
16
|
|
- |
<span class="count">{{ vote_count }}</span>
|
|
13
|
+ |
{% if user %}
|
|
14
|
+ |
|
|
15
|
+ |
<a href="vote?up&{{ target }}={{ hash_id }}" target="vote_sink" class="{{ vote is defined and vote == 1 ? 'upvoted' }}" onclick="vote ('up', this.parentNode)">
|
|
16
|
+ |
<img title="bump" alt="bump" src="images/upvote.png" />
|
|
17
|
+ |
</a>
|
17
|
18
|
|
|
18
|
|
- |
<a href="vote?down&{{ target }}={{ hash_id }}" target="vote_sink" class="{{ vote is defined and vote == -1 ? 'downvoted' }}" onclick="vote ('down', this.parentNode)">
|
19
|
|
- |
<img title="sink" alt="sink" src="images/downvote.png" />
|
20
|
|
- |
</a>
|
|
19
|
+ |
{# Show number of votes #}
|
|
20
|
+ |
<span class="count">{{ vote_count }}</span>
|
|
21
|
+ |
|
|
22
|
+ |
<a href="vote?down&{{ target }}={{ hash_id }}" target="vote_sink" class="{{ vote is defined and vote == -1 ? 'downvoted' }}" onclick="vote ('down', this.parentNode)">
|
|
23
|
+ |
<img title="sink" alt="sink" src="images/downvote.png" />
|
|
24
|
+ |
</a>
|
|
25
|
+ |
|
|
26
|
+ |
{% else %}
|
|
27
|
+ |
|
|
28
|
+ |
{{ vote_count ~ ' vote' ~ (vote_count != 1 ? 's') }}
|
|
29
|
+ |
|
|
30
|
+ |
{% endif %}
|
|
31
|
+ |
|
21
|
32
|
|
</span> |
21
|
32
|
= |
\ No newline at end of file
|