new stream now remembers how far you have scrolled.
also, jasmine is really cool.
This commit is contained in:
parent
92c0fa0163
commit
82218fd7cb
3 changed files with 34 additions and 2 deletions
|
|
@ -29,5 +29,18 @@ app.pages.Stream = app.views.Base.extend({
|
|||
|
||||
postRenderTemplate : function() {
|
||||
this.$("#header").css("background-image", "url(" + app.currentUser.get("wallpaper") + ")")
|
||||
}
|
||||
this.setUpHashChangeOnStreamLoad()
|
||||
},
|
||||
|
||||
setUpHashChangeOnStreamLoad : function(){
|
||||
var self = this;
|
||||
this.streamView.on('loadMore', function(){
|
||||
var post = this.stream.items.last();
|
||||
self.navigateToPost(post)
|
||||
});
|
||||
},
|
||||
|
||||
navigateToPost : function(post){
|
||||
app.router.navigate(location.pathname + "?ex=true&max_time=" + post.createdAt(), {replace: true})
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
app.Router = Backbone.Router.extend({
|
||||
routes: {
|
||||
//new hotness
|
||||
"stream?ex=true:params": 'newStream',
|
||||
"stream?ex=true": 'newStream',
|
||||
"people/:id?ex=true": "newProfile",
|
||||
"posts/new" : "composer",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ describe("app.Pages.Stream", function(){
|
|||
describe('postRenderTemplate', function(){
|
||||
it("sets the background-image of #header", function(){
|
||||
this.page.render()
|
||||
console.log(this.page.$('#header').css('background-image'))
|
||||
expect(this.page.$('#header').css('background-image')).toBeTruthy()
|
||||
})
|
||||
|
||||
|
|
@ -34,4 +33,23 @@ describe("app.Pages.Stream", function(){
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("setUpHashChangeOnStreamLoad", function(){
|
||||
it('calls navigateToPost on the loadMore event', function(){
|
||||
spyOn(this.page, 'navigateToPost')
|
||||
this.page.setUpHashChangeOnStreamLoad()
|
||||
this.page.streamView.trigger('loadMore')
|
||||
expect(this.page.navigateToPost).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe("navigateToPost", function(){
|
||||
it("sets the max time of the url to the created at time of a post", function(){
|
||||
spyOn(app.router, 'navigate')
|
||||
this.page.navigateToPost(this.post)
|
||||
var url = location.pathname + "?ex=true&max_time=" + this.post.createdAt()
|
||||
var options = {replace: true}
|
||||
expect(app.router.navigate).toHaveBeenCalledWith(url, options)
|
||||
})
|
||||
})
|
||||
});
|
||||
Loading…
Reference in a new issue