comment stream now uses handlebars.
This commit is contained in:
parent
edd8644531
commit
d773749374
4 changed files with 40 additions and 33 deletions
30
app/views/templates/comment_stream.handlebars
Normal file
30
app/views/templates/comment_stream.handlebars
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{{#unless all_comments_loaded}}
|
||||||
|
<ul class="show_comments {{#unless showExpandCommentsLink}} hidden {{/unless}}">
|
||||||
|
<li>
|
||||||
|
<a href="/posts/{{id}}/comments" class="toggle_post_comments">
|
||||||
|
{{t "stream.more_comments" count=moreCommentsCount}}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{/unless}}
|
||||||
|
|
||||||
|
<ul class="comments"> </ul>
|
||||||
|
|
||||||
|
{{#if current_user}}
|
||||||
|
<div class="new_comment_form_wrapper {{#unless comments_count}} hidden {{/unless}}">
|
||||||
|
<form accept-charset="UTF-8" action="/posts/{{id}}/comments" class="new_comment" id="new_comment_on_{{id}}" method="post">
|
||||||
|
{{#with current_user}}
|
||||||
|
<a href="/people/{{guid}}">
|
||||||
|
<img src="{{avatar.small}}" class="avatar" />
|
||||||
|
</a>
|
||||||
|
{{/with}}
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<textarea class="comment_box" id="comment_text_on_{{id}}" name="text" rows="2" placeholder="{{t "stream.comment"}}" />
|
||||||
|
</p>
|
||||||
|
<div class="submit_button">
|
||||||
|
<input class="button creation" id="comment_submit_{{id}}" name="commit" type="submit" value="{{t "stream.comment"}}" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
<% if(typeof(all_comments_loaded) == 'undefined' || !all_comments_loaded) { %>
|
|
||||||
<ul class="show_comments <%= comments_count <= 3 ? 'hidden' : '' %>">
|
|
||||||
<li>
|
|
||||||
<a href="/posts/<%= id %>/comments" class="toggle_post_comments">
|
|
||||||
<%= Diaspora.I18n.t('stream.more_comments', {count : comments_count - 3}) %>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<% } %>
|
|
||||||
|
|
||||||
<ul class="comments"> </ul>
|
|
||||||
|
|
||||||
<% if(current_user) { %>
|
|
||||||
<div class="new_comment_form_wrapper <%= comments_count > 0 ? '' : 'hidden' %>">
|
|
||||||
<form accept-charset="UTF-8" action="/posts/<%= id %>/comments" class="new_comment" id="new_comment_on_<%= id %>" method="post">
|
|
||||||
<a href="/people/<%= current_user.guid %>">
|
|
||||||
<img src="<%= current_user.avatar.small %>" class="avatar" data-person-id="<%= current_user.id %>"/>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<textarea class="comment_box" id="comment_text_on_<%= id %>" name="text" rows="2" placeholder="<%= Diaspora.I18n.t('stream.comment') %>"/>
|
|
||||||
</p>
|
|
||||||
<div class="submit_button">
|
|
||||||
<input class="button creation" id="comment_submit_<%= id %>" name="commit" type="submit" value="<%= Diaspora.I18n.t('stream.comment') %>" />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<% } %>
|
|
||||||
|
|
@ -37,9 +37,8 @@ var app = {
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
Handlebars.registerHelper('t', function(scope, values) {
|
||||||
Handlebars.registerHelper('t', function(){
|
return Diaspora.I18n.t(scope, values.hash)
|
||||||
return Diaspora.I18n.t(arguments[0], jQuery.parseJSON(arguments[1]))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Handlebars.registerHelper('imageUrl', function(path){
|
Handlebars.registerHelper('imageUrl', function(path){
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
app.views.CommentStream = app.views.Base.extend({
|
app.views.CommentStream = app.views.Base.extend({
|
||||||
|
|
||||||
legacyTemplate : true,
|
templateName: "comment-stream",
|
||||||
template_name: "#comment-stream-template",
|
|
||||||
|
|
||||||
className : "comment_stream",
|
className : "comment_stream",
|
||||||
|
|
||||||
|
|
@ -23,6 +22,13 @@ app.views.CommentStream = app.views.Base.extend({
|
||||||
this.$("textarea").autoResize({'extraSpace' : 10});
|
this.$("textarea").autoResize({'extraSpace' : 10});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
presenter: function(){
|
||||||
|
return _.extend(this.defaultPresenter(), {
|
||||||
|
moreCommentsCount : (this.model.get("comments_count") - 3),
|
||||||
|
showExpandCommentsLink : (this.model.get("comments_count") > 3)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
createComment: function(evt) {
|
createComment: function(evt) {
|
||||||
if(evt){ evt.preventDefault(); }
|
if(evt){ evt.preventDefault(); }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue