fixing event passing
This commit is contained in:
parent
abc4843273
commit
1c342282b0
7 changed files with 46 additions and 23 deletions
|
|
@ -22,7 +22,7 @@ app.pages.Stream = app.views.Base.extend({
|
||||||
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()
|
var interactions = this.interactionsView = new app.views.StreamInteractions()
|
||||||
|
|
||||||
this.on("frame:interacted", function(post){
|
this.stream.on("frame:interacted", function(post){
|
||||||
interactions.setInteractions(post)
|
interactions.setInteractions(post)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ app.views.InfScroll = app.views.Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
createPostView : function(post){
|
createPostView : function(post){
|
||||||
var postView = new this.postClass({ model: post });
|
var postView = new this.postClass({ model: post, stream: this.stream });
|
||||||
this.postViews.push(postView)
|
this.postViews.push(postView)
|
||||||
return postView
|
return postView
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,11 @@ app.views.Post.SmallFrame = app.views.Post.extend({
|
||||||
'.embed-frame' : "oEmbedView"
|
'.embed-frame' : "oEmbedView"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initialize : function(options) {
|
||||||
|
this.stream = options.stream;
|
||||||
|
this.addStylingClasses()
|
||||||
|
},
|
||||||
|
|
||||||
oEmbedView : function(){
|
oEmbedView : function(){
|
||||||
return new app.views.OEmbed({model : this.model})
|
return new app.views.OEmbed({model : this.model})
|
||||||
},
|
},
|
||||||
|
|
@ -28,10 +33,6 @@ app.views.Post.SmallFrame = app.views.Post.extend({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function() {
|
|
||||||
this.addStylingClasses()
|
|
||||||
},
|
|
||||||
|
|
||||||
postRenderTemplate : function() {
|
postRenderTemplate : function() {
|
||||||
this.addStylingClasses()
|
this.addStylingClasses()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
app.views.Post.StreamFrame = app.views.Base.extend({
|
app.views.Post.StreamFrame = app.views.Base.extend({
|
||||||
|
|
||||||
className : "stream-frame",
|
className : "stream-frame",
|
||||||
|
|
||||||
templateName : "stream-frame",
|
templateName : "stream-frame",
|
||||||
|
|
@ -8,18 +7,19 @@ app.views.Post.StreamFrame = app.views.Base.extend({
|
||||||
".small-frame" : "smallFrameView"
|
".small-frame" : "smallFrameView"
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize : function() {
|
initialize : function(options) {
|
||||||
this.smallFrameView = new app.views.Post.SmallFrame({model : this.model})
|
this.stream = options.stream
|
||||||
|
this.smallFrameView = new app.views.Post.SmallFrame({model : this.model, stream: this.stream})
|
||||||
},
|
},
|
||||||
|
|
||||||
events : _.extend({
|
events : _.extend({
|
||||||
'click .content' : 'triggerInteracted'
|
'click .content' : 'triggerInteracted'
|
||||||
}, app.views.Post.SmallFrame.prototype.events),
|
}, app.views.Post.SmallFrame.prototype.events),
|
||||||
|
|
||||||
|
|
||||||
triggerInteracted : function() {
|
triggerInteracted : function() {
|
||||||
app.page.trigger("frame:interacted", this.model)
|
this.stream.trigger("frame:interacted", this.model)
|
||||||
},
|
},
|
||||||
|
|
||||||
// this is some gross shit.
|
|
||||||
goToPost : $.noop
|
goToPost : $.noop
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
app.views.StreamInteractions = app.views.Base.extend({
|
app.views.StreamInteractions = app.views.Base.extend({
|
||||||
|
|
||||||
id : "post-info",
|
id : "post-info",
|
||||||
|
|
||||||
subviews:{
|
subviews:{
|
||||||
|
|
@ -19,9 +18,5 @@ app.views.StreamInteractions = app.views.Base.extend({
|
||||||
this.feedback = new app.views.FeedbackActions({ model: model })
|
this.feedback = new app.views.FeedbackActions({ model: model })
|
||||||
this.comments = new app.views.PostViewerReactions({ model: model.interactions })
|
this.comments = new app.views.PostViewerReactions({ model: model.interactions })
|
||||||
this.newCommentView = new app.views.PostViewerNewComment({ model : model })
|
this.newCommentView = new app.views.PostViewerNewComment({ model : model })
|
||||||
},
|
|
||||||
|
|
||||||
postRenderTemplate : function(){
|
|
||||||
console.log(this.$el)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
22
spec/javascripts/app/pages/stream_spec.js
Normal file
22
spec/javascripts/app/pages/stream_spec.js
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
describe("app.Pages.Stream", function(){
|
||||||
|
beforeEach(function(){
|
||||||
|
app.setPreload("stream", [factory.post().attributes])
|
||||||
|
this.page = new app.pages.Stream()
|
||||||
|
this.post = this.page.model.items.models[0]
|
||||||
|
expect(this.post).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("rendering", function(){
|
||||||
|
beforeEach(function(){
|
||||||
|
this.page.render()
|
||||||
|
})
|
||||||
|
|
||||||
|
context("clicking the content", function(){
|
||||||
|
it("triggers frame interacted", function(){
|
||||||
|
spyOn(this.post.interactions, "fetch").andReturn(new $.Deferred)
|
||||||
|
this.page.$('.canvas-frame:first .content').click()
|
||||||
|
expect(this.post.interactions.fetch).toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
@ -1,18 +1,23 @@
|
||||||
describe("app.views.Post.StreamFrame", function(){
|
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.stream = new Backbone.Model
|
||||||
app.page = new app.pages.Stream({model : new app.models.Stream()})
|
this.view = new app.views.Post.StreamFrame({model : this.post, stream: this.stream })
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("rendering", function(){
|
describe("rendering", function(){
|
||||||
|
beforeEach(function(){
|
||||||
|
this.view.render()
|
||||||
|
})
|
||||||
|
|
||||||
context("clicking the content", function(){
|
context("clicking the content", function(){
|
||||||
it("fetches the interaction pane", function(){
|
it("triggers frame interacted", function(){
|
||||||
spyOn(this.post.interactions, "fetch").andReturn(new $.Deferred)
|
var spy = jasmine.createSpy()
|
||||||
this.view.render()
|
this.stream.on("frame:interacted", spy)
|
||||||
this.view.$('.content').click()
|
this.view.$('.content').click()
|
||||||
expect(this.post.interactions.fetch).toHaveBeenCalled()
|
expect(spy).toHaveBeenCalledWith(this.post)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue