bind Twipsy in stream_element_view.js

This commit is contained in:
danielgrippi 2011-12-13 20:30:06 -08:00 committed by Dennis Collinson
parent 525fd3c4e4
commit dc82316f13
2 changed files with 27 additions and 14 deletions

View file

@ -2,12 +2,12 @@
<div class="right controls">
<% if(author.id != current_user.id) { %>
<a href="/blocks?block[person_id]=<%= author.id %>" class="block_user control_icon" data-confirm="Ignore and remove user from all aspects?" data-method="post" rel="nofollow" data-original-title="Ignore">
<img alt="Ignoreuser" src="/images/icons/ignoreuser.png">
<a href="/blocks?block[person_id]=<%= author.id %>" class="block_user control_icon" data-confirm="Ignore and remove user from all aspects?" data-method="post" rel="nofollow" title="Ignore">
<img alt="Ignoreuser" src="/images/icons/ignoreuser.png"/>
</a>
<% } %>
<a href="#" class="delete control_icon remove_post">
<a href="#" class="delete control_icon remove_post" title="Delete">
<img src="/images/deletelabel.png"/>
</a>
@ -57,7 +57,8 @@
-
</span>
<% } %>
<span class="post_scope">
<span class="post_scope" title="<%= public ? 'Viewable to anyone on the web' : 'Only certain people can see this'%>">
<%= public ? "Public" : "Limited" %>
-
</span>
@ -90,8 +91,6 @@
</span>
<% } %>
<a href="#" class="focus_comment_textarea">
Comment
</a>

View file

@ -9,21 +9,17 @@ App.Views.Post = App.Views.StreamObject.extend({
},
render: function() {
var self = this;
this.el = $(this.template($.extend(
this.model.toJSON(),
App.user()
)))[0];
this.delegateEvents(); //we need this because we are explicitly setting this.el in this.render()
this.$(".comments").html(new App.Views.CommentStream({
model: this.model
}).render().el);
this.renderPostContent();
this.initializeTooltips()
.renderPostContent()
.renderComments();
this.$(".details time").timeago();
this.delegateEvents(); //we need this because we are explicitly setting this.el in this.render()
return this;
},
@ -38,6 +34,24 @@ App.Views.Post = App.Views.StreamObject.extend({
return this;
},
renderComments: function(){
this.$(".comments").html(new App.Views.CommentStream({
model: this.model
}).render().el);
return this;
},
initializeTooltips: function(){
$([
this.$(".delete"),
this.$(".block_user"),
this.$(".post_scope")
]).map(function() { this.twipsy(); });
return this;
},
focusCommentTextarea: function(evt){
evt.preventDefault();
this.$(".new_comment_form_wrapper").removeClass("hidden");