Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

new stream now remembers how far you have scrolled.

also, jasmine is really cool.
  • Loading branch information...
commit 82218fd7cba89c9b2eda06f70660d804d32d2ab5 1 parent 92c0fa0
@maxwell maxwell authored
View
15 app/assets/javascripts/app/pages/stream.js
@@ -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})
+ },
});
View
1  app/assets/javascripts/app/router.js
@@ -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",
View
20 spec/javascripts/app/pages/stream_spec.js
@@ -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)
+ })
+ })
});
Please sign in to comment.
Something went wrong with that request. Please try again.