diff --git a/app/views/templates/feedback.jst b/app/views/templates/feedback.jst deleted file mode 100644 index fcd0d6e45..000000000 --- a/app/views/templates/feedback.jst +++ /dev/null @@ -1,26 +0,0 @@ - - <%= public ? Diaspora.I18n.t("stream.public") : Diaspora.I18n.t("stream.limited") %> - <% if(provider_display_name) { %> - - via <%= provider_display_name %> - - <% } %> - -– - - - <%= user_like ? Diaspora.I18n.t("stream.unlike") : Diaspora.I18n.t("stream.like") %> - -· - -<% if(public && author.id != current_user.id && (post_type == "Reshare" ? root : true)) { %> - - <%= Diaspora.I18n.t("stream.reshare") %> - - · -<% } %> - - - <%= Diaspora.I18n.t("stream.comment") %> - - diff --git a/app/views/templates/likes_info.jst b/app/views/templates/likes_info.jst deleted file mode 100644 index 1971e4d44..000000000 --- a/app/views/templates/likes_info.jst +++ /dev/null @@ -1,16 +0,0 @@ -<% if(likes_count > 0) { %> - Heart - <% if(likes && likes.length == 0) { %> - - <%= Diaspora.I18n.t('stream.likes', {count: likes_count}) %> - - <% } else { %> - - <% _.each(likes, function(like){ %> - "> - " class="avatar" title="<%= like.get("author").name %>"/> - - <% }) %> - - <% } %> -<% } %> diff --git a/app/views/templates/reshare_feedback.jst b/app/views/templates/reshare_feedback.jst deleted file mode 100644 index e69de29bb..000000000 diff --git a/public/javascripts/app/templates/feedback.handlebars b/public/javascripts/app/templates/feedback.handlebars new file mode 100644 index 000000000..e20eb156a --- /dev/null +++ b/public/javascripts/app/templates/feedback.handlebars @@ -0,0 +1,35 @@ + + {{#if public}} + {{t "stream.public"}} + {{else}} + {{t "stream.limited"}} + {{/if}} + + {{#if provider_display_name}} + + via {{provider_display_name}} + + {{/if}} + +– + + + {{#if user_like}} + {{t "stream.unlike"}} + {{else}} + {{t "stream.like"}} + {{/if}} + +· + +{{#if userCanReshare}} + + {{t "stream.reshare"}} + + · +{{/if}} + + + {{t "stream.comment"}} + + diff --git a/public/javascripts/app/templates/likes-info.handlebars b/public/javascripts/app/templates/likes-info.handlebars new file mode 100644 index 000000000..6d6357e6c --- /dev/null +++ b/public/javascripts/app/templates/likes-info.handlebars @@ -0,0 +1,24 @@ +{{#if likes_count}} + Heart + {{#unless likes.length}} + + + {{t "stream.likes" count=likes_count}} + + + {{else}} + + + + {{#each likes}} + {{#with attributes.author}} + + + + {{/with}} + {{/each}} + + + + {{/unless}} +{{/if}} diff --git a/public/javascripts/app/views/feedback_view.js b/public/javascripts/app/views/feedback_view.js index 4ab7c4c63..3337906ed 100644 --- a/public/javascripts/app/views/feedback_view.js +++ b/public/javascripts/app/views/feedback_view.js @@ -1,6 +1,6 @@ app.views.Feedback = app.views.StreamObject.extend({ - legacyTemplate : true, - template_name: "#feedback-template", + + templateName: "feedback", className : "info", @@ -9,12 +9,18 @@ app.views.Feedback = app.views.StreamObject.extend({ "click .reshare_action": "resharePost" }, + presenter : function() { + return _.extend(this.defaultPresenter(), { + userCanReshare : this.userCanReshare() + }) + }, + toggleLike: function(evt) { if(evt) { evt.preventDefault(); } this.model.toggleLike(); }, - resharePost : function(evt){ + resharePost : function(evt) { if(evt) { evt.preventDefault(); } if(!window.confirm("Reshare " + this.model.reshareAuthor().name + "'s post?")) { return } var reshare = this.model.reshare() @@ -24,5 +30,13 @@ app.views.Feedback = app.views.StreamObject.extend({ app.stream.add(reshare); } }); + }, + + userCanReshare : function() { + var publicPost = this.model.get("public"); + var userIsNotAuthor = this.model.get("author").id != app.user().id; + var rootExists = (this.model.get("post_type") == "Reshare" ? this.model.get("root") : true); + + return publicPost && userIsNotAuthor && rootExists; } }) diff --git a/public/javascripts/app/views/likes_info_view.js b/public/javascripts/app/views/likes_info_view.js index 9d87af7be..3b5a3c059 100644 --- a/public/javascripts/app/views/likes_info_view.js +++ b/public/javascripts/app/views/likes_info_view.js @@ -1,7 +1,6 @@ app.views.LikesInfo = app.views.StreamObject.extend({ - legacyTemplate : true, - template_name : "#likes-info-template", + templateName : "likes-info", className : "likes_container",