From d926529ad7801110d2b7e9483d5f6e497c4a5651 Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Wed, 30 May 2012 14:42:32 -0700 Subject: [PATCH] wip dennis --- app/assets/javascripts/app/pages/stream.js | 30 ++++++++++++++----- .../javascripts/bootstrap-scrollspy-custom.js | 2 -- .../stylesheets/new_styles/_canvas.scss | 4 +++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/pages/stream.js b/app/assets/javascripts/app/pages/stream.js index 87b555a3a..526107abe 100644 --- a/app/assets/javascripts/app/pages/stream.js +++ b/app/assets/javascripts/app/pages/stream.js @@ -28,6 +28,8 @@ app.pages.Stream = app.views.Base.extend({ this.streamView = new app.views.NewStream({ model : this.stream }) var interactions = this.interactionsView = new app.views.StreamInteractions() + this.setUpThrottledInteractionScroll(); + this.stream.on("frame:interacted", function(post){ interactions.setInteractions(post) }) @@ -35,11 +37,22 @@ app.pages.Stream = app.views.Base.extend({ postRenderTemplate : function() { this.$("#header").css("background-image", "url(" + app.currentUser.get("wallpaper") + ")") - $('body').scrollspy({target : '.stream-frame-wrapper'}) - setTimeout(_.bind(this.refreshScrollSpy, this), 2000) + + _.defer(function(){$('body').scrollspy({target : '.stream-frame-wrapper', offset : 50})}) + + this.setUpHashChangeOnStreamLoad() }, + setUpThrottledInteractionScroll : function(){ + this.focusedPost = undefined; + var self = this; + this.updateInteractions = _.throttle(function(){ + console.log("firing for " + self.focusedPost.get('id')); + self.interactionsView.setInteractions(self.focusedPost) + }, 1000) + }, + setUpHashChangeOnStreamLoad : function(){ var self = this; this.streamView.on('loadMore', function(){ @@ -47,6 +60,7 @@ app.pages.Stream = app.views.Base.extend({ if(post){ self.navigateToPost(post) } + self.refreshScrollSpy() }); }, @@ -55,16 +69,18 @@ app.pages.Stream = app.views.Base.extend({ }, - }, - triggerInteractionLoad : function(evt){ - var post = this.stream.items.get($(evt.target).data("id")) - this.interactionsView.setInteractions(post) + var id = $(evt.target).data("id"); + console.log("calling triggerInteractiosns for: " + id) + this.focusedPost = this.stream.items.get(id) + this.updateInteractions() }, //on active guid => this guid // fire interacted from stream collection w/guid refreshScrollSpy : function(){ - $('body').scrollspy('refresh') + setTimeout(function(){ + $('body').scrollspy('refresh') + }, 2000) } }); diff --git a/app/assets/javascripts/bootstrap-scrollspy-custom.js b/app/assets/javascripts/bootstrap-scrollspy-custom.js index ff23fd4ca..55185ba1d 100644 --- a/app/assets/javascripts/bootstrap-scrollspy-custom.js +++ b/app/assets/javascripts/bootstrap-scrollspy-custom.js @@ -109,8 +109,6 @@ active = $(selector) .addClass('active') - console.log(active) - active.trigger('activate') } diff --git a/app/assets/stylesheets/new_styles/_canvas.scss b/app/assets/stylesheets/new_styles/_canvas.scss index 9242c276d..c1b1ad93e 100644 --- a/app/assets/stylesheets/new_styles/_canvas.scss +++ b/app/assets/stylesheets/new_styles/_canvas.scss @@ -438,6 +438,10 @@ color: white; margin-top : 11px; } } + + .active { + border: 10px solid red; + } } .canvas-frame {