DG DC MS; stream has one interactions div
This commit is contained in:
parent
78809798ad
commit
36ef010ed9
10 changed files with 74 additions and 49 deletions
|
|
@ -9,7 +9,7 @@ app.pages.PostViewer = app.views.Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function(options) {
|
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.preloadOrFetch().done(_.bind(this.initViews, this));
|
||||||
this.model.interactions.fetch() //async, yo, might want to throttle this later.
|
this.model.interactions.fetch() //async, yo, might want to throttle this later.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ app.pages.Stream = app.views.Base.extend({
|
||||||
templateName : "stream",
|
templateName : "stream",
|
||||||
|
|
||||||
subviews : {
|
subviews : {
|
||||||
"#stream-content" : "streamView"
|
"#stream-content" : "streamView",
|
||||||
|
"#stream-interactions" : "interactionsView"
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function(){
|
initialize : function(){
|
||||||
|
|
@ -19,5 +20,10 @@ app.pages.Stream = app.views.Base.extend({
|
||||||
this.stream.preloadOrFetch();
|
this.stream.preloadOrFetch();
|
||||||
|
|
||||||
this.streamView = new app.views.NewStream({ model : this.stream })
|
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)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
//=require "./feedback_view"
|
//=require "./feedback_view"
|
||||||
app.views.FeedbackActions = app.views.Feedback.extend({
|
app.views.FeedbackActions = app.views.Feedback.extend({
|
||||||
|
id : "user-controls",
|
||||||
templateName : "feedback-actions"
|
templateName : "feedback-actions"
|
||||||
})
|
});
|
||||||
|
|
@ -5,8 +5,7 @@ app.views.PostViewerInteractions = app.views.Base.extend({
|
||||||
subviews : {
|
subviews : {
|
||||||
"#post-feedback" : "feedbackView",
|
"#post-feedback" : "feedbackView",
|
||||||
"#post-reactions" : "reactionsView",
|
"#post-reactions" : "reactionsView",
|
||||||
"#new-post-comment" : "newCommentView",
|
"#new-post-comment" : "newCommentView"
|
||||||
".interaction_counts" : "interactionCountsView"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
templateName: "post-viewer/interactions",
|
templateName: "post-viewer/interactions",
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,9 @@
|
||||||
app.views.Post.StreamFrame = app.views.Post.SmallFrame.extend({
|
app.views.Post.StreamFrame = app.views.Post.SmallFrame.extend({
|
||||||
events :_.extend({
|
events : _.extend({
|
||||||
'click .content' : 'fetchInteractions'
|
'click .content' : 'triggerInteracted'
|
||||||
}, app.views.Post.SmallFrame.prototype.events),
|
}, app.views.Post.SmallFrame.prototype.events),
|
||||||
|
|
||||||
subviews :_.extend({
|
triggerInteracted : function() {
|
||||||
'.interactions' : 'interactionsView'
|
app.page.trigger("frame:interacted", this.model)
|
||||||
}, app.views.Post.SmallFrame.prototype.subviews),
|
|
||||||
|
|
||||||
initialize : function(){
|
|
||||||
this.interactionsView = new app.views.StreamInteractions({model : this.model})
|
|
||||||
},
|
|
||||||
|
|
||||||
postRenderTemplate : function(){
|
|
||||||
this.addStylingClasses()
|
|
||||||
this.$el.append($("<div class='interactions'/>"))
|
|
||||||
},
|
|
||||||
|
|
||||||
fetchInteractions : function() {
|
|
||||||
this.model.interactions.fetch().done(_.bind(function(){
|
|
||||||
this.interactionsView.render()
|
|
||||||
}, this));
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -1,13 +1,27 @@
|
||||||
app.views.StreamInteractions = app.views.Base.extend({
|
app.views.StreamInteractions = app.views.Base.extend({
|
||||||
subviews : {
|
|
||||||
|
id : "post-info",
|
||||||
|
|
||||||
|
subviews:{
|
||||||
".feedback" : "feedback",
|
".feedback" : "feedback",
|
||||||
".comments" : "comments"
|
".comments" : "comments",
|
||||||
|
".new-comment" : "newCommentView"
|
||||||
},
|
},
|
||||||
|
|
||||||
templateName : "stream-interactions",
|
templateName : "stream-interactions",
|
||||||
|
|
||||||
initialize : function(){
|
setInteractions : function (model) {
|
||||||
this.feedback = new app.views.FeedbackActions({ model : this.model })
|
model.interactions.fetch().done(
|
||||||
this.comments = new app.views.PostViewerFeedback({ model : this.model })
|
_.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)
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
|
||||||
|
|
@ -307,4 +307,20 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 8px;
|
right: 8px;
|
||||||
top: 8px;
|
top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* stream specific wrapper */
|
||||||
|
#stream-interactions {
|
||||||
|
position : fixed;
|
||||||
|
width : 420px;
|
||||||
|
|
||||||
|
#post-info {
|
||||||
|
text-align : left;
|
||||||
|
margin-top : 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#user-controls {
|
||||||
|
padding : 7px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
<a href="#" rel="auth-required" class="label like" title="{{#if userLike}} {{t "viewer.unlike"}} {{else}} {{t "viewer.like"}} {{/if}}">
|
<a href="#" rel="auth-required" class="label like" title="{{#if userLike}} {{t "viewer.unlike"}} {{else}} {{t "viewer.like"}} {{/if}}">
|
||||||
{{#if userLike}}
|
{{#if userLike}}
|
||||||
<i class="icon-heart icon-red"></i>
|
<i class="icon-heart icon-red"></i>
|
||||||
{{else}}
|
{{else}}
|
||||||
<i class="icon-heart icon-white"></i>
|
<i class="icon-heart icon-white"></i>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{likesCount}}
|
{{likesCount}}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
{{#if userCanReshare}}
|
{{#if userCanReshare}}
|
||||||
<a href="#" rel="auth-required" class="label reshare" title="{{#if userReshare}} {{t "viewer.reshared"}} {{else}} {{t "viewer.reshare"}} {{/if}}">
|
<a href="#" rel="auth-required" class="label reshare" title="{{#if userReshare}} {{t "viewer.reshared"}} {{else}} {{t "viewer.reshare"}} {{/if}}">
|
||||||
{{#if userReshare}}
|
{{#if userReshare}}
|
||||||
<i class="icon-retweet icon-blue"></i>
|
<i class="icon-retweet icon-blue"></i>
|
||||||
{{else}}
|
{{else}}
|
||||||
<i class="icon-retweet icon-white"></i>
|
<i class="icon-retweet icon-white"></i>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{resharesCount}}
|
{{resharesCount}}
|
||||||
</a>
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a class="label reshare-viewonly" title="{{#if userReshare}} {{t "viewer.reshared"}} {{else}} {{t "viewer.reshare"}} {{/if}}">
|
<a class="label reshare-viewonly" title="{{#if userReshare}} {{t "viewer.reshared"}} {{else}} {{t "viewer.reshare"}} {{/if}}">
|
||||||
{{#if userReshare}}
|
{{#if userReshare}}
|
||||||
<i class="icon-retweet icon-blue"></i>
|
<i class="icon-retweet icon-blue"></i>
|
||||||
{{else}}
|
{{else}}
|
||||||
<i class="icon-retweet icon-white"></i>
|
<i class="icon-retweet icon-white"></i>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{resharesCount}}
|
{{resharesCount}}
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<a href="#" class="label comment" rel="invoke-interaction-pane" title="{{t "viewer.comment"}}">
|
<a href="#" class="label comment" rel="invoke-interaction-pane" title="{{t "viewer.comment"}}">
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
<div class="span5">
|
<div class="span5">
|
||||||
<section id="stream-content"/>
|
<section id="stream-content"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="span5">
|
||||||
|
<section id="stream-interactions"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -2,6 +2,7 @@ describe("app.views.Post.StreamFrame", function(){
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
this.post = factory.post()
|
this.post = factory.post()
|
||||||
this.view = new app.views.Post.StreamFrame({model : this.post})
|
this.view = new app.views.Post.StreamFrame({model : this.post})
|
||||||
|
app.page = new app.pages.Stream({model : new app.models.Stream()})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("rendering", function(){
|
describe("rendering", function(){
|
||||||
|
|
@ -14,4 +15,4 @@ describe("app.views.Post.StreamFrame", function(){
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
Loading…
Reference in a new issue