canvas view is infinite stream

This commit is contained in:
Dennis Collinson 2012-04-19 12:22:50 -07:00
parent 062de4c269
commit f46dd08cb5
6 changed files with 64 additions and 75 deletions

View file

@ -1,5 +1,4 @@
app.pages.PostViewer = app.views.Base.extend({
templateName: "post-viewer",
subviews : {
@ -92,5 +91,4 @@ app.pages.PostViewer = app.views.Base.extend({
if(evt.keyCode != 27) { return }
this.interactionsView.hidePane();
}
});

View file

@ -1,35 +1,19 @@
//= require ../views/small_frame
app.pages.Profile = app.views.Base.extend(_.extend(app.views.infiniteScrollMixin, {
app.pages.Profile = app.views.Base.extend({
templateName : "profile",
// subviews : {
// "#canvas" : "canvasView"
// },
subviews : {
"#canvas" : "canvasView"
},
initialize : function(options) {
this.model = new app.models.Profile.findByGuid(options.personId)
this.stream = options && options.stream || new app.models.Stream()
this.collection = this.stream.posts
this.stream.fetch();
this.model.bind("change", this.render, this) //this should go on profile info view when it gets Extracted
this.model.bind("change", this.render, this)
// this.initViews()
// this.setupInfiniteScroll()
},
postClass : app.views.SmallFrame,
// mason : function() {
// this.$el.isotope({
// itemSelector : '.canvas-frame'
// })
// }
// initViews : function() {
// this.canvasView = new app.views.Canvas({model : this.model})
// }
}));
this.canvasView = new app.views.Canvas({model : this.stream})
}
});

View file

@ -1,14 +1,17 @@
app.views.Canvas = app.views.Base.extend({
templateName : 'canvas',
postRenderTemplate : function() {
setTimeout(_.bind(this.mason, this), 0)
},
mason : function() {
this.$el.isotope({
itemSelector : '.canvas-frame'
})
app.views.Canvas = app.views.Base.extend(_.extend(app.views.infiniteScrollMixin, {
initialize: function(){
this.stream = this.model
this.collection = this.stream.items
this.postClass = app.views.SmallFrame,
this.setupInfiniteScroll()
}
})
// renderTemplate : function() {
// setTimeout(_.bind(this.mason, this), 1000)
// },
//
// mason : function() {
// this.$el.isotope({
// itemSelector : '.canvas-frame'
// })
// }
}))

View file

@ -1,11 +1,15 @@
<h1>{{full_name}}</h1>
<div>
Gender: {{gender}}
</div>
<div>
Bio: {{bio}}
</div>
<div>
Birthday: {{birthday}}
</div>
<section id="profile_info">
<h1>{{full_name}}</h1>
<div>
Gender: {{gender}}
</div>
<div>
Bio: {{bio}}
</div>
<div>
Birthday: {{birthday}}
</div>
</section>
<section id="canvas">
</section>

View file

@ -5,12 +5,7 @@ describe("app.pages.Profile", function(){
this.stream = this.page.stream
});
// xit("passes the model down to the post view", function(){
// expect(this.page.canvasView.model).toBeDefined()
// expect(this.page.canvasView.model).toBe(this.stream)
// });
it("fetches the profile of the user with the params from the router", function(){
it("fetches the profile of the user with the params from the router and assigns it as the model", function(){
profile = new factory.profile()
spyOn(app.models.Profile, 'findByGuid').andReturn(profile)
var page = new app.pages.Profile({personId : 'jarjabinkisthebest' })
@ -18,6 +13,11 @@ describe("app.pages.Profile", function(){
expect(page.model).toBe(profile)
})
it("passes the model down to the post view", function(){
expect(this.page.canvasView.model).toBeDefined()
expect(this.page.canvasView.model).toBe(this.stream)
});
it("fetches the stream for the user", function(){
spyOn(this.stream, "fetch")
new app.pages.Profile({stream : this.stream})

View file

@ -16,24 +16,24 @@ describe("app.views.Photos", function() {
}, this);
});
describe("initialize", function() {
it("binds an infinite scroll listener", function() {
spyOn($.fn, "scroll");
new app.views.Stream({model : this.stream});
expect($.fn.scroll).toHaveBeenCalled();
});
});
describe("#render", function() {
beforeEach(function() {
this.photo = this.stream.items.models[0];
this.photoElement = $(this.view.$("#" + this.photo.get("guid")));
});
context("when rendering a photo message", function() {
it("shows the photo in the content area", function() {
expect(this.photoElement.length).toBeGreaterThan(0); //markdown'ed
});
});
});
// describe("initialize", function() {
// it("binds an infinite scroll listener", function() {
// spyOn($.fn, "scroll");
// new app.views.Stream({model : this.stream});
// expect($.fn.scroll).toHaveBeenCalled();
// });
// });
//
// describe("#render", function() {
// beforeEach(function() {
// this.photo = this.stream.items.models[0];
// this.photoElement = $(this.view.$("#" + this.photo.get("guid")));
// });
//
// context("when rendering a photo message", function() {
// it("shows the photo in the content area", function() {
// expect(this.photoElement.length).toBeGreaterThan(0); //markdown'ed
// });
// });
// });
});