From 44d3c4bacdf9f37c147462edf23d115cfa405651 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 5 Jan 2011 11:41:57 -0800 Subject: [PATCH] fixed inf scroll on filters issue. one spec failing in AspectsController. --- app/controllers/aspects_controller.rb | 2 +- app/views/aspects/show.html.haml | 4 ++++ public/javascripts/aspect-filters.js | 2 ++ public/javascripts/stream.js | 17 +++++++++++++++++ public/stylesheets/sass/application.sass | 4 ++-- spec/controllers/aspects_controller_spec.rb | 12 ++++++------ .../status_message_controller_spec.rb | 4 ++-- 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index dae3bbf78..e507bf6d0 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -90,7 +90,7 @@ class AspectsController < ApplicationController @aspect = :manage @contacts = current_user.contacts.where(:pending => false) @remote_requests = Request.hashes_for_person(current_user.person) - @aspect_hashes = hashes_for_aspects @aspects, @contacts + @aspect_hashes = hashes_for_aspects @all_aspects, @contacts end def update diff --git a/app/views/aspects/show.html.haml b/app/views/aspects/show.html.haml index 99ff874f9..f078fc62e 100644 --- a/app/views/aspects/show.html.haml +++ b/app/views/aspects/show.html.haml @@ -2,6 +2,10 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. + +- content_for :head do + = include_javascripts :home + - content_for :page_title do = @aspect.name.html_safe diff --git a/public/javascripts/aspect-filters.js b/public/javascripts/aspect-filters.js index f15682376..b783c9c04 100644 --- a/public/javascripts/aspect-filters.js +++ b/public/javascripts/aspect-filters.js @@ -83,6 +83,8 @@ $(document).ready(function(){ // (not cached because this element changes) $("#publisher textarea").val(post); + $('html, body').animate({scrollTop:0}, 'fast'); + // reinit listeners on stream Stream.initialize(); diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index be7b386f8..fd945b564 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -135,6 +135,8 @@ var Stream = { $(this).parents(".status_message").fadeOut(150); }); + // inf scroll + Stream.infiniteScroll($stream); }, toggleComments: function(evt) { @@ -178,6 +180,21 @@ var Stream = { commentBlock.find('textarea').focus(); } } + }, + + infiniteScroll: function(stream){ + stream.infinitescroll({ + navSelector : "div.pagination", + // selector for the paged navigation (it will be hidden) + nextSelector : ".pagination a.next_page", + // selector for the NEXT link (to page 2) + itemSelector : "#main_stream .stream_element", + // selector for all items you'll retrieve + bufferPx: 300, + donetext: "no more.", + loadingText: "", + loadingImg: '/images/ajax-loader.gif' + }); } }; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index b8ee14c8e..6a9e50783 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -130,7 +130,7 @@ header :bottom 1px solid #777 :padding 0 - :top 5px + :top 2px :color #CCC :position fixed @@ -921,7 +921,7 @@ label #aspect_nav :margin - :top 7px + :top 3px :bottom 2px :bottom 0 :color #000 diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 7205b6c60..01056e8ef 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -11,7 +11,7 @@ describe AspectsController do @user = make_user @user2 = make_user - @aspect0 = @user.aspects.create(:name => "lame-os") + @aspect0 = @user.aspects.create(:name => "lame-os") @aspect1 = @user.aspects.create(:name => "another aspect") @aspect2 = @user2.aspects.create(:name => "party people") @@ -37,7 +37,7 @@ describe AspectsController do end context 'filtering' do - before(:all) do + before do @posts = [] @users = [] 8.times do |n| @@ -97,7 +97,7 @@ describe AspectsController do end it "assigns aspect, aspect_contacts, and posts" do get :show, 'id' => @aspect0.id.to_s - assigns(:aspect).should == @aspect + assigns(:aspect).should == @aspect0 achash = @controller.send(:hashes_for_contacts, @aspect0.contacts).first assigns(:aspect_contacts).first[:contact].should == achash[:contact] assigns(:aspect_contacts).first[:person].should == achash[:person] @@ -105,7 +105,7 @@ describe AspectsController do end it "assigns contacts to only non-pending" do @user.contacts.count.should == 1 - @user.send_contact_request_to(make_user.person, @aspect) + @user.send_contact_request_to(make_user.person, @aspect0) @user.contacts.count.should == 2 get :show, 'id' => @aspect0.id.to_s @@ -164,7 +164,7 @@ describe AspectsController do end it "assigns contacts to only non-pending" do @user.contacts.count.should == 1 - @user.send_contact_request_to(make_user.person, @aspect) + @user.send_contact_request_to(make_user.person, @aspect0) @user.contacts.count.should == 2 get :manage @@ -251,7 +251,7 @@ describe AspectsController do end it 'has aspects' do @hashes.length.should == 2 - @hash[:aspect].should == @aspect + @hash[:aspect].should == @aspect0 end it 'has a contact_count' do @hash[:contact_count].should == @aspect0.contacts.count diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index 75d779732..cd3497dc6 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -52,8 +52,8 @@ describe StatusMessagesController do { :status_message => { :public =>"true", :message =>"facebook, is that you?", - :aspect_ids =>"#{aspect1.id}" } - } + }, + :aspect_ids =>"#{aspect1.id}" } } it 'responds to js requests' do post :create, status_message_hash.merge(:format => 'js')