replace two underscore templates with their handlebars counterparts

This commit is contained in:
danielgrippi 2012-02-05 12:50:28 -08:00
parent 39ff47150b
commit 5a72f868d3
7 changed files with 77 additions and 47 deletions

View file

@ -1,26 +0,0 @@
<span class="post_scope">
<%= public ? Diaspora.I18n.t("stream.public") : Diaspora.I18n.t("stream.limited") %>
<% if(provider_display_name) { %>
<strong>
via <%= provider_display_name %>
</strong>
<% } %>
</span>
<a href="#" class="like_action" rel='nofollow'>
<%= user_like ? Diaspora.I18n.t("stream.unlike") : Diaspora.I18n.t("stream.like") %>
</a>
·
<% if(public && author.id != current_user.id && (post_type == "Reshare" ? root : true)) { %>
<a href="#" class="reshare_action" rel='nofollow'>
<%= Diaspora.I18n.t("stream.reshare") %>
</a>
·
<% } %>
<a href="#" class="focus_comment_textarea" rel="nofollow">
<%= Diaspora.I18n.t("stream.comment") %>
</a>

View file

@ -1,16 +0,0 @@
<% if(likes_count > 0) { %>
<img alt="Heart" src="/images/icons/pin.png" />
<% if(likes && likes.length == 0) { %>
<a href="#" class="expand_likes">
<%= Diaspora.I18n.t('stream.likes', {count: likes_count}) %>
</a>
<% } else { %>
<span class="likes_list">
<% _.each(likes, function(like){ %>
<a href="/people/<%= like.get("author").guid %>">
<img src="<%= like.get("author").avatar.small %>" class="avatar" title="<%= like.get("author").name %>"/>
</a>
<% }) %>
</span>
<% } %>
<% } %>

View file

@ -0,0 +1,35 @@
<span class="post_scope">
{{#if public}}
{{t "stream.public"}}
{{else}}
{{t "stream.limited"}}
{{/if}}
{{#if provider_display_name}}
<strong>
via {{provider_display_name}}
</strong>
{{/if}}
</span>
<a href="#" class="like_action" rel='nofollow'>
{{#if user_like}}
{{t "stream.unlike"}}
{{else}}
{{t "stream.like"}}
{{/if}}
</a>
·
{{#if userCanReshare}}
<a href="#" class="reshare_action" rel='nofollow'>
{{t "stream.reshare"}}
</a>
·
{{/if}}
<a href="#" class="focus_comment_textarea" rel="nofollow">
{{t "stream.comment"}}
</a>

View file

@ -0,0 +1,24 @@
{{#if likes_count}}
<img alt="Heart" src="/images/icons/pin.png" />
{{#unless likes.length}}
<a href="#" class="expand_likes">
{{t "stream.likes" count=likes_count}}
</a>
{{else}}
<span class="likes_list">
{{#each likes}}
{{#with attributes.author}}
<a href="/people/{{guid}}">
<img src="{{avatar.small}}" class="avatar" title="{{name}}"/>
</a>
{{/with}}
{{/each}}
</span>
{{/unless}}
{{/if}}

View file

@ -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;
}
})

View file

@ -1,7 +1,6 @@
app.views.LikesInfo = app.views.StreamObject.extend({
legacyTemplate : true,
template_name : "#likes-info-template",
templateName : "likes-info",
className : "likes_container",