diff --git a/app/assets/javascripts/app/pages/post-viewer.js b/app/assets/javascripts/app/pages/post-viewer.js index 71f1d663d..4793baaec 100644 --- a/app/assets/javascripts/app/pages/post-viewer.js +++ b/app/assets/javascripts/app/pages/post-viewer.js @@ -9,7 +9,7 @@ app.pages.PostViewer = app.views.Base.extend({ }, initialize : function(options) { - var post = this.model = new app.models.Post({ id : options.id }); + this.model = new app.models.Post({ id : options.id }); this.model.preloadOrFetch().done(_.bind(this.initViews, this)); this.model.interactions.fetch() //async, yo, might want to throttle this later. diff --git a/app/assets/javascripts/app/pages/stream.js b/app/assets/javascripts/app/pages/stream.js index 477257de5..99c2df8b4 100644 --- a/app/assets/javascripts/app/pages/stream.js +++ b/app/assets/javascripts/app/pages/stream.js @@ -11,7 +11,8 @@ app.pages.Stream = app.views.Base.extend({ templateName : "stream", subviews : { - "#stream-content" : "streamView" + "#stream-content" : "streamView", + "#stream-interactions" : "interactionsView" }, initialize : function(){ @@ -19,5 +20,10 @@ app.pages.Stream = app.views.Base.extend({ this.stream.preloadOrFetch(); this.streamView = new app.views.NewStream({ model : this.stream }) + var interactions = this.interactionsView = new app.views.StreamInteractions() + + this.on("frame:interacted", function(post){ + interactions.setInteractions(post) + }) } }); diff --git a/app/assets/javascripts/app/views/feedback_actions.js b/app/assets/javascripts/app/views/feedback_actions.js index aaf638997..60f26237f 100644 --- a/app/assets/javascripts/app/views/feedback_actions.js +++ b/app/assets/javascripts/app/views/feedback_actions.js @@ -1,4 +1,5 @@ //=require "./feedback_view" app.views.FeedbackActions = app.views.Feedback.extend({ + id : "user-controls", templateName : "feedback-actions" -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/app/assets/javascripts/app/views/post-viewer/interactions.js b/app/assets/javascripts/app/views/post-viewer/interactions.js index 7d78f7264..b9206ee2a 100644 --- a/app/assets/javascripts/app/views/post-viewer/interactions.js +++ b/app/assets/javascripts/app/views/post-viewer/interactions.js @@ -5,8 +5,7 @@ app.views.PostViewerInteractions = app.views.Base.extend({ subviews : { "#post-feedback" : "feedbackView", "#post-reactions" : "reactionsView", - "#new-post-comment" : "newCommentView", - ".interaction_counts" : "interactionCountsView" + "#new-post-comment" : "newCommentView" }, templateName: "post-viewer/interactions", diff --git a/app/assets/javascripts/app/views/post/stream_frame.js b/app/assets/javascripts/app/views/post/stream_frame.js index 8d04e08fc..735f558db 100644 --- a/app/assets/javascripts/app/views/post/stream_frame.js +++ b/app/assets/javascripts/app/views/post/stream_frame.js @@ -1,24 +1,9 @@ app.views.Post.StreamFrame = app.views.Post.SmallFrame.extend({ - events :_.extend({ - 'click .content' : 'fetchInteractions' + events : _.extend({ + 'click .content' : 'triggerInteracted' }, app.views.Post.SmallFrame.prototype.events), - subviews :_.extend({ - '.interactions' : 'interactionsView' - }, app.views.Post.SmallFrame.prototype.subviews), - - initialize : function(){ - this.interactionsView = new app.views.StreamInteractions({model : this.model}) - }, - - postRenderTemplate : function(){ - this.addStylingClasses() - this.$el.append($("
")) - }, - - fetchInteractions : function() { - this.model.interactions.fetch().done(_.bind(function(){ - this.interactionsView.render() - }, this)); + triggerInteracted : function() { + app.page.trigger("frame:interacted", this.model) } }) \ No newline at end of file diff --git a/app/assets/javascripts/app/views/post/stream_interactions_view.js b/app/assets/javascripts/app/views/post/stream_interactions_view.js index 5a6282aa8..8bff9c8f6 100644 --- a/app/assets/javascripts/app/views/post/stream_interactions_view.js +++ b/app/assets/javascripts/app/views/post/stream_interactions_view.js @@ -1,13 +1,27 @@ app.views.StreamInteractions = app.views.Base.extend({ - subviews : { + + id : "post-info", + + subviews:{ ".feedback" : "feedback", - ".comments" : "comments" + ".comments" : "comments", + ".new-comment" : "newCommentView" }, templateName : "stream-interactions", - initialize : function(){ - this.feedback = new app.views.FeedbackActions({ model : this.model }) - this.comments = new app.views.PostViewerFeedback({ model : this.model }) + setInteractions : function (model) { + model.interactions.fetch().done( + _.bind(function () { + this.render() + }, this)); + + this.feedback = new app.views.FeedbackActions({ model: model }) + this.comments = new app.views.PostViewerReactions({ model: model.interactions }) + this.newCommentView = new app.views.PostViewerNewComment({ model : model }) + }, + + postRenderTemplate : function(){ + console.log(this.$el) } -}) \ No newline at end of file +}); diff --git a/app/assets/stylesheets/new_styles/_interactions.scss b/app/assets/stylesheets/new_styles/_interactions.scss index ef967d595..7aa30a8ef 100644 --- a/app/assets/stylesheets/new_styles/_interactions.scss +++ b/app/assets/stylesheets/new_styles/_interactions.scss @@ -307,4 +307,20 @@ position: absolute; right: 8px; top: 8px; +} + + +/* stream specific wrapper */ +#stream-interactions { + position : fixed; + width : 420px; + + #post-info { + text-align : left; + margin-top : 10px; + } + + #user-controls { + padding : 7px; + } } \ No newline at end of file diff --git a/app/assets/templates/feedback-actions.jst.hbs b/app/assets/templates/feedback-actions.jst.hbs index 15bd88e8c..bff9a8251 100644 --- a/app/assets/templates/feedback-actions.jst.hbs +++ b/app/assets/templates/feedback-actions.jst.hbs @@ -1,30 +1,30 @@ {{#if userLike}} - + {{else}} - + {{/if}} {{likesCount}} {{#if userCanReshare}} - - {{#if userReshare}} - - {{else}} - - {{/if}} - {{resharesCount}} - + + {{#if userReshare}} + + {{else}} + + {{/if}} + {{resharesCount}} + {{else}} - - {{#if userReshare}} - - {{else}} - - {{/if}} - {{resharesCount}} - + + {{#if userReshare}} + + {{else}} + + {{/if}} + {{resharesCount}} + {{/if}} diff --git a/app/assets/templates/stream.jst.hbs b/app/assets/templates/stream.jst.hbs index c0af34645..f05257ba1 100644 --- a/app/assets/templates/stream.jst.hbs +++ b/app/assets/templates/stream.jst.hbs @@ -4,6 +4,9 @@