Hide 0 likes.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Oct 2010 10:43:15 +0000 (12:43 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Oct 2010 10:43:15 +0000 (12:43 +0200)
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js
src/main/resources/templates/include/viewPost.html

index bd640bc..bb7f740 100644 (file)
@@ -56,6 +56,7 @@ import net.pterodactylus.util.logging.Logging;
 import net.pterodactylus.util.service.AbstractService;
 import net.pterodactylus.util.template.DateFilter;
 import net.pterodactylus.util.template.DefaultTemplateFactory;
+import net.pterodactylus.util.template.MatchFilter;
 import net.pterodactylus.util.template.PaginationPlugin;
 import net.pterodactylus.util.template.ReflectionAccessor;
 import net.pterodactylus.util.template.Template;
@@ -181,6 +182,7 @@ public class WebInterface extends AbstractService {
                templateFactory.addFilter("substring", new SubstringFilter());
                templateFactory.addFilter("xml", new XmlFilter());
                templateFactory.addFilter("change", new RequestChangeFilter());
+               templateFactory.addFilter("match", new MatchFilter());
                templateFactory.addPlugin("getpage", new GetPagePlugin());
                templateFactory.addPlugin("paginate", new PaginationPlugin());
                templateFactory.setTemplateProvider(new ClassPathTemplateProvider(templateFactory));
index f6628ce..cbf69a6 100644 (file)
@@ -148,6 +148,10 @@ textarea {
        font: inherit;
 }
 
+#sone .post .likes.hidden {
+       display: none;
+}
+
 #sone .post .like.hidden, #sone .post .unlike.hidden {
        display: none;
 }
index 9bb379c..be7deaa 100644 (file)
@@ -286,6 +286,7 @@ function unlikePost(postId) {
 function updatePostLikes(postId) {
        $.getJSON("ajax/getPostLikes.ajax", { "post": postId }, function(data, textStatus) {
                if (data.success) {
+                       $("#sone .post#" + postId + " > .status-line .likes").toggleClass("hidden", data.likes == 0)
                        $("#sone .post#" + postId + " > .status-line .likes span.like-count").text(data.likes);
                }
        });
index c3ad07a..991ccec 100644 (file)
@@ -5,7 +5,7 @@
        </div>
        <div class="status-line">
                <div class="time"><a href="viewPost.html?post=<% post.id|html>"><% post.time|date format="MMM d, yyyy, HH:mm:ss"></a></div>
-               <div class="likes"><span>⬆<span class="like-count"><% post.likes.size></span></span></div>
+               <div class="likes<%if post.likes.size|match value=0> hidden<%/if>"><span>⬆<span class="like-count"><% post.likes.size></span></span></div>
                <%ifnull ! currentSone>
                        <form class="like<%if post.liked> hidden<%/if>" action="likePost.html" method="post">
                                <input type="hidden" name="formPassword" value="<% formPassword|html>" />